-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#150: Rewrite session ID from header tests
- Loading branch information
1 parent
89d58d6
commit e8f1139
Showing
5 changed files
with
32 additions
and
24 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytest | ||
|
||
from datagateway_api.common.exceptions import ( | ||
AuthenticationError, | ||
MissingCredentialsError, | ||
) | ||
from datagateway_api.common.helpers import get_session_id_from_auth_header | ||
|
||
|
||
class TestGetSessionIDFromAuthHeader: | ||
def test_invalid_no_credentials_in_header(self, flask_test_app_db): | ||
with flask_test_app_db: | ||
flask_test_app_db.get("/") | ||
with pytest.raises(MissingCredentialsError): | ||
get_session_id_from_auth_header() | ||
|
||
def test_invalid_header(self, flask_test_app_db, invalid_credentials_header): | ||
with flask_test_app_db: | ||
flask_test_app_db.get("/", headers=invalid_credentials_header) | ||
with pytest.raises(AuthenticationError): | ||
get_session_id_from_auth_header() | ||
|
||
def test_valid_header(self, flask_test_app_db, valid_db_credentials_header): | ||
with flask_test_app_db: | ||
flask_test_app_db.get("/", headers=valid_db_credentials_header) | ||
session_id = valid_db_credentials_header["Authorization"].split()[1] | ||
|
||
assert session_id == get_session_id_from_auth_header() |