Beispiel #1
0
def create_token_non_internal():
    token = cache.get('test-token-non-internal')
    if token is None:
        data = {'username': '******', 'password': '******'}

        req = call_client(request)
        res = req.get('/auth', query_string=data)

        res_json = json.loads(res.data)

        logging.warning('RESULT : %s', res_json)

        assert res.status_code == 200

        cache.set('test-token-non-internal', res_json['token'], timeout=60)

        return res_json['token']
    else:
        return token
Beispiel #2
0
def create_internal_token() :
    token = cache.get('test-token-internal')
    if token is None :
        data = {
            'client_key' : 'rahasia1',
            'client_secret' : 'rahasia1'
        }

        req = call_client(request) 
        res = req.get('/auth', query_string=data)

        res_json = json.loads(res.data)

        logging.warning('RESULT : %s', res_json)

        assert res.status_code == 200

        cache.set('test-token-internal', res_json['token'], timeout=60)

        return res_json['token']
    else :
        return token
def create_token_penjual():
    token = cache.get('test-token')
    if token is None:
        ##prepare request input
        data = {'username': '******', 'password': '******'}
        # do request
        req = call_client(request)
        res = req.get('/users/login',
                      query_string=data,
                      content_type='application/json')

        # store response
        res_json = json.loads(res.data)

        logging.warning('RESULT : %s', res_json)
        # assert if the result is as expected
        assert res.status_code == 200

        # save token into cache
        cache.set('test_token', res_json['token'], timeout=60)

        return res_json['token']
    else:
        return token