def test_load_users(self): authorisor = BasicUserGroupAuthorisationService(BrainSecurityAuthorisationConfiguration()) store = UserGroupsStore() yaml_data = yaml.load(""" users: console: roles: user groups: sysadmin, local viewer: roles: user groups: local """, Loader=yaml.FullLoader) store._load_users(yaml_data,authorisor) self.assertTrue("console" in authorisor.users.keys()) self.assertIsInstance(authorisor.users['console'], User) self.assertTrue("user" in authorisor.users['console'].roles) self.assertTrue("sysadmin" in authorisor.users['console'].groups) self.assertTrue("local" in authorisor.users['console'].groups) self.assertTrue("viewer" in authorisor.users.keys()) self.assertIsInstance(authorisor.users['viewer'], User) self.assertTrue("user" in authorisor.users['viewer'].roles) self.assertTrue("local" in authorisor.users['viewer'].groups)
def test_load_users_no_users(self): authorisor = BasicUserGroupAuthorisationService(BrainSecurityAuthorisationConfiguration()) store = UserGroupsStore() yaml_data = yaml.load(""" others: console: roles: user groups: sysadmin, local viewer: roles: user groups: local """, Loader=yaml.FullLoader) store._load_users(yaml_data,authorisor) self.assertFalse("console" in authorisor.users.keys()) self.assertFalse("viewer" in authorisor.users.keys())