summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/ui/auth/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'testapi/opnfv_testapi/ui/auth/utils.py')
-rw-r--r--testapi/opnfv_testapi/ui/auth/utils.py23
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