def test_get_authorized_users_some_not_authorized(self): auths = {self.uid1: ([self.user], []), self.uid2: ([self.user2], [self.role]), self.uid3: ([self.user2], [])} self.create_messages(auths) self.assertTupleEqual(get_authorized_execution_ids(self.uids, self.user.id, [self.role.id]), (set(), {self.uid1, self.uid2}))
def test_get_authorized_uids_all_require_authorizations(self): for uid in self.uids: walkoff.messaging.workflow_authorization_cache.add_authorized_users( uid, [42], [3, 5]) self.assertTupleEqual( get_authorized_execution_ids(self.uids, 42, [3, 4]), (set(), self.uids))
def test_get_authorized_users_mixed(self): walkoff.messaging.workflow_authorization_cache.add_authorized_users( 'uid1', [42], [3, 5]) walkoff.messaging.workflow_authorization_cache.add_authorized_users( 'uid3', [84], []) self.assertTupleEqual( get_authorized_execution_ids(self.uids, 42, [3, 4]), ({self.uid2}, {self.uid1}))
def test_get_authorized_uids_all_require_authorizations(self): auths = {self.uid1: ([self.user], [self.role]), self.uid2: ([self.user], [self.role]), self.uid3: ([self.user], [self.role])} self.create_messages(auths) self.assertTupleEqual(get_authorized_execution_ids(self.uids, self.user.id, [self.role.id]), (set(), self.uids))
def test_get_authorized_uids_no_authorizations_required(self): self.assertTupleEqual(get_authorized_execution_ids(self.uids, 42, [3, 4]), (self.uids, set()))
def test_get_authorized_uids_no_uids_supplied(self): self.assertTupleEqual(get_authorized_execution_ids(set(), 42, [3, 4]), (set(), set()))