diff --git a/distribution/galleon-feature-packs/pom.xml b/distribution/galleon-feature-packs/pom.xml index fcbedba3b0..fc16e85110 100644 --- a/distribution/galleon-feature-packs/pom.xml +++ b/distribution/galleon-feature-packs/pom.xml @@ -32,6 +32,7 @@ saml-adapter-galleon-pack + saml-adapter-galleon-pack-layer-metadata-tests diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/pom.xml b/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/pom.xml new file mode 100644 index 0000000000..d9d706e53e --- /dev/null +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/pom.xml @@ -0,0 +1,120 @@ + + + + + org.keycloak + galleon-feature-packs-parent + 999.0.0-SNAPSHOT + + + 4.0.0 + + org.keycloak + keycloak-saml-adapter-galleon-pack-layers-metadata-tests + + Keycloak Galleon Feature Pack: SAML Adapter Layer Metadata Tests + jar + + + 1.2.6 + 4.0.1 + + + + org.keycloak + keycloak-saml-adapter-galleon-pack + zip + test + + + junit + junit + test + + + + org.jboss.shrinkwrap + shrinkwrap-api + test + ${version.org.jboss.shrinkwrap} + + + org.jboss.shrinkwrap + shrinkwrap-impl-base + test + ${version.org.jboss.shrinkwrap} + + + org.wildfly.glow + wildfly-glow-core + + + org.wildfly.glow + wildfly-glow-maven-resolver + + + jakarta.ejb + jakarta.ejb-api + ${version.jakarta.ejb.jakarta-ejb-api} + + + * + * + + + + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + + + copy-provisioning-xml + validate + + copy-resources + + + ${project.build.testOutputDirectory}/glow/${project.version} + + + ${project.basedir}/src/test/resources/glow/latest + true + + + + + + + + + + src/test/resources + + glow/latest/* + + true + + + + diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/src/test/java/org/keycloak/test/saml/adapter/galleon/pack/layer/metadata/EjbLiteAnnotationUsage.java b/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/src/test/java/org/keycloak/test/saml/adapter/galleon/pack/layer/metadata/EjbLiteAnnotationUsage.java new file mode 100644 index 0000000000..efcb26521a --- /dev/null +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/src/test/java/org/keycloak/test/saml/adapter/galleon/pack/layer/metadata/EjbLiteAnnotationUsage.java @@ -0,0 +1,7 @@ +package org.keycloak.test.saml.adapter.galleon.pack.layer.metadata; + +import jakarta.ejb.Stateless; + +@Stateless +public class EjbLiteAnnotationUsage { +} diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/src/test/java/org/keycloak/test/saml/adapter/galleon/pack/layer/metadata/KeycloakSamlAdapterLayerMetaDataTestCase.java b/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/src/test/java/org/keycloak/test/saml/adapter/galleon/pack/layer/metadata/KeycloakSamlAdapterLayerMetaDataTestCase.java new file mode 100644 index 0000000000..217107b3d2 --- /dev/null +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/src/test/java/org/keycloak/test/saml/adapter/galleon/pack/layer/metadata/KeycloakSamlAdapterLayerMetaDataTestCase.java @@ -0,0 +1,93 @@ +package org.keycloak.test.saml.adapter.galleon.pack.layer.metadata; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.Asset; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.exporter.ZipExporter; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.wildfly.glow.Arguments; +import org.wildfly.glow.GlowMessageWriter; +import org.wildfly.glow.GlowSession; +import org.wildfly.glow.ScanResults; +import org.wildfly.glow.maven.MavenResolver; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.Collections; +import java.util.Set; +import java.util.stream.Collectors; + +public class KeycloakSamlAdapterLayerMetaDataTestCase { + + private static final String URL_PROPERTY = "wildfly-glow-galleon-feature-packs-url"; + private static final Path ARCHIVES_PATH = Paths.get("target/glow-archives"); + private static final String WEB_XML = "" + + " " + + " KEYCLOAK-SAML" + + " " + + ""; + @BeforeClass + public static void prepareArchivesDirectory() throws Exception { + Path glowXmlPath = Paths.get("target/test-classes/glow"); + System.out.println(glowXmlPath.toUri()); + System.setProperty(URL_PROPERTY, glowXmlPath.toUri().toString()); + if (Files.exists(ARCHIVES_PATH)) { + Files.walkFileTree(ARCHIVES_PATH, new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + }); + } + Files.createDirectories(ARCHIVES_PATH); + } + + + private static Path createWebArchive(String archiveName, String xmlName, String xmlContents, Class... classes) { + WebArchive war = ShrinkWrap.create(WebArchive.class); + Asset asset = new StringAsset(xmlContents); + war.addAsWebInfResource(asset, xmlName); + war.addClasses(classes); + ZipExporter exporter = war.as(ZipExporter.class); + Path path = ARCHIVES_PATH.resolve(archiveName); + exporter.exportTo(path.toFile()); + return path; + } + + @Test + public void testKeycloakDetected() throws Exception { + Path p = createWebArchive("test.war", "web.xml", WEB_XML); + Arguments arguments = Arguments.scanBuilder().setBinaries(Collections.singletonList(p)).build(); + ScanResults scanResults = GlowSession.scan(MavenResolver.newMavenResolver(), arguments, GlowMessageWriter.DEFAULT); + Set foundLayers = scanResults.getDiscoveredLayers().stream().map(l -> l.getName()).collect(Collectors.toSet()); + Assert.assertTrue(foundLayers.toString(), foundLayers.contains("keycloak-saml") && + foundLayers.contains("keycloak-client-saml") && + !foundLayers.contains("keycloak-client-saml-ejb")); + } + + @Test + public void testKeycloakEJBDetected() throws Exception { + Path p = createWebArchive("test-ejb.war", "web.xml", WEB_XML, EjbLiteAnnotationUsage.class); + Arguments arguments = Arguments.scanBuilder().setBinaries(Collections.singletonList(p)).build(); + ScanResults scanResults = GlowSession.scan(MavenResolver.newMavenResolver(), arguments, GlowMessageWriter.DEFAULT); + Set foundLayers = scanResults.getDiscoveredLayers().stream().map(l -> l.getName()).collect(Collectors.toSet()); + Assert.assertTrue(foundLayers.toString(), foundLayers.contains("keycloak-saml") && + foundLayers.contains("keycloak-client-saml") && + foundLayers.contains("keycloak-client-saml-ejb")); + } +} diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/src/test/resources/glow/latest/provisioning-bare-metal.xml b/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/src/test/resources/glow/latest/provisioning-bare-metal.xml new file mode 100644 index 0000000000..2c3baeb7aa --- /dev/null +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/src/test/resources/glow/latest/provisioning-bare-metal.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/src/test/resources/glow/versions.yaml b/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/src/test/resources/glow/versions.yaml new file mode 100644 index 0000000000..776f0dc974 --- /dev/null +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack-layer-metadata-tests/src/test/resources/glow/versions.yaml @@ -0,0 +1,2 @@ +latest: ${project.version} +versions: ${project.version} \ No newline at end of file diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/layers/standalone/keycloak-client-saml-ejb/layer-spec.xml b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/layers/standalone/keycloak-client-saml-ejb/layer-spec.xml index e130798553..84bba8864d 100644 --- a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/layers/standalone/keycloak-client-saml-ejb/layer-spec.xml +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/layers/standalone/keycloak-client-saml-ejb/layer-spec.xml @@ -1,5 +1,8 @@ - + + + + diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/layers/standalone/keycloak-client-saml/layer-spec.xml b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/layers/standalone/keycloak-client-saml/layer-spec.xml index 00f1c159b9..a6350b9533 100644 --- a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/layers/standalone/keycloak-client-saml/layer-spec.xml +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/layers/standalone/keycloak-client-saml/layer-spec.xml @@ -1,5 +1,8 @@ - + + + + diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/layers/standalone/keycloak-saml/layer-spec.xml b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/layers/standalone/keycloak-saml/layer-spec.xml index 1d869f320b..cc47c6b3f5 100644 --- a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/layers/standalone/keycloak-saml/layer-spec.xml +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/layers/standalone/keycloak-saml/layer-spec.xml @@ -1,5 +1,8 @@ - + + + + diff --git a/pom.xml b/pom.xml index ec94a24831..dc3ff4a8ee 100644 --- a/pom.xml +++ b/pom.xml @@ -221,9 +221,12 @@ 2.0.3 - 6.4.2.Final - 5.1.0.Final + 6.5.2.Final + 5.2.2.Final 2.3.1.Final + + + 1.0.0.Alpha8 true @@ -1343,6 +1346,12 @@ keycloak-saml-adapter-core-jakarta ${project.version} + + org.keycloak + keycloak-saml-adapter-galleon-pack + ${project.version} + zip + org.keycloak keycloak-saml-tomcat-adapter-core @@ -1725,6 +1734,20 @@ jboss-servlet-api_4.0_spec ${jboss-servlet-api_4.0_spec} + + + + org.wildfly.glow + wildfly-glow-core + test + ${version.org.wildfly.glow} + + + org.wildfly.glow + wildfly-glow-maven-resolver + test + ${version.org.wildfly.glow} +