-
Notifications
You must be signed in to change notification settings - Fork 0
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
211af87
commit 283be30
Showing
3 changed files
with
177 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
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,74 @@ | ||
import responses | ||
import responses.matchers | ||
|
||
from geoservercloud.geoservercloud import GeoServerCloud | ||
|
||
TEST_USER = "test_user" | ||
|
||
|
||
def test_create_user(geoserver: GeoServerCloud) -> None: | ||
with responses.RequestsMock() as rsps: | ||
rsps.post( | ||
url=f"{geoserver.url}/rest/security/usergroup/users", | ||
status=201, | ||
match=[ | ||
responses.matchers.json_params_matcher( | ||
{ | ||
"user": { | ||
"userName": TEST_USER, | ||
"password": "test_password", | ||
"enabled": True, | ||
} | ||
} | ||
) | ||
], | ||
) | ||
response = geoserver.create_user(TEST_USER, "test_password") | ||
assert response.status_code == 201 | ||
|
||
|
||
def test_update_user_password(geoserver: GeoServerCloud) -> None: | ||
with responses.RequestsMock() as rsps: | ||
rsps.post( | ||
url=f"{geoserver.url}/rest/security/usergroup/user/{TEST_USER}", | ||
status=200, | ||
match=[ | ||
responses.matchers.json_params_matcher( | ||
{ | ||
"user": { | ||
"password": "new_password", | ||
} | ||
} | ||
) | ||
], | ||
) | ||
response = geoserver.update_user(TEST_USER, password="new_password") | ||
assert response.status_code == 200 | ||
|
||
|
||
def test_update_user_enabled(geoserver: GeoServerCloud) -> None: | ||
with responses.RequestsMock() as rsps: | ||
rsps.post( | ||
url=f"{geoserver.url}/rest/security/usergroup/user/{TEST_USER}", | ||
status=200, | ||
match=[ | ||
responses.matchers.json_params_matcher( | ||
{ | ||
"user": { | ||
"enabled": False, | ||
} | ||
} | ||
) | ||
], | ||
) | ||
response = geoserver.update_user(TEST_USER, enabled=False) | ||
assert response.status_code == 200 | ||
|
||
|
||
def test_delete_user(geoserver: GeoServerCloud) -> None: | ||
with responses.RequestsMock() as rsps: | ||
rsps.delete( | ||
url=f"{geoserver.url}/rest/security/usergroup/user/{TEST_USER}", status=200 | ||
) | ||
response = geoserver.delete_user(TEST_USER) | ||
assert response.status_code == 200 |