Search in sources :

Example 6 with TestIamPermissionsResponse

use of com.google.iam.v1.TestIamPermissionsResponse in project google-cloud-java by GoogleCloudPlatform.

the class ITSubscriptionAdminClientSnippets method replaceSubscriptionPolicyAndTestPermissionsIsSuccessful.

@Test
public void replaceSubscriptionPolicyAndTestPermissionsIsSuccessful() throws Exception {
    String topicName = topics[0];
    String subscriptionName = subscriptions[0];
    createSubscription(topicName, subscriptionName);
    Policy policy = subscriptionAdminClientSnippets.replaceSubscriptionPolicy(subscriptionName);
    assertNotNull(policy.getBindingsCount());
    assertTrue(policy.getBindings(0).getRole().equalsIgnoreCase(Role.viewer().toString()));
    assertTrue(policy.getBindings(0).getMembers(0).equalsIgnoreCase(Identity.allAuthenticatedUsers().toString()));
    TestIamPermissionsResponse response = subscriptionAdminClientSnippets.testSubscriptionPermissions(subscriptionName);
    assertTrue(response.getPermissionsList().contains("pubsub.subscriptions.get"));
}
Also used : Policy(com.google.iam.v1.Policy) TestIamPermissionsResponse(com.google.iam.v1.TestIamPermissionsResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

TestIamPermissionsResponse (com.google.iam.v1.TestIamPermissionsResponse)6 Test (org.junit.Test)4 ByteString (com.google.protobuf.ByteString)3 TopicAdminClient (com.google.cloud.pubsub.spi.v1.TopicAdminClient)2 Policy (com.google.iam.v1.Policy)2 TestIamPermissionsRequest (com.google.iam.v1.TestIamPermissionsRequest)2 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 SubscriptionName (com.google.pubsub.v1.SubscriptionName)1 TopicName (com.google.pubsub.v1.TopicName)1