|
2 | 2 | from flask_jwt_extended import decode_token |
3 | 3 |
|
4 | 4 | from openatlas.database.token import get_tokens |
5 | | -from openatlas.models.user import User |
6 | 5 | from openatlas import app, check_incoming_tokens |
7 | 6 | from tests.base import TestBaseCase |
8 | 7 |
|
@@ -77,17 +76,19 @@ def test_token(self) -> None: |
77 | 76 | g.settings['api_public'] = False |
78 | 77 | c.get(url_for('logout')) |
79 | 78 | for token in jwt_token_strings: |
80 | | - #decoded = decode_token(token) |
81 | | - #check = check_incoming_tokens({'typ': 'JWT'}, decoded) |
82 | | - #assert check is True if decoded['sub'] in ['Alice', 'Inactive'] else False |
83 | | - |
84 | | - # should fail if check_incoming_tokens checks for user active |
| 79 | + decoded = decode_token(token) |
85 | 80 | rv = c.get( |
86 | 81 | url_for('api_04.class_mapping', locale='de'), |
87 | 82 | headers={'Authorization': f'Bearer {token}'}) |
88 | | - assert b'results' in rv.data |
89 | | - |
90 | | - # assert check_incoming_tokens({'typ': 'Unknown'}, decoded) is True |
| 83 | + if decoded['sub'] in ['Alice', 'Inactive']: |
| 84 | + assert b'Token has been revoked' in rv.data |
| 85 | + else: |
| 86 | + assert b'results' in rv.data |
| 87 | + |
| 88 | + assert check_incoming_tokens({'typ': 'Unknown'}, decoded) is True |
| 89 | + c.post( |
| 90 | + url_for('login'), |
| 91 | + data={'username': 'Alice', 'password': 'test'}) |
91 | 92 |
|
92 | 93 | rv = c.get(url_for('delete_revoked_tokens'), follow_redirects=True) |
93 | 94 | assert b'All revoked tokens deleted' in rv.data |
|
0 commit comments