spiff-arena/tests/spiffworkflow_backend/unit/test_permission_target.py
burnettk 4a48d9cccd Squashed 'spiffworkflow-backend/' changes from f9c2fa21e..5225a8b4c
5225a8b4c pyl
259f74a1e Merge branch 'main' into bug/refresh-token
d452208ef Merge pull request #135 from sartography/feature/permissions3
8e1075406 Merge branch 'main' into bug/refresh-token
2b01d2fe7 fixed authentication_callback and getting the user w/ burnettk
476e36c7d mypy changes
6403e62c0 Fix migration after merging main
594a32b67 merged in main and resolved conflicts w/ burnettk
b285ba1a1 added updated columns to secrets and updated flask-bpmn
7c53fc9fa Merge remote-tracking branch 'origin/main' into feature/permissions3
201a6918a pyl changes
a6112f7fb Merge branch 'main' into bug/refresh-token
87f65a6c6 auth_token should be dictionary, not string
f163de61c pyl
1f443bb94 PublicAuthenticationService -> AuthenticationService
6c491a3df Don't refresh token here. They just logged in. We are validating the returned token. If it is bad, raise an error.
91b8649f8 id_token -> auth_token
fc94774bb Move `store_refresh_token` to authentication_service
00d66e9c5 mypy
c4e415dbe mypy
1e75716eb Pre commit
a72b03e09 Rename method. We pass it auth_tokens, not id_tokens
9a6700a6d Too many things expect g.token. Reverting my change
74883fb23 Noe store refresh_token, and try to use it if auth_token is expired Renamed some methods to use correct token type
be0557013 Cleanup - remove unused code
cf01f0d51 Add refresh_token model
1c0c937af added method to delete all permissions so we can recreate them w/ burnettk
aaeaac879 Merge remote-tracking branch 'origin/main' into feature/permissions3
44856fce2 added api endpoint to check if user has permissions based on given target uris w/ burnettk
ae830054d precommit w/ burnettk
94d50efb1 created common method to check whether an api method should have auth w/ burnettk
c955335d0 precommit w/ burnettk
37caf1a69 added a finance user to keycloak and fixed up the staging permission yml w/ burnettk
93c456294 merged in main and resolved conflicts w/ burnettk
06a7c6485 remaining tests are now passing w/ burnettk
50529d04c added test to make sure api gives a 403 if a permission is not found w/ burnettk
6a9d0a68a api calls are somewhat respecting permissions now and the process api tests are passing
d07fbbeff attempting to respect permissions w/ burnettk

git-subtree-dir: spiffworkflow-backend
git-subtree-split: 5225a8b4c101133567d4f7efa33632d36c29c81d
2022-10-20 16:00:12 -04:00

43 lines
1.5 KiB
Python

"""Process Model."""
import pytest
from flask.app import Flask
from flask_bpmn.models.db import db
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from spiffworkflow_backend.models.permission_target import (
InvalidPermissionTargetUriError,
)
from spiffworkflow_backend.models.permission_target import PermissionTargetModel
class TestPermissionTarget(BaseTest):
"""TestPermissionTarget."""
def test_wildcard_must_go_at_the_end_of_uri(
self, app: Flask, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_wildcard_must_go_at_the_end_of_uri."""
permission_target = PermissionTargetModel(uri="/test_group/%")
db.session.add(permission_target)
db.session.commit()
permission_target = PermissionTargetModel(uri="/test_group")
db.session.add(permission_target)
db.session.commit()
with pytest.raises(InvalidPermissionTargetUriError) as exception:
PermissionTargetModel(uri="/test_group/%/model")
assert (
str(exception.value) == "Wildcard must appear at end: /test_group/%/model"
)
def test_can_change_asterisk_to_percent_on_creation(
self, app: Flask, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_can_change_asterisk_to_percent_on_creation."""
permission_target = PermissionTargetModel(uri="/test_group/*")
db.session.add(permission_target)
db.session.commit()
assert isinstance(permission_target.id, int)
assert permission_target.uri == "/test_group/%"