@@ -593,3 +593,35 @@ def test_enqueue_with_priority(dbos: DBOS, client: DBOSClient) -> None:
593593def test_client_bad_url () -> None :
594594 with pytest .raises (DBAPIError ) as exc_info :
595595 DBOSClient ("postgresql://postgres:fakepassword@localhost:5433/fake_database" )
596+
597+
598+ def test_client_auth (dbos : DBOS , client : DBOSClient ) -> None :
599+ run_client_collateral ()
600+
601+ johnDoe : Person = {"first" : "John" , "last" : "Doe" , "age" : 30 }
602+ wfid = str (uuid .uuid4 ())
603+
604+ user = "testuser"
605+ roles = ["role1" , "role2" ]
606+
607+ options : EnqueueOptions = {
608+ "queue_name" : "test_queue" ,
609+ "workflow_name" : "enqueue_test" ,
610+ "workflow_id" : wfid ,
611+ "authenticated_user" : user ,
612+ "authenticated_roles" : roles ,
613+ }
614+
615+ handle : WorkflowHandle [str ] = client .enqueue (options , 42 , "test" , johnDoe )
616+ result = handle .get_result ()
617+ assert result == '42-test-{"first": "John", "last": "Doe", "age": 30}'
618+
619+ list_results = client .list_workflows ()
620+ assert len (list_results ) == 1
621+ assert list_results [0 ].workflow_id == wfid
622+ assert list_results [0 ].status == "SUCCESS"
623+ assert list_results [0 ].output == result
624+ assert list_results [0 ].input is not None
625+ assert list_results [0 ].authenticated_user == user
626+ assert list_results [0 ].authenticated_roles == roles
627+ assert list_results [0 ].assumed_role is None
0 commit comments