def test_bcros_user_update_by_token(session): # pylint: disable=unused-argument """Assert that a user can be created by token.""" user_model = factory_user_model(TestUserInfo.user_bcros) user = UserService(user_model) dictionary = user.as_dict() assert dictionary.get('keycloak_guid', None) is None user = UserService.save_from_jwt_token(TestJwtClaims.anonymous_bcros_role) assert user is not None dictionary = user.as_dict() assert dictionary['username'] == TestJwtClaims.anonymous_bcros_role['preferred_username'] assert dictionary['keycloak_guid'] == TestJwtClaims.anonymous_bcros_role['sub']
def test_as_dict(session): # pylint: disable=unused-argument """Assert that a user is rendered correctly as a dictionary.""" user_model = factory_user_model() user = UserService(user_model) dictionary = user.as_dict() assert dictionary['username'] == TestUserInfo.user1['username']
def test_user_find_by_username(session): # pylint: disable=unused-argument """Assert that a user can be found by username.""" user_model = factory_user_model() user = UserService(user_model) user = UserService.find_by_username(None) assert user is None user = UserService.find_by_username(TestUserInfo.user1['username']) assert user is not None dictionary = user.as_dict() assert dictionary['username'] == TestUserInfo.user1['username']
def test_as_dict(session): # pylint: disable=unused-argument """Assert that a user is rendered correctly as a dictionary.""" user_model = factory_user_model( username='******', roles='{edit,uma_authorization,basic}', keycloak_guid='1b20db59-19a0-4727-affe-c6f64309fd04') user = UserService(user_model) dictionary = user.as_dict() assert dictionary['username'] == 'testuser' assert dictionary['roles'] == '{edit,uma_authorization,basic}' assert dictionary[ 'keycloak_guid'] == '1b20db59-19a0-4727-affe-c6f64309fd04'
def test_user_find_by_username(session): # pylint: disable=unused-argument """Assert that a user can be found by username.""" user_model = factory_user_model( username='******', roles='{edit,uma_authorization,basic}', keycloak_guid='1b20db59-19a0-4727-affe-c6f64309fd04') user = UserService(user_model) user = UserService.find_by_username('testuser') assert user is not None dictionary = user.as_dict() assert dictionary['username'] == 'testuser'