use of com.google.cloud.storage.testing.ApiPolicyMatcher in project google-cloud-java by GoogleCloudPlatform.
the class PolicyHelperTest method testEquivalence.
@Test
public void testEquivalence() {
Policy libPolicy = Policy.newBuilder().addIdentity(StorageRoles.objectViewer(), Identity.allUsers()).addIdentity(StorageRoles.objectAdmin(), Identity.user("test1@gmail.com"), Identity.user("test2@gmail.com")).setEtag(ETAG).build();
com.google.api.services.storage.model.Policy apiPolicy = new com.google.api.services.storage.model.Policy().setBindings(ImmutableList.of(new Bindings().setMembers(ImmutableList.of("allUsers")).setRole("roles/storage.objectViewer"), new Bindings().setMembers(ImmutableList.of("user:test1@gmail.com", "user:test2@gmail.com")).setRole("roles/storage.objectAdmin"))).setEtag(ETAG);
Policy actualLibPolicy = PolicyHelper.convertFromApiPolicy(apiPolicy);
com.google.api.services.storage.model.Policy actualApiPolicy = PolicyHelper.convertToApiPolicy(libPolicy);
assertEquals(libPolicy, actualLibPolicy);
assertTrue(new ApiPolicyMatcher(apiPolicy).matches(actualApiPolicy));
}
Aggregations