diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2017-05-17 18:31:26 +0800 |
---|---|---|
committer | Serena Feng <feng.xiaowei@zte.com.cn> | 2017-05-18 01:01:05 +0000 |
commit | d57892f46ca4864f2188d0e4fccb97d3987c10d1 (patch) | |
tree | caafd5d32898992591f9eb68a5e3d078ddd167c0 /testapi/opnfv_testapi/ui/auth/utils.py | |
parent | bd392ea5ac1797d97348a8f98f254d0fff1241aa (diff) |
add signin web to TestAPI
Change-Id: I4d39a8561c8ebd3238a495e5799fd43fb1a508b9
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/opnfv_testapi/ui/auth/utils.py')
-rw-r--r-- | testapi/opnfv_testapi/ui/auth/utils.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testapi/opnfv_testapi/ui/auth/utils.py b/testapi/opnfv_testapi/ui/auth/utils.py new file mode 100644 index 0000000..c3912ad --- /dev/null +++ b/testapi/opnfv_testapi/ui/auth/utils.py @@ -0,0 +1,23 @@ +import random +import string + +from six.moves.urllib import parse + + +def get_token(length=30): + """Get random token.""" + return ''.join(random.choice(string.ascii_lowercase) + for i in range(length)) + + +def set_query_params(url, params): + """Set params in given query.""" + url_parts = parse.urlparse(url) + url = parse.urlunparse(( + url_parts.scheme, + url_parts.netloc, + url_parts.path, + url_parts.params, + parse.urlencode(params), + url_parts.fragment)) + return url |