use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.
the class ComponentInvalidationClusterTest method testComponentUpdating.
@Test
public void testComponentUpdating() {
ComponentRepresentation testEntity = createTestEntityRepresentation();
// CREATE
log.info("(1) createEntityOnCurrentFailNode");
ComponentRepresentation comp = createEntityOnCurrentFailNode(testEntity);
for (ContainerInfo ci : suiteContext.getAuthServerBackendsInfo()) {
assertComponentHasCorrectConfig(comp, ci);
}
iterateCurrentFailNode();
// config - add new
comp.getConfig().putSingle("val3", "val3 value");
comp = updateEntityOnCurrentFailNode(comp, "config - adding");
for (ContainerInfo ci : suiteContext.getAuthServerBackendsInfo()) {
assertComponentHasCorrectConfig(comp, ci);
}
iterateCurrentFailNode();
// config - remove
comp.getConfig().remove("val3");
comp = updateEntityOnCurrentFailNode(comp, "config - removing");
for (ContainerInfo ci : suiteContext.getAuthServerBackendsInfo()) {
assertComponentHasCorrectConfig(comp, ci);
}
iterateCurrentFailNode();
// config - update 1
comp.getConfig().get("val1").set(0, comp.getConfig().get("val1").get(0) + " - updated");
comp = updateEntityOnCurrentFailNode(comp, "config");
for (ContainerInfo ci : suiteContext.getAuthServerBackendsInfo()) {
assertComponentHasCorrectConfig(comp, ci);
}
}
use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.
the class RoleInvalidationClusterTest method assertEntityOnSurvivorNodesEqualsTo.
@Override
protected void assertEntityOnSurvivorNodesEqualsTo(RoleRepresentation testEntityOnFailNode) {
super.assertEntityOnSurvivorNodesEqualsTo(testEntityOnFailNode);
// composites
boolean entityDiffers = false;
for (ContainerInfo survivorNode : getCurrentSurvivorNodes()) {
log.debug(String.format("Attempt to verify %s on survivor %s (%s)", getEntityType(testEntityOnFailNode), survivorNode, survivorNode.getContextRoot()));
RoleRepresentation testEntityOnSurvivorNode = readEntity(testEntityOnFailNode, survivorNode);
if (EqualsBuilder.reflectionEquals(sortFieldsComposites(testEntityOnSurvivorNode.getComposites()), sortFieldsComposites(testEntityOnFailNode.getComposites()))) {
log.info(String.format("Verification of %s on survivor %s PASSED", getEntityType(testEntityOnFailNode), survivorNode));
} else {
entityDiffers = true;
log.error(String.format("Verification of %s on survivor %s FAILED", getEntityType(testEntityOnFailNode), survivorNode));
String tf = ReflectionToStringBuilder.reflectionToString(testEntityOnFailNode.getComposites(), ToStringStyle.SHORT_PREFIX_STYLE);
String ts = ReflectionToStringBuilder.reflectionToString(testEntityOnSurvivorNode.getComposites(), ToStringStyle.SHORT_PREFIX_STYLE);
log.error(String.format("\nEntity on fail node: \n%s\n" + "\nEntity on survivor node: \n%s\n" + "\nDifference: \n%s\n", tf, ts, StringUtils.difference(tf, ts)));
}
}
assertFalse(entityDiffers);
}
use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.
the class URLProvider method doLookup.
@Override
public Object doLookup(ArquillianResource resource, Annotation... qualifiers) {
URL url = (URL) super.doLookup(resource, qualifiers);
if (url == null) {
String appServerContextRoot = ServerURLs.getAppServerContextRoot();
try {
for (Annotation a : qualifiers) {
if (OperateOnDeployment.class.isAssignableFrom(a.annotationType())) {
return new URL(appServerContextRoot + "/" + ((OperateOnDeployment) a).value() + "/");
}
}
} catch (MalformedURLException ex) {
throw new RuntimeException(ex);
}
}
// inject context roots if annotation present
for (Annotation a : qualifiers) {
if (AuthServerContext.class.isAssignableFrom(a.annotationType())) {
return suiteContext.get().getAuthServerInfo().getContextRoot();
}
if (AppServerContext.class.isAssignableFrom(a.annotationType())) {
// standalone
ContainerInfo appServerInfo = testContext.get().getAppServerInfo();
if (appServerInfo != null)
return appServerInfo.getContextRoot();
// cluster
List<ContainerInfo> appServerBackendsInfo = testContext.get().getAppServerBackendsInfo();
if (appServerBackendsInfo.isEmpty())
throw new IllegalStateException("Both testContext's appServerInfo and appServerBackendsInfo not set.");
return appServerBackendsInfo.get(0).getContextRoot();
}
if (AuthServerBrowserContext.class.isAssignableFrom(a.annotationType())) {
return suiteContext.get().getAuthServerInfo().getBrowserContextRoot();
}
if (AppServerBrowserContext.class.isAssignableFrom(a.annotationType())) {
// standalone
ContainerInfo appServerInfo = testContext.get().getAppServerInfo();
if (appServerInfo != null)
return appServerInfo.getBrowserContextRoot();
// cluster
List<ContainerInfo> appServerBackendsInfo = testContext.get().getAppServerBackendsInfo();
if (appServerBackendsInfo.isEmpty())
throw new IllegalStateException("Both testContext's appServerInfo and appServerBackendsInfo not set.");
return appServerBackendsInfo.get(0).getBrowserContextRoot();
}
}
// fix injected URL
if (url != null) {
try {
url = new URIBuilder(url.toURI()).setScheme(APP_SERVER_SCHEME).setHost(APP_SERVER_HOST).setPort(Integer.parseInt(APP_SERVER_PORT)).build().toURL();
} catch (URISyntaxException | MalformedURLException ex) {
throw new RuntimeException(ex);
}
}
return url;
}
use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.
the class SpiProvidersSwitchingUtils method resetProvider.
public static void resetProvider(SuiteContext suiteContext, SetDefaultProvider annotation) {
ContainerInfo authServerInfo = suiteContext.getAuthServerInfo();
SpiSwitcher spiSwitcher = SpiSwitcher.getSpiSwitcherFor(authServerInfo);
String spi = annotation.spi();
Container container = authServerInfo.getArquillianContainer();
if (annotation.onlyUpdateDefault()) {
String originalValue = originalSettingsBackup.get(spi);
log.infof("Resetting default provider for %s to %s", spi, originalValue == null ? "<null>" : originalValue);
if (originalValue != null) {
spiSwitcher.updateDefaultProvider(container, spi, originalValue);
} else {
spiSwitcher.unsetDefaultProvider(container, spi);
}
} else {
log.infof("Removing default provider for %s to %s", spi);
spiSwitcher.removeProviderConfig(container, spi);
}
}
Aggregations