fixed tests related to new permissions w/ burnettk
This commit is contained in:
parent
3124c5451a
commit
696bfe224c
|
@ -7,5 +7,20 @@ function error_handler() {
|
|||
trap 'error_handler ${LINENO} $?' ERR
|
||||
set -o errtrace -o errexit -o nounset -o pipefail
|
||||
|
||||
set -x
|
||||
mysql -uroot spiffworkflow_backend_development -e 'select pa.id, g.identifier group_identifier, pt.uri, permission from permission_assignment pa join principal p on p.id = pa.principal_id join `group` g on g.id = p.group_id join permission_target pt on pt.id = pa.permission_target_id;'
|
||||
database=spiffworkflow_backend_local_development
|
||||
if [[ "${1:-}" == "test" ]]; then
|
||||
database=spiffworkflow_backend_unit_testing
|
||||
fi
|
||||
|
||||
# shellcheck disable=2016
|
||||
mysql -uroot "$database" -e '
|
||||
select u.username user, g.identifier group
|
||||
FROM `user` u
|
||||
JOIN `user_group_assignment` uga on uga.user_id = u.id
|
||||
JOIN `group` g on g.id = uga.group_id;
|
||||
|
||||
select pa.id, g.identifier group_identifier, pt.uri, permission from permission_assignment pa
|
||||
join principal p on p.id = pa.principal_id
|
||||
join `group` g on g.id = p.group_id
|
||||
join permission_target pt on pt.id = pa.permission_target_id;
|
||||
'
|
||||
|
|
|
@ -9,6 +9,7 @@ from tests.spiffworkflow_backend.helpers.base_test import BaseTest
|
|||
from spiffworkflow_backend.models.bpmn_process import BpmnProcessModel
|
||||
from spiffworkflow_backend.models.db import db
|
||||
from spiffworkflow_backend.models.user import UserModel
|
||||
from spiffworkflow_backend.services.authorization_service import AuthorizationService
|
||||
from spiffworkflow_backend.services.process_model_service import ProcessModelService
|
||||
|
||||
|
||||
|
@ -55,4 +56,6 @@ def with_db_and_bpmn_file_cleanup() -> None:
|
|||
@pytest.fixture()
|
||||
def with_super_admin_user() -> UserModel:
|
||||
"""With_super_admin_user."""
|
||||
return BaseTest.create_user_with_permission("super_admin")
|
||||
user = BaseTest.find_or_create_user(username="testadmin1")
|
||||
AuthorizationService.import_permissions_from_yaml_file(user)
|
||||
return user
|
||||
|
|
|
@ -425,7 +425,7 @@ paths:
|
|||
schema:
|
||||
$ref: "#/components/schemas/ProcessModel"
|
||||
|
||||
/process-models-natural-language/{modified_process_group_id}:
|
||||
/process-model-natural-language/{modified_process_group_id}:
|
||||
parameters:
|
||||
- name: modified_process_group_id
|
||||
in: path
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
|
||||
<bpmn:process id="test_save_process_instance_metadata" isExecutable="true">
|
||||
<bpmn:startEvent id="Event_0r6oru6">
|
||||
<bpmn:outgoing>Flow_1j4jzft</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:sequenceFlow id="Flow_1j4jzft" sourceRef="Event_0r6oru6" targetRef="save_key1" />
|
||||
<bpmn:endEvent id="Event_1s123jg">
|
||||
<bpmn:incoming>Flow_01xr2ac</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:scriptTask id="save_key1">
|
||||
<bpmn:incoming>Flow_1j4jzft</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_10xyk22</bpmn:outgoing>
|
||||
<bpmn:script>key1 = "value1"</bpmn:script>
|
||||
</bpmn:scriptTask>
|
||||
<bpmn:sequenceFlow id="Flow_10xyk22" sourceRef="save_key1" targetRef="save_key2" />
|
||||
<bpmn:scriptTask id="save_key2">
|
||||
<bpmn:incoming>Flow_10xyk22</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_01xr2ac</bpmn:outgoing>
|
||||
<bpmn:script>key2 = "value2"; key3 = "value3"</bpmn:script>
|
||||
</bpmn:scriptTask>
|
||||
<bpmn:sequenceFlow id="Flow_01xr2ac" sourceRef="save_key2" targetRef="Event_1s123jg" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="test_save_process_instance_metadata">
|
||||
<bpmndi:BPMNShape id="Event_0r6oru6_di" bpmnElement="Event_0r6oru6">
|
||||
<dc:Bounds x="162" y="162" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_0zfzev2_di" bpmnElement="save_key1">
|
||||
<dc:Bounds x="250" y="140" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_0d1q8x4_di" bpmnElement="save_key2">
|
||||
<dc:Bounds x="410" y="140" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_1s123jg_di" bpmnElement="Event_1s123jg">
|
||||
<dc:Bounds x="582" y="162" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="Flow_1j4jzft_di" bpmnElement="Flow_1j4jzft">
|
||||
<di:waypoint x="198" y="180" />
|
||||
<di:waypoint x="250" y="180" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_10xyk22_di" bpmnElement="Flow_10xyk22">
|
||||
<di:waypoint x="350" y="180" />
|
||||
<di:waypoint x="410" y="180" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_01xr2ac_di" bpmnElement="Flow_01xr2ac">
|
||||
<di:waypoint x="510" y="180" />
|
||||
<di:waypoint x="582" y="180" />
|
||||
</bpmndi:BPMNEdge>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -59,7 +59,6 @@ class BaseTest:
|
|||
|
||||
@staticmethod
|
||||
def logged_in_headers(user: UserModel, _redirect_url: str = "http://some/frontend/url") -> Dict[str, str]:
|
||||
"""Logged_in_headers."""
|
||||
return dict(Authorization="Bearer " + user.encode_auth_token())
|
||||
|
||||
def create_group_and_model_with_bpmn(
|
||||
|
@ -317,11 +316,8 @@ class BaseTest:
|
|||
target_uri: str = PermissionTargetModel.URI_ALL,
|
||||
permission_names: Optional[list[str]] = None,
|
||||
) -> UserModel:
|
||||
# user = BaseTest.find_or_create_user(username=username)
|
||||
# return cls.add_permissions_to_user(user, target_uri=target_uri, permission_names=permission_names)
|
||||
user = BaseTest.find_or_create_user(username="testadmin1")
|
||||
AuthorizationService.import_permissions_from_yaml_file(user)
|
||||
return user
|
||||
user = BaseTest.find_or_create_user(username=username)
|
||||
return cls.add_permissions_to_user(user, target_uri=target_uri, permission_names=permission_names)
|
||||
|
||||
@classmethod
|
||||
def add_permissions_to_user(
|
||||
|
|
|
@ -25,14 +25,12 @@ class TestLoggingService(BaseTest):
|
|||
with_db_and_bpmn_file_cleanup: None,
|
||||
with_super_admin_user: UserModel,
|
||||
) -> None:
|
||||
self.create_process_group_with_api(client, with_super_admin_user, "test_group", "test_group")
|
||||
initiator_user = self.find_or_create_user("initiator_user")
|
||||
assert initiator_user.principal is not None
|
||||
AuthorizationService.import_permissions_from_yaml_file()
|
||||
|
||||
process_model = load_test_spec(
|
||||
process_model_id="misc/category_number_one/simple_form",
|
||||
# bpmn_file_name="simp.bpmn",
|
||||
process_model_source_directory="simple_form",
|
||||
)
|
||||
process_instance = self.create_process_instance_from_process_model(
|
||||
|
@ -85,14 +83,12 @@ class TestLoggingService(BaseTest):
|
|||
with_db_and_bpmn_file_cleanup: None,
|
||||
with_super_admin_user: UserModel,
|
||||
) -> None:
|
||||
self.create_process_group_with_api(client, with_super_admin_user, "test_group", "test_group")
|
||||
initiator_user = self.find_or_create_user("initiator_user")
|
||||
assert initiator_user.principal is not None
|
||||
AuthorizationService.import_permissions_from_yaml_file()
|
||||
|
||||
process_model = load_test_spec(
|
||||
process_model_id="misc/category_number_one/simple_form",
|
||||
# bpmn_file_name="simp.bpmn",
|
||||
process_model_source_directory="simple_form",
|
||||
)
|
||||
process_instance = self.create_process_instance_from_process_model(
|
||||
|
|
|
@ -182,7 +182,7 @@ class TestProcessApi(BaseTest):
|
|||
user=with_super_admin_user,
|
||||
)
|
||||
response = client.post(
|
||||
f"/v1.0/process-models-natural-language/{process_group_id}",
|
||||
f"/v1.0/process-model-natural-language/{process_group_id}",
|
||||
content_type="application/json",
|
||||
data=json.dumps(body),
|
||||
headers=self.logged_in_headers(with_super_admin_user),
|
||||
|
@ -238,9 +238,6 @@ class TestProcessApi(BaseTest):
|
|||
process_model_identifier = f"{process_group_id}/{process_model_id}"
|
||||
initial_primary_process_id = "sample"
|
||||
terminal_primary_process_id = "new_process_id"
|
||||
self.create_process_group_with_api(
|
||||
client=client, user=with_super_admin_user, process_group_id=process_group_id
|
||||
)
|
||||
|
||||
bpmn_file_name = f"{process_model_id}.bpmn"
|
||||
bpmn_file_source_directory = process_model_id
|
||||
|
@ -282,14 +279,11 @@ class TestProcessApi(BaseTest):
|
|||
) -> None:
|
||||
"""Test_process_model_delete."""
|
||||
process_group_id = "test_process_group"
|
||||
process_group_description = "Test Process Group"
|
||||
process_model_id = "sample"
|
||||
process_model_identifier = f"{process_group_id}/{process_model_id}"
|
||||
self.create_process_group_with_api(client, with_super_admin_user, process_group_id, process_group_description)
|
||||
self.create_process_model_with_api(
|
||||
client,
|
||||
process_model = load_test_spec(
|
||||
process_model_id=process_model_identifier,
|
||||
user=with_super_admin_user,
|
||||
process_model_source_directory=process_model_id,
|
||||
)
|
||||
|
||||
# assert we have a model
|
||||
|
@ -3051,6 +3045,17 @@ class TestProcessApi(BaseTest):
|
|||
bpmn_file_name="save_process_instance_metadata.bpmn",
|
||||
process_model_source_directory="save_process_instance_metadata",
|
||||
)
|
||||
ProcessModelService.update_process_model(
|
||||
process_model,
|
||||
{
|
||||
"metadata_extraction_paths": [
|
||||
{"key": "key1", "path": "key1"},
|
||||
{"key": "key2", "path": "key2"},
|
||||
{"key": "key3", "path": "key3"},
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
process_instance = self.create_process_instance_from_process_model(
|
||||
process_model=process_model, user=with_super_admin_user
|
||||
)
|
||||
|
@ -3188,6 +3193,16 @@ class TestProcessApi(BaseTest):
|
|||
bpmn_file_name="save_process_instance_metadata.bpmn",
|
||||
process_model_source_directory="save_process_instance_metadata",
|
||||
)
|
||||
ProcessModelService.update_process_model(
|
||||
process_model,
|
||||
{
|
||||
"metadata_extraction_paths": [
|
||||
{"key": "key1", "path": "key1"},
|
||||
{"key": "key2", "path": "key2"},
|
||||
{"key": "key3", "path": "key3"},
|
||||
]
|
||||
},
|
||||
)
|
||||
process_instance = self.create_process_instance_from_process_model(
|
||||
process_model=process_model, user=with_super_admin_user
|
||||
)
|
||||
|
@ -3262,7 +3277,6 @@ class TestProcessApi(BaseTest):
|
|||
with_super_admin_user: UserModel,
|
||||
) -> None:
|
||||
"""Test_process_instance_list_can_order_by_metadata."""
|
||||
self.create_process_group_with_api(client, with_super_admin_user, "test_group", "test_group")
|
||||
process_model = load_test_spec(
|
||||
"test_group/hello_world",
|
||||
process_model_source_directory="nested-task-data-structure",
|
||||
|
|
|
@ -27,7 +27,7 @@ export default function ProcessModelNewExperimental() {
|
|||
const handleFormSubmission = (event: any) => {
|
||||
event.preventDefault();
|
||||
HttpService.makeCallToBackend({
|
||||
path: `/process-models-natural-language/${params.process_group_id}`,
|
||||
path: `/process-model-natural-language/${params.process_group_id}`,
|
||||
successCallback: navigateToProcessModel,
|
||||
httpMethod: 'POST',
|
||||
postBody: { natural_language_text: processModelDescriptiveText },
|
||||
|
|
Loading…
Reference in New Issue