use of org.keycloak.testsuite.arquillian.annotation.EnableFeature in project keycloak by keycloak.
the class PartialImportTest method testAddClientsWithServiceAccountsAndAuthorization.
@EnableFeature(value = UPLOAD_SCRIPTS, skipRestart = true)
@Test
public void testAddClientsWithServiceAccountsAndAuthorization() throws IOException {
setFail();
addClients(true);
PartialImportResults results = doImport();
assertEquals(NUM_ENTITIES * 2, results.getAdded());
for (PartialImportResult result : results.getResults()) {
if (result.getResourceType().equals(ResourceType.CLIENT)) {
String id = result.getId();
ClientResource clientRsc = testRealmResource().clients().get(id);
ClientRepresentation client = clientRsc.toRepresentation();
assertTrue(client.getName().startsWith(CLIENT_PREFIX));
Assert.assertTrue(client.isServiceAccountsEnabled());
if (ProfileAssume.isFeatureEnabled(AUTHORIZATION)) {
Assert.assertTrue(client.getAuthorizationServicesEnabled());
AuthorizationResource authRsc = clientRsc.authorization();
ResourceServerRepresentation authRep = authRsc.exportSettings();
Assert.assertNotNull(authRep);
Assert.assertEquals(2, authRep.getResources().size());
Assert.assertEquals(3, authRep.getPolicies().size());
} else {
Assert.assertNull(client.getAuthorizationServicesEnabled());
}
} else {
UserResource userRsc = testRealmResource().users().get(result.getId());
Assert.assertTrue(userRsc.toRepresentation().getUsername().startsWith(ServiceAccountConstants.SERVICE_ACCOUNT_USER_PREFIX + CLIENT_PREFIX));
}
}
}
use of org.keycloak.testsuite.arquillian.annotation.EnableFeature in project keycloak by keycloak.
the class PartialImportTest method testEverythingOverwriteWithServiceAccounts.
@EnableFeature(value = UPLOAD_SCRIPTS, skipRestart = true)
@Test
public void testEverythingOverwriteWithServiceAccounts() throws IOException {
setOverwrite();
importEverything(true);
PartialImportResults results = doImport();
assertEquals(NUM_ENTITIES * (NUM_RESOURCE_TYPES + 1), results.getOverwritten());
}
use of org.keycloak.testsuite.arquillian.annotation.EnableFeature in project keycloak by keycloak.
the class PartialImportTest method testEverythingSkipWithServiceAccounts.
@EnableFeature(value = UPLOAD_SCRIPTS, skipRestart = true)
@Test
public void testEverythingSkipWithServiceAccounts() throws IOException {
setSkip();
importEverything(true);
PartialImportResults results = doImport();
assertEquals(NUM_ENTITIES * (NUM_RESOURCE_TYPES + 1), results.getSkipped());
}
use of org.keycloak.testsuite.arquillian.annotation.EnableFeature in project keycloak by keycloak.
the class LoginTest method loginSuccessfulWithDynamicScope.
@Test
@EnableFeature(value = Profile.Feature.DYNAMIC_SCOPES, skipRestart = true)
public void loginSuccessfulWithDynamicScope() {
ProfileAssume.assumeFeatureEnabled(DYNAMIC_SCOPES);
ClientScopeRepresentation clientScope = new ClientScopeRepresentation();
clientScope.setName("dynamic");
clientScope.setAttributes(new HashMap<String, String>() {
{
put(ClientScopeModel.IS_DYNAMIC_SCOPE, "true");
put(ClientScopeModel.DYNAMIC_SCOPE_REGEXP, "dynamic:*");
}
});
clientScope.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
Response response = testRealm().clientScopes().create(clientScope);
String scopeId = ApiUtil.getCreatedId(response);
getCleanup().addClientScopeId(scopeId);
response.close();
ClientResource testApp = ApiUtil.findClientByClientId(testRealm(), "test-app");
ClientRepresentation testAppRep = testApp.toRepresentation();
testApp.update(testAppRep);
testApp.addOptionalClientScope(scopeId);
oauth.scope("dynamic:scope");
oauth.doLogin("login@test.com", "password");
events.expectLogin().user(userId).assertEvent();
}
use of org.keycloak.testsuite.arquillian.annotation.EnableFeature in project keycloak by keycloak.
the class ClientSettingsTest method alwaysDisplayInAccountConsole.
@Test
@EnableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true)
public void alwaysDisplayInAccountConsole() {
refreshPageAndWaitForLoad();
newClient = createClientRep("always-display-in-console", OIDC);
createClient(newClient);
newClient.setRedirectUris(TEST_REDIRECT_URIs);
newClient.setAlwaysDisplayInConsole(true);
assertFalse(clientSettingsPage.form().isAlwaysDisplayInConsole());
clientSettingsPage.form().setAlwaysDisplayInConsole(true);
clientSettingsPage.form().setRedirectUris(TEST_REDIRECT_URIs);
clientSettingsPage.form().save();
assertTrue(clientSettingsPage.form().isAlwaysDisplayInConsole());
ClientRepresentation found = findClientByClientId(newClient.getClientId());
assertNotNull("Client " + newClient.getClientId() + " was not found.", found);
assertClientSettingsEqual(newClient, found);
clientSettingsPage.form().setAccessType(BEARER_ONLY);
assertFalse(clientSettingsPage.form().isAlwaysDisplayInConsoleVisible());
// check if the switch is displayed when change the Client to SAML and bearer-only flag is set to on (bearer-only
// is not applicable for SAML but it's technically present in the Client representation and therefore can affect
// the visibility of the switch)
clientSettingsPage.form().setProtocol(SAML);
assertTrue(clientSettingsPage.form().isAlwaysDisplayInConsoleVisible());
}
Aggregations