-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migration 1.9.0-1: recalculate GS security rules.
- Loading branch information
Showing
3 changed files
with
59 additions
and
4 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,37 @@ | ||
import pytest | ||
|
||
from . import upgrade_v1_9 | ||
from layman import settings, app | ||
from layman.common import geoserver as gs_common | ||
from test import process_client | ||
DB_SCHEMA = settings.LAYMAN_PRIME_SCHEMA | ||
|
||
auth = settings.LAYMAN_GS_AUTH | ||
|
||
|
||
def assert_roles(workspace, | ||
layer, | ||
expected_roles): | ||
for right_type in ['read', 'write']: | ||
rule = f'{workspace}.{layer}.{right_type[0]}' | ||
roles = gs_common.get_security_roles(rule, auth) | ||
assert roles == expected_roles | ||
|
||
|
||
@pytest.mark.usefixtures('ensure_layman') | ||
def test_geoserver_everyone_rights_repair(): | ||
workspace = 'test_geoserver_everyone_rights_repair_workspace' | ||
layer = 'test_geoserver_everyone_rights_repair_layer' | ||
expected_roles1 = {'ROLE_ANONYMOUS'} | ||
expected_roles2 = {'ROLE_ANONYMOUS', 'ROLE_AUTHENTICATED'} | ||
|
||
process_client.publish_layer(workspace, layer) | ||
for right_type in ['read', 'write']: | ||
gs_common.ensure_layer_security_roles(workspace, layer, expected_roles1, right_type[0], auth) | ||
|
||
assert_roles(workspace, layer, expected_roles1) | ||
|
||
with app.app_context(): | ||
upgrade_v1_9.geoserver_everyone_rights_repair() | ||
|
||
assert_roles(workspace, layer, expected_roles2) |