summaryrefslogtreecommitdiffstats
path: root/testapi/testapi-client/testapiclient/authHandler.py
diff options
context:
space:
mode:
Diffstat (limited to 'testapi/testapi-client/testapiclient/authHandler.py')
-rw-r--r--testapi/testapi-client/testapiclient/authHandler.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/testapi/testapi-client/testapiclient/authHandler.py b/testapi/testapi-client/testapiclient/authHandler.py
new file mode 100644
index 0000000..a421cf8
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/authHandler.py
@@ -0,0 +1,16 @@
+import requests
+from user import User
+from config import Config
+import urllib
+
+
+class AuthHandler:
+
+ @staticmethod
+ def authenticate(username, password):
+ session = requests.Session()
+ hostname = Config.config.get("cas", "auth_url") + urllib.quote(Config.config.get("api", "url")) + Config.config.get("cas", "signin_return")
+ data = {'name': username, 'pass': password, 'form_id': 'user_login'}
+ response = session.post(hostname, data)
+ User.session = session
+ return response