示例#1
0
 def test_encode_eternal_jwt_token(self, app, user_class):
     """
     This test verifies that the encode_eternal_jwt_token correctly encodes
     jwt data based on a user instance. Also verifies that the lifespan is
     set to the constant VITAM_AETERNUM
     """
     guard = Praetorian(app, user_class)
     the_dude = user_class(
         username='******',
         password=guard.encrypt_password('abides'),
         roles='admin,operator',
     )
     moment = pendulum.parse('2017-05-21 18:39:55')
     with freezegun.freeze_time(moment):
         token = guard.encode_eternal_jwt_token(the_dude)
         token_data = jwt.decode(
             token,
             guard.encode_key,
             algorithms=guard.allowed_algorithms,
         )
         assert token_data['iat'] == moment.int_timestamp
         assert token_data['exp'] == (moment + VITAM_AETERNUM).int_timestamp
         assert token_data['rf_exp'] == (moment +
                                         VITAM_AETERNUM).int_timestamp
         assert token_data['id'] == the_dude.id
示例#2
0
 def test_encode_eternal_jwt_token(self, app, user_class):
     """
     This test verifies that the encode_eternal_jwt_token correctly encodes
     jwt data based on a user instance. Also verifies that the lifespan is
     set to the constant VITAM_AETERNUM
     """
     guard = Praetorian(app, user_class)
     the_dude = user_class(
         username="******",
         password=guard.hash_password("abides"),
         roles="admin,operator",
     )
     moment = plummet.momentize('2017-05-21 18:39:55')
     with plummet.frozen_time(moment):
         token = guard.encode_eternal_jwt_token(the_dude)
         token_data = jwt.decode(
             token,
             guard.encode_key,
             algorithms=guard.allowed_algorithms,
         )
         assert token_data["iat"] == moment.int_timestamp
         assert token_data["exp"] == (moment + VITAM_AETERNUM).int_timestamp
         assert (token_data[REFRESH_EXPIRATION_CLAIM] == (
             moment + VITAM_AETERNUM).int_timestamp)
         assert token_data["id"] == the_dude.id