summaryrefslogtreecommitdiffstats
path: root/testapi/testapi-client/testapiclient/authHandler.py
blob: baa1088a8c99019fb3fd88cbab67cd3358f2da74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import requests
from user import User
from config import Config
import urllib


class AuthHandler:

    @staticmethod
    def authenticate(username, password):
        session = requests.Session()
        hostname = '{}{}{}'.format(
            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