use percents instead of asterisks to better support db syntax w/ burnettk

This commit is contained in:
jasquat 2022-10-11 11:51:12 -04:00
parent 0c116ae804
commit 22ba89ae4f
3 changed files with 4 additions and 5 deletions

View File

@ -19,7 +19,7 @@ class PermissionTargetModel(SpiffworkflowBaseDBModel):
@validates("uri")
def validate_uri(self, key: str, value: str) -> str:
if re.search(r"\*.", value):
if re.search(r"%.", value):
raise InvalidPermissionTargetUri(
f"Invalid Permission Target Uri: {value}"
)

View File

@ -65,7 +65,6 @@ class AuthorizationService:
principals.append(group.principal)
return cls.has_permission(principals, permission, target_uri)
# return False
# def refresh_token(self, token: str) -> str:
# """Refresh_token."""

View File

@ -12,7 +12,7 @@ class TestPermissionTarget(BaseTest):
def test_asterisk_must_go_at_the_end_of_uri(
self, app: Flask, with_db_and_bpmn_file_cleanup: None
) -> None:
permission_target = PermissionTargetModel(uri="/test_group/*")
permission_target = PermissionTargetModel(uri="/test_group/%")
db.session.add(permission_target)
db.session.commit()
@ -21,7 +21,7 @@ class TestPermissionTarget(BaseTest):
db.session.commit()
with pytest.raises(InvalidPermissionTargetUri) as exception:
PermissionTargetModel(uri="/test_group/*/model")
PermissionTargetModel(uri="/test_group/%/model")
assert (
str(exception.value) == "Invalid Permission Target Uri: /test_group/*/model"
str(exception.value) == "Invalid Permission Target Uri: /test_group/%/model"
)