-
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.
- Loading branch information
1 parent
91b2faa
commit 8148c98
Showing
2 changed files
with
25 additions
and
21 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
microservices/gatewayApi/tests/clients/test_uma_resourceset.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,25 @@ | ||
from clients.uma.resourceset import map_res_name_to_id | ||
|
||
def test_map_res_name_to_id(mocker, app): | ||
# Mock the Flask app 'config' and 'logger' | ||
class mock_patch: | ||
config = { | ||
"resourceAuthServer": { | ||
"serverUrl": "http://keycloak", | ||
"realm": "master" | ||
} | ||
} | ||
logger = app.logger | ||
mocker.patch('clients.uma.resourceset.app', mock_patch) | ||
|
||
# Mock the response from Keycloak to get a particular resourceset | ||
class mock_resourceset: | ||
status_code = 200 | ||
def json(): | ||
return [ | ||
"ecbae046-e0bc-4e96-a3f5-22efb50fef34" | ||
] | ||
mocker.patch("clients.uma.resourceset.requests.get", return_value=mock_resourceset) | ||
|
||
id = map_res_name_to_id(None, "NS_RESOURCE") | ||
assert id == "ecbae046-e0bc-4e96-a3f5-22efb50fef34" |
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