Beispiel #1
0
 def test_delete_token_logged_in(self, api, client):
     token, _ = register_and_login_confirmed_user(api, client,
                                                  "tokenreader",
                                                  "*****@*****.**",
                                                  "passwd")
     url = api.url_for(Token, token_id=2)
     response = client.delete(url, headers=get_authorization_header(token))
     response_json = get_response_json(response.data)
     assert (response.status_code == 200)
     assert (response_json["messages"]["token"] is not None)
     assert (TokenRegistry.get_by_id(1) is not None)
     assert (TokenRegistry.get_by_id(2) is None)  # should have been deleted
Beispiel #2
0
 def test_update_token_unrevoke(self, api, client):
     token, _ = register_and_login_confirmed_user(api, client,
                                                  "tokenreader",
                                                  "*****@*****.**",
                                                  "passwd")
     update_token = TokenRegistry.get_by_id(2)
     update_token.revoked = True
     url = api.url_for(Token, token_id=2)
     response = client.put(url,
                           data={'revoked': 'False'},
                           headers=get_authorization_header(token))
     response_json = get_response_json(response.data)
     assert (response.status_code == 200)
     assert (response_json["revoked"] == False)
Beispiel #3
0
 def test_get_by_id(self):
     new_token = TokenRegistry('jti', 'type', 'username', True,
                               dt.datetime.utcnow())
     new_token.save()
     retrieved_token = TokenRegistry.get_by_id(new_token.id)
     assert (retrieved_token == new_token)