Skip to content

Commit 3cadfc2

Browse files
committed
Fix tests to run with latest pytest
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
1 parent f05a1db commit 3cadfc2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/pyop/test_authz_state.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ def authorization_state_factory(self):
3737
def authorization_state(self, authorization_state_factory):
3838
return authorization_state_factory(refresh_token_lifetime=3600)
3939

40-
def assert_access_token(self, access_token, access_token_db, iat):
40+
def assert_access_token(self, authorization_request, access_token, access_token_db, iat):
4141
assert isinstance(access_token, AccessToken)
4242
assert access_token.expires_in == self.TEST_TOKEN_LIFETIME
4343
assert access_token.value
4444
assert access_token.BEARER_TOKEN_TYPE == 'Bearer'
4545

4646
assert access_token.value in access_token_db
47-
self.assert_introspected_token(access_token_db[access_token.value], access_token, iat)
47+
self.assert_introspected_token(authorization_request, access_token_db[access_token.value], access_token, iat)
4848
assert access_token_db[access_token.value]['exp'] == iat + self.TEST_TOKEN_LIFETIME
4949

50-
def assert_introspected_token(self, token_introspection, access_token, iat):
51-
auth_req = self.authorization_request().to_dict()
50+
def assert_introspected_token(self, authorization_request, token_introspection, access_token, iat):
51+
auth_req = authorization_request.to_dict()
5252

5353
assert token_introspection['scope'] == auth_req['scope']
5454
assert token_introspection['client_id'] == auth_req['client_id']
@@ -91,7 +91,7 @@ def test_create_access_token(self, authorization_state_factory, authorization_re
9191
self.set_valid_subject_identifier(authorization_state)
9292

9393
access_token = authorization_state.create_access_token(authorization_request, self.TEST_SUBJECT_IDENTIFIER)
94-
self.assert_access_token(access_token, authorization_state.access_tokens, MOCK_TIME.return_value)
94+
self.assert_access_token(authorization_request, access_token, authorization_state.access_tokens, MOCK_TIME.return_value)
9595

9696
def test_create_access_token_with_scope_other_than_auth_req(self, authorization_state, authorization_request):
9797
scope = ['openid', 'extra']
@@ -115,7 +115,7 @@ def test_introspect_access_token(self, authorization_state_factory, authorizatio
115115
access_token = authorization_state.create_access_token(authorization_request, self.TEST_SUBJECT_IDENTIFIER)
116116
token_introspection = authorization_state.introspect_access_token(access_token.value)
117117
assert token_introspection['active'] is True
118-
self.assert_introspected_token(token_introspection, access_token, MOCK_TIME.return_value)
118+
self.assert_introspected_token(authorization_request, token_introspection, access_token, MOCK_TIME.return_value)
119119

120120
def test_introspect_access_token_with_expired_token(self, authorization_state_factory, authorization_request):
121121
authorization_state = authorization_state_factory(access_token_lifetime=self.TEST_TOKEN_LIFETIME)
@@ -129,7 +129,7 @@ def test_introspect_access_token_with_expired_token(self, authorization_state_fa
129129
with patch('time.time', mock_time2):
130130
token_introspection = authorization_state.introspect_access_token(access_token.value)
131131
assert token_introspection['active'] is False
132-
self.assert_introspected_token(token_introspection, access_token, MOCK_TIME.return_value)
132+
self.assert_introspected_token(authorization_request, token_introspection, access_token, MOCK_TIME.return_value)
133133

134134
@pytest.mark.parametrize('access_token', INVALID_INPUT)
135135
def test_introspect_access_token_with_invalid_access_token(self, access_token, authorization_state):
@@ -149,7 +149,7 @@ def test_exchange_code_for_token(self, authorization_state_factory, authorizatio
149149
authz_code = authorization_state.create_authorization_code(authorization_request, self.TEST_SUBJECT_IDENTIFIER)
150150
access_token = authorization_state.exchange_code_for_token(authz_code)
151151

152-
self.assert_access_token(access_token, authorization_state.access_tokens, MOCK_TIME.return_value)
152+
self.assert_access_token(authorization_request, access_token, authorization_state.access_tokens, MOCK_TIME.return_value)
153153
assert authorization_state.authorization_codes[authz_code]['used'] == True
154154

155155
def test_exchange_code_for_token_with_scope_other_than_auth_req(self, authorization_state,
@@ -248,7 +248,7 @@ def test_use_refresh_token(self, authorization_state_factory, authorization_requ
248248
authorization_state.access_tokens[old_access_token.value]['exp']
249249
assert authorization_state.access_tokens[new_access_token.value]['iat'] > \
250250
authorization_state.access_tokens[old_access_token.value]['iat']
251-
self.assert_access_token(new_access_token, authorization_state.access_tokens, mock_time2.return_value)
251+
self.assert_access_token(authorization_request, new_access_token, authorization_state.access_tokens, mock_time2.return_value)
252252

253253
assert authorization_state.refresh_tokens[refresh_token]['access_token'] == new_access_token.value
254254

@@ -430,4 +430,4 @@ def test_remove_state_for_subject_identifier(self, authorization_state, authoriz
430430

431431
def test_remove_state_for_unknown_subject_identifier(self, authorization_state):
432432
with pytest.raises(InvalidSubjectIdentifier):
433-
authorization_state.delete_state_for_subject_identifier('unknown')
433+
authorization_state.delete_state_for_subject_identifier('unknown')

0 commit comments

Comments
 (0)