move towards returning dict in get_current_user

This commit is contained in:
burnettk 2023-02-06 10:30:38 -05:00
parent 19ccca408d
commit b4a3156256
2 changed files with 45 additions and 1 deletions

View File

@ -26,4 +26,4 @@ class GetCurrentUser(Script):
**kwargs: Any
) -> Any:
"""Run."""
return g.user.username
return g.user.__dict__

View File

@ -0,0 +1,44 @@
"""Test_get_localtime."""
from flask.app import Flask
from flask import g
from flask.testing import FlaskClient
from spiffworkflow_backend.models.script_attributes_context import ScriptAttributesContext
from spiffworkflow_backend.scripts.get_current_user import GetCurrentUser
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
from spiffworkflow_backend.models.db import db
from spiffworkflow_backend.models.group import GroupModel
from spiffworkflow_backend.models.user import UserModel
from spiffworkflow_backend.services.process_instance_processor import (
ProcessInstanceProcessor,
)
from spiffworkflow_backend.services.user_service import UserService
class TestGetCurrentUser(BaseTest):
def test_get_current_user(
self,
app: Flask,
client: FlaskClient,
with_db_and_bpmn_file_cleanup: None,
with_super_admin_user: UserModel,
) -> None:
"""Test_can_get_members_of_a_group."""
testuser1 = self.find_or_create_user("testuser1")
testuser1.tenant_specific_field_1 = "456"
db.session.add(testuser1)
g.user = testuser1
process_model_identifier = "test_process_model"
process_instance_id = 1
script_attributes_context = ScriptAttributesContext(
task=None,
environment_identifier="testing",
process_instance_id=process_instance_id,
process_model_identifier=process_model_identifier,
)
result = GetCurrentUser().run(
script_attributes_context,
)
assert result['username'] == "testuser1"