-
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
5795feb
commit 8388246
Showing
13 changed files
with
778 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<style></style> |
Empty file.
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,43 @@ | ||
import responses | ||
|
||
from geoservercloud.geoservercloud import GeoServerCloud | ||
|
||
|
||
def test_create_resource(geoserver: GeoServerCloud) -> None: | ||
path = "/new/resource" | ||
resource_path = "/new/resource/resource.json" | ||
payload = {"something": "new"} | ||
with responses.RequestsMock() as rsps: | ||
rsps.get( | ||
url=f"{geoserver.url}{resource_path}", | ||
status=404, | ||
) | ||
rsps.post( | ||
url=f"{geoserver.url}{path}", | ||
status=201, | ||
match=[responses.matchers.json_params_matcher(payload)], | ||
) | ||
|
||
response = geoserver.create_or_update_resource(path, resource_path, payload) | ||
|
||
assert response.status_code == 201 | ||
|
||
|
||
def test_update_resource(geoserver: GeoServerCloud) -> None: | ||
path = "/some/resource" | ||
resource_path = "/some/resource/resource.json" | ||
payload = {"something": "something"} | ||
with responses.RequestsMock() as rsps: | ||
rsps.get( | ||
url=f"{geoserver.url}{resource_path}", | ||
status=200, | ||
) | ||
rsps.put( | ||
url=f"{geoserver.url}{resource_path}", | ||
status=200, | ||
match=[responses.matchers.json_params_matcher(payload)], | ||
) | ||
|
||
response = geoserver.create_or_update_resource(path, resource_path, payload) | ||
|
||
assert response.status_code == 200 |
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,93 @@ | ||
import responses | ||
import responses.matchers | ||
|
||
from geoservercloud.geoservercloud import GeoServerCloud | ||
|
||
|
||
def test_create_acl_admin_rule(geoserver: GeoServerCloud) -> None: | ||
with responses.RequestsMock() as rsps: | ||
rsps.post( | ||
url=f"{geoserver.url}/acl/api/adminrules", | ||
status=201, | ||
match=[ | ||
responses.matchers.json_params_matcher( | ||
{ | ||
"priority": 1, | ||
"access": "ADMIN", | ||
"role": "TEST_ROLE", | ||
"user": "TEST_USER", | ||
"workspace": "TEST_WORKSPACE", | ||
} | ||
) | ||
], | ||
) | ||
|
||
response = geoserver.create_acl_admin_rule( | ||
priority=1, | ||
access="ADMIN", | ||
role="TEST_ROLE", | ||
user="TEST_USER", | ||
workspace="TEST_WORKSPACE", | ||
) | ||
assert response.status_code == 201 | ||
|
||
|
||
def test_create_acl_rule(geoserver: GeoServerCloud) -> None: | ||
with responses.RequestsMock() as rsps: | ||
rsps.post( | ||
url=f"{geoserver.url}/acl/api/rules", | ||
status=201, | ||
match=[ | ||
responses.matchers.json_params_matcher( | ||
{ | ||
"priority": 1, | ||
"access": "ALLOW", | ||
"role": "TEST_ROLE", | ||
"workspace": "TEST_WORKSPACE", | ||
"service": "WMS", | ||
} | ||
) | ||
], | ||
) | ||
|
||
response = geoserver.create_acl_rule( | ||
priority=1, | ||
access="ALLOW", | ||
role="TEST_ROLE", | ||
workspace="TEST_WORKSPACE", | ||
service="WMS", | ||
) | ||
assert response.status_code == 201 | ||
|
||
|
||
def test_delete_acl_admin_rule(geoserver: GeoServerCloud) -> None: | ||
with responses.RequestsMock() as rsps: | ||
rsps.delete( | ||
url=f"{geoserver.url}/acl/api/adminrules/id/1", | ||
status=200, | ||
) | ||
|
||
response = geoserver.delete_acl_admin_rule(1) | ||
assert response.status_code == 200 | ||
|
||
|
||
def test_delete_all_acl_admin_rules(geoserver: GeoServerCloud) -> None: | ||
with responses.RequestsMock() as rsps: | ||
rsps.delete( | ||
url=f"{geoserver.url}/acl/api/adminrules", | ||
status=200, | ||
) | ||
|
||
response = geoserver.delete_all_acl_admin_rules() | ||
assert response.status_code == 200 | ||
|
||
|
||
def test_delete_all_acl_rules(geoserver: GeoServerCloud) -> None: | ||
with responses.RequestsMock() as rsps: | ||
rsps.delete( | ||
url=f"{geoserver.url}/acl/api/rules", | ||
status=200, | ||
) | ||
|
||
response = geoserver.delete_all_acl_rules() | ||
assert response.status_code == 200 |
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
Oops, something went wrong.