def test_ring_policy(self): # add member snippets.add_member_to_key_ring_policy(self.project_id, self.location, self.keyring_id, self.member, self.role) policy = snippets.get_key_ring_policy(self.project_id, self.location, self.keyring_id) found = False for b in list(policy.bindings): if b.role == self.role and self.member in b.members: found = True assert found # remove member snippets.remove_member_from_key_ring_policy(self.project_id, self.location, self.keyring_id, self.member, self.role) policy = snippets.get_key_ring_policy(self.project_id, self.location, self.keyring_id) found = False for b in list(policy.bindings): if b.role == self.role and self.member in b.members: found = True assert not found
def test_get_key_ring_policy(capsys): snippets.get_key_ring_policy(PROJECT, LOCATION, KEY_RING) out, _ = capsys.readouterr() expected_roles_exist = ( 'Printing IAM policy for resource projects/{}/locations/{}/keyRings/{}' ':'.format(PROJECT, LOCATION, KEY_RING)) expected_no_roles = ( 'No roles found for resource projects/{}/locations/{}/keyRings/{}.' .format(PROJECT, LOCATION, KEY_RING)) assert (expected_roles_exist in out) or (expected_no_roles in out)
def test_get_key_ring_policy(capsys): snippets.get_key_ring_policy(PROJECT, LOCATION, KEY_RING) out, _ = capsys.readouterr() expected_roles_exist = ( 'Printing IAM policy for resource projects/{}/locations/{}/keyRings/{}' ':'.format(PROJECT, LOCATION, KEY_RING)) expected_no_roles = ( 'No roles found for resource projects/{}/locations/{}/keyRings/{}.'. format(PROJECT, LOCATION, KEY_RING)) assert (expected_roles_exist in out) or (expected_no_roles in out)
def test_get_ring_policy(self): policy = snippets.get_key_ring_policy(self.project_id, self.location, self.keyring_id) assert type(policy) is Policy