use of org.keycloak.admin.client.resource.RealmResource in project keycloak by keycloak.
the class UsersTest method countUsersByFiltersWithNoViewPermission.
@Test
public void countUsersByFiltersWithNoViewPermission() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException {
ProfileAssume.assumeFeatureEnabled(Profile.Feature.AUTHORIZATION);
RealmResource testRealmResource = setupTestEnvironmentWithPermissions(false);
// search username
assertThat(testRealmResource.users().count(null, null, null, "user"), is(0));
assertThat(testRealmResource.users().count(null, null, null, "user1"), is(0));
assertThat(testRealmResource.users().count(null, null, null, "notExisting"), is(0));
assertThat(testRealmResource.users().count(null, null, null, ""), is(0));
// search first name
assertThat(testRealmResource.users().count(null, "FirstName", null, null), is(0));
assertThat(testRealmResource.users().count(null, "user2FirstName", null, null), is(0));
assertThat(testRealmResource.users().count(null, "notExisting", null, null), is(0));
assertThat(testRealmResource.users().count(null, "", null, null), is(0));
// search last name
assertThat(testRealmResource.users().count("LastName", null, null, null), is(0));
assertThat(testRealmResource.users().count("user2LastName", null, null, null), is(0));
assertThat(testRealmResource.users().count("notExisting", null, null, null), is(0));
assertThat(testRealmResource.users().count("", null, null, null), is(0));
// search in email
assertThat(testRealmResource.users().count(null, null, "@example.com", null), is(0));
assertThat(testRealmResource.users().count(null, null, "user1@example.com", null), is(0));
assertThat(testRealmResource.users().count(null, null, "user1@test.com", null), is(0));
assertThat(testRealmResource.users().count(null, null, "", null), is(0));
// search for combinations
assertThat(testRealmResource.users().count("LastName", "FirstName", null, null), is(0));
assertThat(testRealmResource.users().count("user1LastName", "FirstName", null, null), is(0));
assertThat(testRealmResource.users().count("user1LastName", "", null, null), is(0));
assertThat(testRealmResource.users().count("LastName", "", null, null), is(0));
assertThat(testRealmResource.users().count("LastName", "", null, null), is(0));
assertThat(testRealmResource.users().count(null, null, "@example.com", "user"), is(0));
// search not specified (defaults to simply /count)
assertThat(testRealmResource.users().count(null, null, null, null), is(0));
assertThat(testRealmResource.users().count("", "", "", ""), is(0));
}
use of org.keycloak.admin.client.resource.RealmResource in project keycloak by keycloak.
the class UsersTest method countUsersBySearchWithGroupViewPermission.
@Test
public void countUsersBySearchWithGroupViewPermission() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException {
ProfileAssume.assumeFeatureEnabled(Profile.Feature.AUTHORIZATION);
RealmResource testRealmResource = setupTestEnvironmentWithPermissions(true);
// search all
assertThat(testRealmResource.users().count("user"), is(3));
// search first name
assertThat(testRealmResource.users().count("*FirstName*"), is(3));
assertThat(testRealmResource.users().count("user2FirstName"), is(1));
// search last name
assertThat(testRealmResource.users().count("*LastName*"), is(3));
assertThat(testRealmResource.users().count("user2LastName"), is(1));
// search in email
assertThat(testRealmResource.users().count("*@example.com*"), is(3));
assertThat(testRealmResource.users().count("user1@example.com"), is(1));
// search for something not existing
assertThat(testRealmResource.users().count("notExisting"), is(0));
// search for empty string
assertThat(testRealmResource.users().count(""), is(3));
// search not specified (defaults to simply /count)
assertThat(testRealmResource.users().count(null), is(3));
}
use of org.keycloak.admin.client.resource.RealmResource in project keycloak by keycloak.
the class AbstractPolicyManagementTest method configureAuthorization.
@Before
public void configureAuthorization() throws Exception {
createResourcesAndScopes();
RealmResource realm = getRealm();
createPolicies(realm, getClient(realm));
}
use of org.keycloak.admin.client.resource.RealmResource in project keycloak by keycloak.
the class AbstractKerberosTest method updateKerberosAuthExecutionRequirement.
public static AuthenticationExecutionModel.Requirement updateKerberosAuthExecutionRequirement(AuthenticationExecutionModel.Requirement requirement, RealmResource realmResource) {
Optional<AuthenticationExecutionInfoRepresentation> kerberosAuthExecutionOpt = realmResource.flows().getExecutions(DefaultAuthenticationFlows.BROWSER_FLOW).stream().filter(e -> e.getProviderId().equals(SpnegoAuthenticatorFactory.PROVIDER_ID)).findFirst();
Assert.assertTrue(kerberosAuthExecutionOpt.isPresent());
AuthenticationExecutionInfoRepresentation kerberosAuthExecution = kerberosAuthExecutionOpt.get();
String oldRequirementStr = kerberosAuthExecution.getRequirement();
AuthenticationExecutionModel.Requirement oldRequirement = AuthenticationExecutionModel.Requirement.valueOf(oldRequirementStr);
kerberosAuthExecution.setRequirement(requirement.name());
realmResource.flows().updateExecutions(DefaultAuthenticationFlows.BROWSER_FLOW, kerberosAuthExecution);
return oldRequirement;
}
use of org.keycloak.admin.client.resource.RealmResource in project keycloak by keycloak.
the class UncaughtErrorPageTest method internationalisationEnabled.
@Test
public void internationalisationEnabled() throws MalformedURLException {
RealmResource testRealm = realmsResouce().realm("master");
RealmRepresentation rep = testRealm.toRepresentation();
rep.setInternationalizationEnabled(true);
rep.setDefaultLocale("en");
rep.setSupportedLocales(Collections.singleton("en"));
testRealm.update(rep);
try {
checkPageNotFound("/auth/realms/master/nosuch");
checkPageNotFound("/auth/nosuch");
} finally {
rep.setInternationalizationEnabled(false);
testRealm.update(rep);
}
}
Aggregations