FederatedGraphReadAccessPredicate extends FederatedGraphAccessPredicate { @Override public boolean test(final User user, final String adminAuth) { return super.test(user, adminAuth); } FederatedGraphReadAccessPredicate(final String creatingUserId, final Set<String> auths, final boolean isPublic); @JsonCreator  FederatedGraphReadAccessPredicate(
            @JsonProperty("creatingUserId") final String creatingUserId,
            @JsonProperty("auths") final List<String> auths,
            @JsonProperty("public") final boolean isPublic); @Override boolean test(final User user, final String adminAuth);  }
@Test public void shouldReturnTrueForResourceCreator() { assertTrue(createAccessPredicate(TEST_USER.getUserId(), NO_AUTHS, NON_PUBLIC).test(TEST_USER, null)); }
@Test public void shouldReturnTrueForPublicResource() { assertTrue(createAccessPredicate(TEST_USER.getUserId(), asList("auth1"), PUBLIC).test(new User.Builder().userId("AnotherUser").build(), null)); }
@Test public void shouldReturnFalseForUserWhoIsNotResourceCreator() { assertFalse(createAccessPredicate(TEST_USER.getUserId(), NO_AUTHS, NON_PUBLIC).test(new User.Builder().userId("AnotherUser").build(), null)); }
@Test public void shouldReturnTrueForAdministrator() { assertTrue(createAccessPredicate(TEST_USER.getUserId(), NO_AUTHS, NON_PUBLIC).test(new User.Builder().userId("AdminUser").opAuths("auth1", "auth2").build(), "auth1")); }
@Test public void shouldReturnTrueForAdministratorWithAnyAdminAuths() { assertTrue(createAccessPredicate(TEST_USER.getUserId(), NO_AUTHS, NON_PUBLIC).test(new User.Builder().userId("AdminUser").opAuths("auth1", "auth2").build(), "authX,authY,auth1")); }
@Test public void shouldReturnFalseForUserWhoIsNotAdministrator() { assertFalse(createAccessPredicate(TEST_USER.getUserId(), NO_AUTHS, NON_PUBLIC).test(new User.Builder().userId("NonAdminUser").opAuths("auth1", "auth2").build(), "auth3")); }
@Test public void shouldReturnTrueForUserWithPermission() { assertTrue(createAccessPredicate(TEST_USER.getUserId(), asList("auth1"), NON_PUBLIC).test(new User.Builder().userId("AnotherUser").opAuths("auth1", "auth2").build(), null)); }
@Test public void shouldReturnFalseForUserWithoutPermission() { assertFalse(createAccessPredicate(TEST_USER.getUserId(), asList("auth1"), NON_PUBLIC).test(new User.Builder().userId("AnotherUser").opAuths("auth3").build(), null)); }