Ejemplo n.º 1
0
def create_request_with_api_token_header(json_body=None,
                                         match_dict=None,
                                         nickname='Walter'):
    token = generate_application_token("TEST_API_TOKEN_FOR_" + nickname)
    request: IRequest = construct_dummy_request(json_body=json_body,
                                                match_dict=match_dict)
    request.headers['X-Authentication'] = json.dumps({
        'nickname': nickname,
        'token': token
    })
    return request
Ejemplo n.º 2
0
 def test_generate_check(self):
     token = admin.generate_application_token("test")
     self.assertTrue(admin.check_api_token(token))
Ejemplo n.º 3
0
def generate_api_token(request):
    owner = request.params['owner']
    token = lib.generate_application_token(owner)
    LOG.debug("API-Token for %s was created.", owner)
    return {'token': token}
Ejemplo n.º 4
0
def generate_api_token(request):
    owner = request.params['owner']
    token = lib.generate_application_token(owner)
    logger('Admin', 'API-Token for {} was created.'.format(owner))
    return {'token': token}