-
Notifications
You must be signed in to change notification settings - Fork 15
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 #101 from JaurbanRH/anonymous
Add test for anonymous identity
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 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
34 changes: 34 additions & 0 deletions
34
testsuite/tests/kuadrant/authorino/identity/test_anonymous_identity.py
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,34 @@ | ||
"""Test for anonymous identity""" | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def authorization(authorization, rhsso): | ||
"""Add RHSSO identity""" | ||
authorization.add_oidc_identity("rhsso", rhsso.well_known["issuer"]) | ||
return authorization | ||
|
||
|
||
def test_anonymous_identity(client, auth, authorization): | ||
""" | ||
Setup: | ||
- Create AuthConfig with RHSSO identity | ||
Test: | ||
- Send request with authentication | ||
- Assert that response status code is 200 | ||
- Send request without authentication | ||
- Assert that response status code is 401 (Unauthorized) | ||
- Add anonymous identity | ||
- Send request without authentication | ||
- Assert that response status code is 200 | ||
""" | ||
response = client.get("/get", auth=auth) | ||
assert response.status_code == 200 | ||
|
||
response = client.get("/get") | ||
assert response.status_code == 401 | ||
|
||
authorization.add_anonymous_identity("anonymous") | ||
|
||
response = client.get("/get") | ||
assert response.status_code == 200 |