Search in sources :

Example 1 with ContainerInfo

use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.

the class AbstractInvalidationClusterTest method assertEntityOnSurvivorNodesEqualsTo.

protected void assertEntityOnSurvivorNodesEqualsTo(T testEntityOnFailNode) {
    boolean entityDiffers = false;
    for (ContainerInfo survivorNode : getCurrentSurvivorNodes()) {
        log.debug(String.format("Attempt to verify %s on survivor %s (%s)", getEntityType(testEntityOnFailNode), survivorNode, survivorNode.getContextRoot()));
        T testEntityOnSurvivorNode = readEntity(testEntityOnFailNode, survivorNode);
        if (EqualsBuilder.reflectionEquals(sortFields(testEntityOnSurvivorNode), sortFields(testEntityOnFailNode), excludedComparisonFields)) {
            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, ToStringStyle.SHORT_PREFIX_STYLE);
            String ts = ReflectionToStringBuilder.reflectionToString(testEntityOnSurvivorNode, 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);
}
Also used : ContainerInfo(org.keycloak.testsuite.arquillian.ContainerInfo)

Example 2 with ContainerInfo

use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.

the class AbstractInvalidationClusterTest method assertEntityOnSurvivorNodesIsDeleted.

private void assertEntityOnSurvivorNodesIsDeleted(T testEntityOnFailNode) {
    // check if deleted from all survivor nodes
    boolean entityExists = false;
    for (ContainerInfo survivorNode : getCurrentSurvivorNodes()) {
        T testEntityOnSurvivorNode = readEntity(testEntityOnFailNode, survivorNode);
        if (testEntityOnSurvivorNode == null) {
            log.info(String.format("Verification of %s deletion on survivor %s PASSED", getEntityType(testEntityOnFailNode), survivorNode));
        } else {
            entityExists = true;
            log.error(String.format("Verification of %s deletion on survivor %s FAILED", getEntityType(testEntityOnFailNode), survivorNode));
        }
    }
    assertFalse(entityExists);
}
Also used : ContainerInfo(org.keycloak.testsuite.arquillian.ContainerInfo)

Example 3 with ContainerInfo

use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.

the class ConcurrentLoginClusterTest method beforeTest.

@Before
@Override
public void beforeTest() {
    // Start backend nodes
    log.info("Starting 2 backend nodes now");
    for (ContainerInfo node : suiteContext.getAuthServerBackendsInfo()) {
        if (!controller.isStarted(node.getQualifier())) {
            log.info("Starting backend node: " + node);
            controller.start(node.getQualifier());
            Assert.assertTrue(controller.isStarted(node.getQualifier()));
        }
    }
    // Import realms
    log.info("Importing realms");
    List<RealmRepresentation> testRealms = new LinkedList<>();
    super.addTestRealms(testRealms);
    for (RealmRepresentation testRealm : testRealms) {
        importRealm(testRealm);
    }
    log.info("Realms imported");
    // Finally create clients
    createClients();
}
Also used : RealmRepresentation(org.keycloak.representations.idm.RealmRepresentation) ContainerInfo(org.keycloak.testsuite.arquillian.ContainerInfo) LinkedList(java.util.LinkedList) Before(org.junit.Before)

Example 4 with ContainerInfo

use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.

the class SpiProvidersSwitchingUtils method removeProvider.

public static void removeProvider(SuiteContext suiteContext, SetDefaultProvider annotation) {
    ContainerInfo authServerInfo = suiteContext.getAuthServerInfo();
    SpiSwitcher spiSwitcher = SpiSwitcher.getSpiSwitcherFor(authServerInfo);
    String spi = annotation.spi();
    Container container = authServerInfo.getArquillianContainer();
    log.infof("Removing default provider setting for %s", spi);
    if (annotation.onlyUpdateDefault()) {
        spiSwitcher.unsetDefaultProvider(container, spi);
    } else {
        spiSwitcher.removeProviderConfig(container, spi);
    }
}
Also used : KeycloakQuarkusServerDeployableContainer(org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer) Container(org.jboss.arquillian.container.spi.Container) ContainerInfo(org.keycloak.testsuite.arquillian.ContainerInfo)

Example 5 with ContainerInfo

use of org.keycloak.testsuite.arquillian.ContainerInfo in project keycloak by keycloak.

the class SpiProvidersSwitchingUtils method addProviderDefaultValue.

public static void addProviderDefaultValue(SuiteContext suiteContext, SetDefaultProvider annotation) {
    ContainerInfo authServerInfo = suiteContext.getAuthServerInfo();
    SpiSwitcher spiSwitcher = SpiSwitcher.getSpiSwitcherFor(authServerInfo);
    String spi = annotation.spi();
    Container container = authServerInfo.getArquillianContainer();
    log.infof("Setting default provider for %s to %s", spi, annotation.providerId());
    if (annotation.onlyUpdateDefault()) {
        spiSwitcher.getCurrentDefaultProvider(container, spi, annotation).ifPresent(v -> originalSettingsBackup.put(spi, v));
        spiSwitcher.updateDefaultProvider(container, spi, annotation.providerId());
    } else {
        spiSwitcher.setDefaultProvider(container, spi, annotation.providerId());
    }
}
Also used : KeycloakQuarkusServerDeployableContainer(org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer) Container(org.jboss.arquillian.container.spi.Container) ContainerInfo(org.keycloak.testsuite.arquillian.ContainerInfo)

Aggregations

ContainerInfo (org.keycloak.testsuite.arquillian.ContainerInfo)14 Container (org.jboss.arquillian.container.spi.Container)3 KeycloakQuarkusServerDeployableContainer (org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer)3 Before (org.junit.Before)2 Annotation (java.lang.annotation.Annotation)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 LinkedList (java.util.LinkedList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1 ComponentRepresentation (org.keycloak.representations.idm.ComponentRepresentation)1 RealmRepresentation (org.keycloak.representations.idm.RealmRepresentation)1 RoleRepresentation (org.keycloak.representations.idm.RoleRepresentation)1 SamlClient (org.keycloak.testsuite.util.SamlClient)1 SamlClientBuilder (org.keycloak.testsuite.util.SamlClientBuilder)1