-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from shenwpo/Bearer
Implement bearer authorization
- Loading branch information
Showing
6 changed files
with
45 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ jinja2==2.11.2 | |
markupsafe==1.1.1 | ||
simpleeval==0.9.10 | ||
werkzeug==1.0.1 | ||
PyJWT==2.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
import jwt | ||
import pytest | ||
from flask_authz.utils import authorization_decoder, UnSupportedAuthType | ||
|
||
|
||
@pytest.mark.parametrize("auth_str, result", [("Basic Ym9iOnBhc3N3b3Jk", "Bob")]) | ||
def test_auth_docode(auth_str, result): | ||
assert authorization_decoder(auth_str) == "bob" | ||
def test_auth_docode(app_fixture, auth_str, result): | ||
assert authorization_decoder(app_fixture.config, auth_str) == "bob" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"auth_str", [("Bearer Ym9iOnBhc3N3b3Jk"), ("Unsupported Ym9iOnBhc3N3b3Jk")] | ||
"auth_str, result", | ||
[("Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZGVudGl0eSI6IkJvYiJ9" | ||
".YZqkPHdrxkkFNg7GNL8g-hRpiD9LPyospO47Mh3iEDk", "Bob")]) | ||
def test_auth_docode(app_fixture, auth_str, result): | ||
assert authorization_decoder(app_fixture.config, auth_str) == "Bob" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"auth_str", [("Unsupported Ym9iOnBhc3N3b3Jk")] | ||
) | ||
def test_auth_docode_exceptions(auth_str): | ||
def test_auth_docode_exceptions(app_fixture, auth_str): | ||
with pytest.raises(UnSupportedAuthType): | ||
authorization_decoder(auth_str) | ||
authorization_decoder(app_fixture.config, auth_str) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"auth_str", | ||
[("Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2MTUxMDg0OTIuNTY5MjksImlkZW50aXR5IjoiQm9iIn0." | ||
"CAeMpG-gKbucHU7-KMiqM7H_gTkHSRvXSjNtlvh5DlE")] | ||
) | ||
def test_auth_docode_exceptions(app_fixture, auth_str): | ||
with pytest.raises(jwt.ExpiredSignatureError): | ||
authorization_decoder(app_fixture.config, auth_str) |