def test_test_iam_permissions(self): # Setup Expected Response expected_response = {} expected_response = iam_policy_pb2.TestIamPermissionsResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = publisher_client.PublisherClient(channel=channel) # Setup Request resource = client.topic_path('[PROJECT]', '[TOPIC]') permissions = [] response = client.test_iam_permissions(resource, permissions) assert expected_response == response assert len(channel.requests) == 1 expected_request = iam_policy_pb2.TestIamPermissionsRequest( resource=resource, permissions=permissions) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_test_iam_permissions(self): # Setup Expected Response expected_response = {} expected_response = iam_policy_pb2.TestIamPermissionsResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = securitycenter_v1beta1.SecurityCenterClient(channel=channel) # Setup Request resource = client.source_path('[ORGANIZATION]', '[SOURCE]') permissions = [] response = client.test_iam_permissions(resource, permissions) assert expected_response == response assert len(channel.requests) == 1 expected_request = iam_policy_pb2.TestIamPermissionsRequest( resource=resource, permissions=permissions) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_test_iam_permissions(self): # Setup Expected Response expected_response = {} expected_response = iam_policy_pb2.TestIamPermissionsResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = tasks_v2beta2.CloudTasksClient(channel=channel) # Setup Request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') permissions = [] response = client.test_iam_permissions(resource, permissions) assert expected_response == response assert len(channel.requests) == 1 expected_request = iam_policy_pb2.TestIamPermissionsRequest( resource=resource, permissions=permissions) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_test_iam_permissions(self): # Setup Expected Response expected_response = {} expected_response = iam_policy_pb2.TestIamPermissionsResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = bigtable_admin_v2.BigtableInstanceAdminClient(channel=channel) # Setup Request resource = client.instance_path('[PROJECT]', '[INSTANCE]') permissions = [] response = client.test_iam_permissions(resource, permissions) assert expected_response == response assert len(channel.requests) == 1 expected_request = iam_policy_pb2.TestIamPermissionsRequest( resource=resource, permissions=permissions) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_test_iam_permissions(self): # Setup Expected Response expected_response = {} expected_response = iam_policy_pb2.TestIamPermissionsResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = kms_v1.KeyManagementServiceClient(channel=channel) # Setup Request resource = client.key_ring_path('[PROJECT]', '[LOCATION]', '[KEY_RING]') permissions = [] response = client.test_iam_permissions(resource, permissions) assert expected_response == response assert len(channel.requests) == 1 expected_request = iam_policy_pb2.TestIamPermissionsRequest( resource=resource, permissions=permissions) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_test_iam_permissions(self, mock_create_stub): # Mock gRPC layer grpc_stub = mock.Mock(spec=iam_policy_pb2.IAMPolicyStub) mock_create_stub.return_value = grpc_stub client = publisher_client.PublisherClient() # Mock request resource = client.topic_path('[PROJECT]', '[TOPIC]') permissions = [] # Mock response expected_response = iam_policy_pb2.TestIamPermissionsResponse() grpc_stub.TestIamPermissions.return_value = expected_response response = client.test_iam_permissions(resource, permissions) self.assertEqual(expected_response, response) grpc_stub.TestIamPermissions.assert_called_once() request = grpc_stub.TestIamPermissions.call_args[0] self.assertEqual(resource, request.resource) self.assertEqual(permissions, request.permissions)
def test_test_iam_permissions(self): # Setup Expected Response expected_response = {} expected_response = iam_policy_pb2.TestIamPermissionsResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = iot_v1.DeviceManagerClient(channel=channel) # Setup Request resource = client.registry_path('[PROJECT]', '[LOCATION]', '[REGISTRY]') permissions = [] response = client.test_iam_permissions(resource, permissions) assert expected_response == response assert len(channel.requests) == 1 expected_request = iam_policy_pb2.TestIamPermissionsRequest( resource=resource, permissions=permissions) actual_request = channel.requests[0][1] assert expected_request == actual_request
def TestBucketIamPermissions(self, request, context): return iam_policy_pb2.TestIamPermissionsResponse( permissions=request.iam_request.permissions)