Search in sources :

Example 36 with Policy

use of oasis.names.tc.xacml._3_0.core.schema.wd_17.Policy in project java-resourcemanager by googleapis.

the class ProjectsClientTest method getIamPolicyTest2.

@Test
public void getIamPolicyTest2() throws Exception {
    Policy expectedResponse = Policy.newBuilder().setVersion(351608024).addAllBindings(new ArrayList<Binding>()).setEtag(ByteString.EMPTY).build();
    mockProjects.addResponse(expectedResponse);
    String resource = "resource-341064690";
    Policy actualResponse = client.getIamPolicy(resource);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockProjects.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0));
    Assert.assertEquals(resource, actualRequest.getResource());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Policy(com.google.iam.v1.Policy) Binding(com.google.iam.v1.Binding) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) GetIamPolicyRequest(com.google.iam.v1.GetIamPolicyRequest) Test(org.junit.Test)

Example 37 with Policy

use of oasis.names.tc.xacml._3_0.core.schema.wd_17.Policy in project java-resourcemanager by googleapis.

the class TagKeysClientTest method setIamPolicyExceptionTest2.

@Test
public void setIamPolicyExceptionTest2() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockTagKeys.addException(exception);
    try {
        String resource = "resource-341064690";
        Policy policy = Policy.newBuilder().build();
        client.setIamPolicy(resource, policy);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : Policy(com.google.iam.v1.Policy) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 38 with Policy

use of oasis.names.tc.xacml._3_0.core.schema.wd_17.Policy in project java-resourcemanager by googleapis.

the class FoldersClientTest method setIamPolicyExceptionTest2.

@Test
public void setIamPolicyExceptionTest2() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockFolders.addException(exception);
    try {
        String resource = "resource-341064690";
        Policy policy = Policy.newBuilder().build();
        client.setIamPolicy(resource, policy);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : Policy(com.google.iam.v1.Policy) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 39 with Policy

use of oasis.names.tc.xacml._3_0.core.schema.wd_17.Policy in project java-resourcemanager by googleapis.

the class FoldersClientTest method getIamPolicyTest.

@Test
public void getIamPolicyTest() throws Exception {
    Policy expectedResponse = Policy.newBuilder().setVersion(351608024).addAllBindings(new ArrayList<Binding>()).setEtag(ByteString.EMPTY).build();
    mockFolders.addResponse(expectedResponse);
    ResourceName resource = FolderName.of("[FOLDER]");
    Policy actualResponse = client.getIamPolicy(resource);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockFolders.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0));
    Assert.assertEquals(resource.toString(), actualRequest.getResource());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Policy(com.google.iam.v1.Policy) Binding(com.google.iam.v1.Binding) AbstractMessage(com.google.protobuf.AbstractMessage) ResourceName(com.google.api.resourcenames.ResourceName) GetIamPolicyRequest(com.google.iam.v1.GetIamPolicyRequest) Test(org.junit.Test)

Example 40 with Policy

use of oasis.names.tc.xacml._3_0.core.schema.wd_17.Policy in project java-resourcemanager by googleapis.

the class TagValuesClientTest method setIamPolicyExceptionTest.

@Test
public void setIamPolicyExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockTagValues.addException(exception);
    try {
        ResourceName resource = FolderName.of("[FOLDER]");
        Policy policy = Policy.newBuilder().build();
        client.setIamPolicy(resource, policy);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : Policy(com.google.iam.v1.Policy) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ResourceName(com.google.api.resourcenames.ResourceName) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Aggregations

Policy (com.google.iam.v1.Policy)221 Test (org.junit.Test)182 AbstractMessage (com.google.protobuf.AbstractMessage)117 GetIamPolicyRequest (com.google.iam.v1.GetIamPolicyRequest)80 ByteString (com.google.protobuf.ByteString)76 ArrayList (java.util.ArrayList)72 SetIamPolicyRequest (com.google.iam.v1.SetIamPolicyRequest)71 AuditConfig (com.google.iam.v1.AuditConfig)68 Binding (com.google.iam.v1.Binding)68 ResourceName (com.google.api.resourcenames.ResourceName)66 StatusRuntimeException (io.grpc.StatusRuntimeException)43 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)41 PolicyType (oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType)13 RuleType (oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType)12 IOException (java.io.IOException)10 TargetType (oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType)10 ToscaPolicyConversionException (org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException)9 KeyManagementServiceClient (com.google.cloud.kms.v1.KeyManagementServiceClient)8 TopicAdminClient (com.google.cloud.pubsub.v1.TopicAdminClient)8 DeadLetterPolicy (com.google.pubsub.v1.DeadLetterPolicy)8