-
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
66 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,44 @@ | ||
import pytest | ||
|
||
from layman import upgrade, app, settings | ||
from layman.common import geoserver as gs_common | ||
from layman.common.prime_db_schema import util as db_util | ||
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) | ||
|
||
version = (1, 9, 0, 0) | ||
sql_insert = f'''update {DB_SCHEMA}.data_version set | ||
major_version = %s, | ||
minor_version = %s, | ||
patch_version = %s, | ||
migration = %s;''' | ||
with app.app_context(): | ||
db_util.run_statement(sql_insert, version) | ||
upgrade.upgrade() | ||
|
||
assert_roles(workspace, layer, expected_roles2) |