This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
commit bcd4f0d636315b9d9405f32f8aef2322f848c239 Author: Robert Munteanu <[email protected]> AuthorDate: Fri Feb 10 23:05:50 2023 +0100 oidc-rp: run it using a local feature model --- org.apache.sling.servlets.oidc-rp/.gitignore | 1 + org.apache.sling.servlets.oidc-rp/pom.xml | 90 ++++++++++++++++++++-- .../src/main/features/main.json | 36 +++++++++ .../servlets/oidc_rp/AuthorizationCodeFlowIT.java | 5 +- 4 files changed, 122 insertions(+), 10 deletions(-) diff --git a/org.apache.sling.servlets.oidc-rp/.gitignore b/org.apache.sling.servlets.oidc-rp/.gitignore new file mode 100644 index 00000000..a85248dc --- /dev/null +++ b/org.apache.sling.servlets.oidc-rp/.gitignore @@ -0,0 +1 @@ +launcher/ diff --git a/org.apache.sling.servlets.oidc-rp/pom.xml b/org.apache.sling.servlets.oidc-rp/pom.xml index e2ec172e..0e829481 100644 --- a/org.apache.sling.servlets.oidc-rp/pom.xml +++ b/org.apache.sling.servlets.oidc-rp/pom.xml @@ -43,12 +43,27 @@ <groupId>biz.aQute.bnd</groupId> <artifactId>bnd-maven-plugin</artifactId> </plugin> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + <configuration> + <systemPropertyVariables> + <sling.http.port>${http.port}/</sling.http.port> + </systemPropertyVariables> + </configuration> + </plugin> <plugin> <groupId>org.apache.sling</groupId> <artifactId>slingfeature-maven-plugin</artifactId> <version>1.6.8</version> <extensions>true</extensions> - <configuration> <skipAddFeatureDependencies>true</skipAddFeatureDependencies> <framework> @@ -110,25 +125,86 @@ </execution> </executions> </plugin> - <!-- + <!-- reserve network ports for the integration tests --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>reserve-network-port</id> + <goals> + <goal>reserve-network-port</goal> + </goals> + <phase>pre-integration-test</phase> + <configuration> + <portNames> + <portName>http.port</portName> + </portNames> + </configuration> + </execution> + </executions> + </plugin> <plugin> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>prepare-feature-launcher</id> <goals> - <goal>get</goal> - <goal>copy</goal> + <goal>unpack</goal> </goals> <phase>package</phase> <configuration> - <artifact>org.apache.sling:org.apache.sling.feature.launcher:\${org.apache.sling.feature.launcher.version}</artifact> - <stripVersion>true</stripVersion> + <artifactItems> + <artifactItem> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.feature.launcher</artifactId> + <version>1.2.4</version> + <type>tar.gz</type> + <!-- remove the version number from the unpacked folder --> + <fileMappers> + <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper> + <pattern>\Qorg.apache.sling.feature.launcher-1.2.4\E</pattern> + <replacement>org.apache.sling.feature.launcher</replacement> + </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper> + </fileMappers> + </artifactItem> + </artifactItems> </configuration> </execution> </executions> </plugin> - --> + <plugin> + <groupId>org.apache.sling</groupId> + <artifactId>feature-launcher-maven-plugin</artifactId> + <version>0.1.4</version> + <configuration> + <launches> + <launch> + <id>sling-starter-oak-tar</id> + <feature> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + <classifier>app</classifier> + <type>slingosgifeature</type> + </feature> + <launcherArguments> + <frameworkProperties> + <org.osgi.service.http.port>${http.port}</org.osgi.service.http.port> + </frameworkProperties> + </launcherArguments> + </launch> + </launches> + </configuration> + <executions> + <execution> + <goals> + <goal>start</goal> + <goal>stop</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> <dependencies> diff --git a/org.apache.sling.servlets.oidc-rp/src/main/features/main.json b/org.apache.sling.servlets.oidc-rp/src/main/features/main.json new file mode 100644 index 00000000..e84f33db --- /dev/null +++ b/org.apache.sling.servlets.oidc-rp/src/main/features/main.json @@ -0,0 +1,36 @@ +{ + "bundles": [ + { + "id":"com.nimbusds:oauth2-oidc-sdk:9.35", + "start-order": 24 + }, + { + "id":"com.nimbusds:nimbus-jose-jwt:9.22", + "start-order": 24 + }, + { + "id":"com.nimbusds:content-type:2.2", + "start-order": 24 + }, + { + "id":"com.nimbusds:lang-tag:1.6", + "start-order": 24 + }, + { + "id":"org.apache.servicemix.bundles:org.apache.servicemix.bundles.jcip-annotations:1.0_2", + "start-order": 24 + }, + { + "id":"net.minidev:json-smart:2.4.8", + "start-order": 24 + }, + { + "id":"net.minidev:accessors-smart:2.4.8", + "start-order": 24 + }, + { + "id": "org.apache.sling:org.apache.sling.servlets.oidc-rp:${project.version}", + "start-order": 25 + } + ] +} \ No newline at end of file diff --git a/org.apache.sling.servlets.oidc-rp/src/test/java/org/apache/sling/servlets/oidc_rp/AuthorizationCodeFlowIT.java b/org.apache.sling.servlets.oidc-rp/src/test/java/org/apache/sling/servlets/oidc_rp/AuthorizationCodeFlowIT.java index 57f4b83e..2eb9f3ab 100644 --- a/org.apache.sling.servlets.oidc-rp/src/test/java/org/apache/sling/servlets/oidc_rp/AuthorizationCodeFlowIT.java +++ b/org.apache.sling.servlets.oidc-rp/src/test/java/org/apache/sling/servlets/oidc_rp/AuthorizationCodeFlowIT.java @@ -61,14 +61,13 @@ class AuthorizationCodeFlowIT { @Test void accessTokenIsPresentOnSuccessfulLogin() throws Exception { int keycloakPort = keycloak.getHttpPort(); + int slingPort = Integer.getInteger("sling.http.port", 8080); // two parts // - local app on port 8080 // - keycloak on port 8081 - // TODO - lookup external sling app from a env settting ( and start using maven infrastructure ) - - SlingClient sling = SlingClient.Builder.create(URI.create("http://localhost:8080"), "admin", "admin").disableRedirectHandling().build(); + SlingClient sling = SlingClient.Builder.create(URI.create("http://localhost:" + slingPort), "admin", "admin").disableRedirectHandling().build(); // configure connection to keycloak sling.adaptTo(OsgiConsoleClient.class).editConfiguration("org.apache.sling.servlets.oidc_rp.impl.OidcConnectionImpl",null,
