|
| 1 | +import jwt |
1 | 2 | import pytest |
2 | 3 | from flask_authz.utils import authorization_decoder, UnSupportedAuthType |
3 | 4 |
|
4 | 5 |
|
5 | 6 | @pytest.mark.parametrize("auth_str, result", [("Basic Ym9iOnBhc3N3b3Jk", "Bob")]) |
6 | | -def test_auth_docode(auth_str, result): |
7 | | - assert authorization_decoder(auth_str) == "bob" |
| 7 | +def test_auth_docode(app_fixture, auth_str, result): |
| 8 | + assert authorization_decoder(app_fixture.config, auth_str) == "bob" |
8 | 9 |
|
9 | 10 |
|
10 | 11 | @pytest.mark.parametrize( |
11 | | - "auth_str", [("Bearer Ym9iOnBhc3N3b3Jk"), ("Unsupported Ym9iOnBhc3N3b3Jk")] |
| 12 | + "auth_str, result", |
| 13 | + [("Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZGVudGl0eSI6IkJvYiJ9" |
| 14 | + ".YZqkPHdrxkkFNg7GNL8g-hRpiD9LPyospO47Mh3iEDk", "Bob")]) |
| 15 | +def test_auth_docode(app_fixture, auth_str, result): |
| 16 | + assert authorization_decoder(app_fixture.config, auth_str) == "Bob" |
| 17 | + |
| 18 | + |
| 19 | +@pytest.mark.parametrize( |
| 20 | + "auth_str", [("Unsupported Ym9iOnBhc3N3b3Jk")] |
12 | 21 | ) |
13 | | -def test_auth_docode_exceptions(auth_str): |
| 22 | +def test_auth_docode_exceptions(app_fixture, auth_str): |
14 | 23 | with pytest.raises(UnSupportedAuthType): |
15 | | - authorization_decoder(auth_str) |
| 24 | + authorization_decoder(app_fixture.config, auth_str) |
| 25 | + |
| 26 | + |
| 27 | +@pytest.mark.parametrize( |
| 28 | + "auth_str", |
| 29 | + [("Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2MTUxMDg0OTIuNTY5MjksImlkZW50aXR5IjoiQm9iIn0." |
| 30 | + "CAeMpG-gKbucHU7-KMiqM7H_gTkHSRvXSjNtlvh5DlE")] |
| 31 | +) |
| 32 | +def test_auth_docode_exceptions(app_fixture, auth_str): |
| 33 | + with pytest.raises(jwt.ExpiredSignatureError): |
| 34 | + authorization_decoder(app_fixture.config, auth_str) |
0 commit comments