KEYCLOAK-10004 refactor fuse adapter tests

This commit is contained in:
vramik 2019-04-02 14:47:02 +02:00 committed by Hynek Mlnařík
parent 0193e78ff9
commit e2d69632e9
72 changed files with 534 additions and 880 deletions

View file

@ -150,7 +150,6 @@ Assumed you downloaded `jboss-fuse-karaf-6.3.0.redhat-229.zip`
2) Install to your local maven repository and change the properties according to your env (This step can be likely avoided if you somehow configure your local maven settings to point directly to Fuse repo):
mvn install:install-file \
-DgroupId=org.jboss.fuse \
-DartifactId=jboss-fuse-karaf \
@ -166,24 +165,22 @@ Assumed you downloaded `jboss-fuse-karaf-6.3.0.redhat-229.zip`
mvn -f testsuite/integration-arquillian/servers/pom.xml \
clean install \
-Papp-server-fuse63 \
-Dfuse63.version=6.3.0.redhat-229 \
-Dapp.server.karaf.update.config=true \
-Dmaven.local.settings=$HOME/.m2/settings.xml \
-Drepositories=,http://REPO-SERVER/brewroot/repos/sso-7.1-build/latest/maven/ \
-Dmaven.repo.local=$HOME/.m2/repository
-Dfuse63.version=6.3.0.redhat-229
# Run the Fuse adapter tests
mvn -f testsuite/integration-arquillian/tests/base/pom.xml \
clean install \
-Pauth-server-wildfly \
-Papp-server-fuse63 \
-Dtest=Fuse*AdapterTest
-Dauth.server.ssl.required=false \
-Dadditional.fuse.repos=,$REPO \
-Dtest=*.fuse.*
### JBoss Fuse 7.X
1) Download JBoss Fuse 7 to your filesystem. It can be downloaded from http://origin-repository.jboss.org/nexus/content/groups/m2-proxy/org/jboss/fuse/fuse-karaf (Fuse 7.1 or higher is required)
Assumed you downloaded `fuse-karaf-7.1.0.fuse-710029.zip`
1) Download JBoss Fuse 7 to your filesystem. It can be downloaded from http://origin-repository.jboss.org/nexus/content/groups/m2-proxy/org/jboss/fuse/fuse-karaf (Fuse 7.3 or higher is required)
Assumed you downloaded `fuse-karaf-7.3.0.fuse-730065-redhat-00002.zip`
2) Install to your local maven repository and change the properties according to your env (This step can be likely avoided if you somehow configure your local maven settings to point directly to Fuse repo):
@ -191,9 +188,9 @@ Assumed you downloaded `fuse-karaf-7.1.0.fuse-710029.zip`
mvn install:install-file \
-DgroupId=org.jboss.fuse \
-DartifactId=fuse-karaf \
-Dversion=7.1.0.fuse-710029 \
-Dversion=7.3.0.fuse-730065-redhat-00002 \
-Dpackaging=zip \
-Dfile=/mydownloads/fuse-karaf-7.1.0.fuse-710029.zip
-Dfile=/mydownloads/fuse-karaf-7.3.0.fuse-730065-redhat-00002.zip
3) Prepare Fuse and run the tests (change props according to your environment, versions etc):
@ -203,17 +200,15 @@ Assumed you downloaded `fuse-karaf-7.1.0.fuse-710029.zip`
mvn -f testsuite/integration-arquillian/servers/pom.xml \
clean install \
-Papp-server-fuse7x \
-Dfuse7x.version=7.1.0.fuse-710029 \
-Dapp.server.karaf.update.config=true \
-Dmaven.local.settings=$HOME/.m2/settings.xml \
-Drepositories=,http://REPO-SERVER/brewroot/repos/sso-7.1-build/latest/maven/ \
-Dmaven.repo.local=$HOME/.m2/repository
-Dfuse7x.version=7.3.0.fuse-730065-redhat-00002
# Run the Fuse adapter tests
mvn -f testsuite/integration-arquillian/tests/base/pom.xml \
clean test \
-Papp-server-fuse7x \
-Dtest=Fuse*AdapterTest
-Dauth.server.ssl.required=false \
-Dadditional.fuse.repos=,$REPO \
-Dtest=*.fuse.*
### EAP6 with Hawtio

View file

@ -25,9 +25,6 @@ The artifacts are used by the Arquillian TestSuite.
- Wildfly 8, 9, 10
- EAP 6, 7
- Relative (Wildfly 10 / EAP 7)
- Karaf / Fuse
- Karaf 3
- Fuse 6.1, 6.2
- Tomcat
- Tomcat 7, 8, 9

View file

@ -31,14 +31,6 @@ Submodules are enabled with profiles: `-Papp-server-MODULE`
Configures SSL in `standalone.xml`. See profile `ssl`.
## App Server - Karaf
Submodules are enabled with profiles: `-Papp-server-MODULE`
### Modules
* __`karaf3` Karaf 3__
* __`fuse61` JBoss Fuse 6.1__
* __`fuse62` JBoss Fuse 6.2__
## App Server - Tomcat
Submodules are enabled with profiles: `-Papp-server-MODULE`
### Modules

View file

@ -1,42 +0,0 @@
set NOPAUSE=true
echo "JAVA_HOME=%JAVA_HOME%"
start "Karaf" /b cmd /c start.bat
echo "Karaf container starting"
ping 127.0.0.1 -n 5 > nul
set ERROR=0
set TIMEOUT=10
set I=0
:wait_for_karaf
call client.bat %CLIENT_AUTH% info
if %ERRORLEVEL% equ 0 goto install_features
echo "Server is not reachable. Waiting."
ping 127.0.0.1 -n 2 > nul
set /a I=%I%+1
if %I% gtr %TIMEOUT% (
set ERROR=1
goto shutdown_karaf
)
goto wait_for_karaf
:install_features
echo "Server is reachable. Installing features."
if "%UNINSTALL_PAX%" == "true" (
call client.bat %CLIENT_AUTH% -f uninstall-pax.cli
if %ERRORLEVEL% neq 0 set ERROR=%ERRORLEVEL%
)
if "%UPDATE_CONFIG%" == "true" (
call client.bat %CLIENT_AUTH% -f update-config.cli
if %ERRORLEVEL% neq 0 set ERROR=%ERRORLEVEL%
)
call client.bat %CLIENT_AUTH% -f install-features.cli
if %ERRORLEVEL% neq 0 set ERROR=%ERRORLEVEL%
:shutdown_karaf
call stop.bat
ping 127.0.0.1 -n 5 > nul
exit /b %ERROR%

View file

@ -1,67 +0,0 @@
#!/bin/bash
echo "JAVA_HOME=$JAVA_HOME"
./start
echo "Karaf container starting"
sleep 5
TIMEOUT=10
DELAY=1
T=0
RESULT=0
until [ $T -gt $TIMEOUT ]
do
if ./client $CLIENT_AUTH info; then
echo "Server is reachable."
if "$UNINSTALL_PAX" == "true"; then
echo "Uninstalling PAX"
./client $CLIENT_AUTH -f uninstall-pax.cli
if [ $? -ne 0 ]; then RESULT=1; fi
fi
if "$UPDATE_CONFIG" == "true"; then
echo "Updating Config"
./client $CLIENT_AUTH -f update-config.cli
if [ $? -ne 0 ]; then
echo "Call update-config.cli failed!";
RESULT=1;
else
./client $CLIENT_AUTH config:list | grep org.ops4j.pax.url.mvn.
fi
fi
echo "Installing features."
./client $CLIENT_AUTH -f install-features.cli
if [ $? -ne 0 ]; then
echo "Call install-features.cli failed!";
RESULT=1;
fi
if "$UPDATE_CONFIG" == "true"; then
echo "Updating Config - Keycloak authentication"
./client $CLIENT_AUTH -f update-config-auth.cli
if [ $? -ne 0 ]; then
echo "Call update-config-auth.cli failed!";
RESULT=1;
fi
fi
./stop
rm -rf ../data/log
rm -rf ../data/tmp
sleep 5
exit $RESULT
else
echo "Server is not reachable. Waiting."
sleep $DELAY
let T=$T+$DELAY
fi
done
./stop
exit 1

View file

@ -1,64 +0,0 @@
<?xml version="1.0"?>
<!--
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
~ and other contributors as indicated by the @author tags.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-servers-app-server-karaf</artifactId>
<version>6.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>integration-arquillian-servers-app-server-fuse61</artifactId>
<packaging>pom</packaging>
<name>App Server - Karaf - JBoss Fuse 6.1</name>
<properties>
<app.server.karaf>fuse61</app.server.karaf>
<app.server.karaf.groupId>org.jboss.fuse</app.server.karaf.groupId>
<app.server.karaf.artifactId>jboss-fuse-full</app.server.karaf.artifactId>
<app.server.karaf.version>${fuse61.version}</app.server.karaf.version>
<app.server.karaf.unpacked.folder.name>jboss-fuse-${fuse61.version}</app.server.karaf.unpacked.folder.name>
<app.server.karaf.client.auth>-u admin -p admin</app.server.karaf.client.auth>
<app.server.karaf.uninstall.pax>true</app.server.karaf.uninstall.pax>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>fuse61.version</property>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -1,6 +0,0 @@
features:addurl mvn:org.ops4j.pax.web/pax-web-features/3.1.2/xml/features
features:addurl mvn:org.keycloak/keycloak-osgi-features/${project.version}/xml/features
features:addurl mvn:org.keycloak.example.demo/keycloak-fuse-example-features/${project.version}/xml/features
features:install keycloak-pax-web-upgrade
features:install pax-http-whiteboard/3.1.2
features:install pax-war/3.1.2

View file

@ -1,5 +0,0 @@
features:uninstall pax-war
features:uninstall pax-http-whiteboard
features:uninstall pax-http
features:uninstall pax-jetty
features:removeurl mvn:org.ops4j.pax.web/pax-web-features/3.0.6/xml/features

View file

@ -1,63 +0,0 @@
<?xml version="1.0"?>
<!--
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
~ and other contributors as indicated by the @author tags.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-servers-app-server-karaf</artifactId>
<version>6.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>integration-arquillian-servers-app-server-fuse62</artifactId>
<packaging>pom</packaging>
<name>App Server - Karaf - JBoss Fuse 6.2</name>
<properties>
<app.server.karaf>fuse62</app.server.karaf>
<app.server.karaf.groupId>org.jboss.fuse</app.server.karaf.groupId>
<app.server.karaf.artifactId>jboss-fuse-full</app.server.karaf.artifactId>
<app.server.karaf.version>${fuse62.version}</app.server.karaf.version>
<app.server.karaf.unpacked.folder.name>jboss-fuse-${fuse62.version}</app.server.karaf.unpacked.folder.name>
<app.server.karaf.client.auth>-u admin -p admin</app.server.karaf.client.auth>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>fuse62.version</property>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -1,3 +0,0 @@
features:addurl mvn:org.keycloak/keycloak-osgi-features/${project.version}/xml/features
features:addurl mvn:org.keycloak.testsuite/fuse-example-keycloak-features/${project.version}/xml/features
features:install keycloak-fuse-6.2-example

View file

@ -1,5 +0,0 @@
config:edit org.ops4j.pax.url.mvn
config:propset org.ops4j.pax.url.mvn.localRepository ${maven.repo.local}
config:propset org.ops4j.pax.url.mvn.settings ${maven.local.settings}
config:propappend org.ops4j.pax.url.mvn.repositories ${repositories}
config:update

View file

@ -1 +0,0 @@
admin=admin,admin,manager,viewer,Monitor, Operator, Maintainer, Deployer, Auditor, Administrator, SuperUser

View file

@ -35,7 +35,6 @@
<app.server.karaf.artifactId>jboss-fuse-karaf</app.server.karaf.artifactId>
<app.server.karaf.version>${fuse63.version}</app.server.karaf.version>
<app.server.karaf.unpacked.folder.name>jboss-fuse-${fuse63.version}</app.server.karaf.unpacked.folder.name>
<app.server.karaf.client.auth>-u admin -p admin</app.server.karaf.client.auth>
</properties>
<dependencies>

View file

@ -1,3 +0,0 @@
features:addurl mvn:org.keycloak/keycloak-osgi-features/${project.version}/xml/features
features:addurl mvn:org.keycloak.testsuite/fuse-example-keycloak-features/${project.version}/xml/features
features:install keycloak-fuse-6.3-example

View file

@ -1,8 +0,0 @@
config:edit org.apache.karaf.shell
config:propset sshRealm keycloak
config:update
system-property -p hawtio.roles admin,user
system-property -p hawtio.keycloakEnabled true
system-property -p hawtio.realm keycloak
system-property -p hawtio.keycloakClientConfig file://\$\{karaf.base\}/etc/keycloak-hawtio-client.json
system-property -p hawtio.rolePrincipalClasses org.keycloak.adapters.jaas.RolePrincipal,org.apache.karaf.jaas.boot.principal.RolePrincipal

View file

@ -1,10 +0,0 @@
config:edit org.ops4j.pax.url.mvn
config:propset org.ops4j.pax.url.mvn.localRepository ${maven.repo.local}
config:propset org.ops4j.pax.url.mvn.settings ${maven.local.settings}
config:propappend org.ops4j.pax.url.mvn.repositories ${repositories}
config:update
config:edit jmx.acl.org.apache.karaf.security.jmx
config:propappend list* viewer
config:propappend set* jmxAdmin
config:propappend * jmxAdmin,admin
config:update

View file

@ -1 +1 @@
admin=admin,admin,manager,viewer,Monitor, Operator, Maintainer, Deployer, Auditor, Administrator, SuperUser
admin=password,admin,manager,viewer,Monitor, Operator, Maintainer, Deployer, Auditor, Administrator, SuperUser

View file

@ -35,7 +35,6 @@
<app.server.karaf.artifactId>fuse-karaf</app.server.karaf.artifactId>
<app.server.karaf.version>${fuse7x.version}</app.server.karaf.version>
<app.server.karaf.unpacked.folder.name>fuse-karaf-${fuse7x.version}</app.server.karaf.unpacked.folder.name>
<app.server.karaf.client.auth>-u admin -p admin</app.server.karaf.client.auth>
</properties>
<dependencies>

View file

@ -1,7 +0,0 @@
feature:repo-add mvn:org.keycloak/keycloak-osgi-features/${project.version}/xml/features
feature:repo-add mvn:org.keycloak.testsuite/fuse-example-keycloak-features/${project.version}/xml/features
feature:install pax-http-undertow
feature:install keycloak-jaas keycloak-pax-http-undertow
feature:install keycloak-fuse-7.0-example

View file

@ -1,27 +0,0 @@
config:edit --factory --alias cxf org.ops4j.pax.web.context
config:property-set bundle.symbolicName org.apache.cxf.cxf-rt-transports-http
config:property-set context.id default
config:property-set context.param.keycloak.config.resolver org.keycloak.adapters.osgi.HierarchicalPathBasedKeycloakConfigResolver
config:property-set login.config.authMethod KEYCLOAK
config:property-set security.cxf.url /cxf/customerservice/*
config:property-set security.cxf.roles "admin, user"
config:update
config:edit org.apache.karaf.shell
config:property-set sshRealm keycloak
config:update
# Running on Fuse 7.1?
fuse71 = (system:version | grep --color never fuse-71) ;
system:property -p hawtio.keycloakEnabled true
system:property -p hawtio.realm keycloak
if { ($fuse71 trim) isEmpty } {
system:property -p hawtio.keycloakClientConfig '\${karaf.etc}/keycloak-hawtio-client.json'
system:property -p hawtio.keycloakServerConfig '\${karaf.etc}/keycloak-bearer.json'
system:property -p hawtio.roles admin,manager,viewer,ssh
} {
system:property -p hawtio.keycloakClientConfig 'file:\${karaf.etc}/keycloak-hawtio-client.json'
system:property -p hawtio.keycloakServerConfig 'file:\${karaf.etc}/keycloak-bearer.json'
}
system:property -p hawtio.rolePrincipalClasses org.keycloak.adapters.jaas.RolePrincipal,org.apache.karaf.jaas.boot.principal.RolePrincipal

View file

@ -1,11 +0,0 @@
config:edit org.ops4j.pax.url.mvn
config:property-set org.ops4j.pax.url.mvn.localRepository ${maven.repo.local}
config:property-set org.ops4j.pax.url.mvn.settings ${maven.local.settings}
config:property-append org.ops4j.pax.url.mvn.repositories "${repositories}"
config:update
config:edit jmx.acl.org.apache.karaf.security.jmx
config:property-append list* viewer
config:property-append set* jmxAdmin
config:property-append * jmxAdmin,admin
config:update

View file

@ -1 +1 @@
admin=admin,admin,manager,viewer,ssh,systembundles
admin=password,admin,manager,viewer,ssh,systembundles

View file

@ -1,40 +0,0 @@
<?xml version="1.0"?>
<!--
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
~ and other contributors as indicated by the @author tags.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-servers-app-server-karaf</artifactId>
<version>6.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>integration-arquillian-servers-app-server-karaf3</artifactId>
<packaging>pom</packaging>
<name>App Server - Karaf - Karaf 3</name>
<properties>
<app.server.karaf>karaf3</app.server.karaf>
<app.server.karaf.groupId>org.apache.karaf</app.server.karaf.groupId>
<app.server.karaf.artifactId>apache-karaf-minimal</app.server.karaf.artifactId>
<app.server.karaf.version>${karaf3.version}</app.server.karaf.version>
<app.server.karaf.unpacked.folder.name>apache-karaf-minimal-${karaf3.version}</app.server.karaf.unpacked.folder.name>
</properties>
</project>

View file

@ -1,5 +0,0 @@
feature:repo-add mvn:org.apache.camel.karaf/apache-camel/2.15.1/xml/features
feature:repo-add mvn:org.apache.cxf.karaf/apache-cxf/3.0.4/xml/features
feature:repo-add mvn:org.keycloak/keycloak-osgi-features/${project.version}/xml/features
feature:repo-add mvn:org.keycloak.example.demo/keycloak-fuse-example-features/${project.version}/xml/features
feature:install keycloak-fuse-example

View file

@ -1,5 +0,0 @@
config:edit org.ops4j.pax.url.mvn
config:property-set org.ops4j.pax.url.mvn.localRepository ${maven.repo.local}
config:property-set org.ops4j.pax.url.mvn.settings ${maven.local.settings}
config:property-append org.ops4j.pax.url.mvn.repositories ${repositories}
config:update

View file

@ -1,2 +0,0 @@
karaf = karaf,_g_:admingroup
_g_\:admingroup = group,admin,manager,viewer,webconsole

View file

@ -33,9 +33,6 @@
<common.resources>${project.parent.basedir}/common</common.resources>
<assembly.xml>${project.parent.basedir}/assembly.xml</assembly.xml>
<app.server.karaf.home>${containers.home}/${app.server.karaf.unpacked.folder.name}</app.server.karaf.home>
<app.server.karaf.client.auth>-u karaf</app.server.karaf.client.auth>
<app.server.karaf.uninstall.pax>false</app.server.karaf.uninstall.pax>
<app.server.karaf.update.config>false</app.server.karaf.update.config>
</properties>
<profiles>
@ -103,27 +100,6 @@
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-clis</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${app.server.karaf.home}/bin</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>install-features.cli</include>
<include>update-config.cli</include>
<include>update-config-auth.cli</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-configs</id>
<phase>process-resources</phase>
@ -150,29 +126,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>install-features</id>
<phase>process-test-resources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${common.resources}/install-features.${script.suffix}</executable>
<workingDirectory>${app.server.karaf.home}/bin</workingDirectory>
<environmentVariables>
<JAVA_HOME>${app.server.java.home}</JAVA_HOME>
<CLIENT_AUTH>${app.server.karaf.client.auth}</CLIENT_AUTH>
<UNINSTALL_PAX>${app.server.karaf.uninstall.pax}</UNINSTALL_PAX>
<UPDATE_CONFIG>${app.server.karaf.update.config}</UPDATE_CONFIG>
</environmentVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
@ -195,65 +148,6 @@
</build>
</profile>
<profile>
<id>enforce-props-when-update-config</id>
<activation>
<property>
<name>app.server.karaf.update.config</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-props-when-update-config</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<message>When updating config maven.local.settings is expected to be explicitly set.</message>
<property>maven.local.settings</property>
</requireProperty>
<requireProperty>
<message>When updating config maven.repo.local is expected to be explicitly set.</message>
<property>maven.repo.local</property>
</requireProperty>
<requireProperty>
<message>When updating config repositories is expected to be set.</message>
<property>repositories</property>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>app-server-karaf3</id>
<modules>
<module>karaf3</module>
</modules>
</profile>
<profile>
<id>app-server-fuse61</id>
<modules>
<module>fuse61</module>
</modules>
</profile>
<profile>
<id>app-server-fuse62</id>
<modules>
<module>fuse62</module>
</modules>
</profile>
<profile>
<id>app-server-fuse63</id>
<activation>

View file

@ -709,7 +709,7 @@
<app.server.http.port>8181</app.server.http.port>
<app.server.management.user>admin</app.server.management.user>
<app.server.management.password>admin</app.server.management.password>
<app.server.management.password>password</app.server.management.password>
<app.server.karaf.jvm.debug.args>-agentlib:jdwp=transport=dt_socket,server=y,suspend=${app.server.debug.suspend},address=localhost:${app.server.debug.port}</app.server.karaf.jvm.debug.args>
</properties>
<dependencies>
@ -733,6 +733,20 @@
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<message>When running fuse tests 'additional.fuse.repos' is expected to be set.</message>
<property>additional.fuse.repos</property>
</requireProperty>
</rules>
</configuration>
</plugin>
<plugin>
<groupId>org.commonjava.maven.plugins</groupId>
<artifactId>directory-maven-plugin</artifactId>
@ -770,7 +784,7 @@
<app.server.http.port>8181</app.server.http.port>
<app.server.management.user>admin</app.server.management.user>
<app.server.management.password>admin</app.server.management.password>
<app.server.management.password>password</app.server.management.password>
<app.server.karaf.jvm.debug.args>-agentlib:jdwp=transport=dt_socket,server=y,suspend=${app.server.debug.suspend},address=localhost:${app.server.debug.port}</app.server.karaf.jvm.debug.args>
</properties>
<dependencies>
@ -794,6 +808,20 @@
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<message>When running fuse tests 'additional.fuse.repos' is expected to be set.</message>
<property>additional.fuse.repos</property>
</requireProperty>
</rules>
</configuration>
</plugin>
<plugin>
<groupId>org.commonjava.maven.plugins</groupId>
<artifactId>directory-maven-plugin</artifactId>

View file

@ -30,6 +30,8 @@ import org.jboss.logging.Logger;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainers;
import org.keycloak.testsuite.arquillian.containers.SelfManagedAppContainerLifecycle;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.utils.fuse.FuseUtils;
import org.wildfly.extras.creaper.core.ManagementClient;
import org.wildfly.extras.creaper.core.online.ManagementProtocol;
import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
@ -194,10 +196,17 @@ public class AppServerTestEnricher {
log.info("Starting app server: " + testContext.getAppServerInfo().getQualifier());
controller.start(testContext.getAppServerInfo().getQualifier());
}
if (isFuseAppServer()) {
FuseUtils.setUpFuse(ContainerConstants.APP_SERVER_PREFIX + CURRENT_APP_SERVER);
}
}
}
public void stopAppServer(@Observes(precedence = 1) AfterClass event) {
/*
* For Fuse: precedence = 2 - app server has to be stopped
* before AuthServerTestEnricher.afterClass is executed
*/
public void stopAppServer(@Observes(precedence = 2) AfterClass event) {
if (testContext.getAppServerInfo() == null) {
return; // no adapter test
}
@ -286,8 +295,8 @@ public class AppServerTestEnricher {
return CURRENT_APP_SERVER.equals("wls");
}
public static boolean isOSGiAppServer() {
return CURRENT_APP_SERVER.contains("karaf") || CURRENT_APP_SERVER.contains("fuse");
public static boolean isFuseAppServer() {
return CURRENT_APP_SERVER.contains("fuse");
}
private boolean isJBossBased() {

View file

@ -468,7 +468,7 @@ public class AuthServerTestEnricher {
}
}
public void afterClass(@Observes(precedence = 2) AfterClass event) {
public void afterClass(@Observes(precedence = 1) AfterClass event) {
//check if a test accidentally left the auth-server not running
ContainerController controller = containerConroller.get();
if (!controller.isStarted(suiteContext.getAuthServerInfo().getQualifier())) {

View file

@ -28,7 +28,7 @@ import org.jboss.arquillian.container.test.impl.client.deployment.AnnotationDepl
import org.jboss.arquillian.test.spi.TestClass;
import org.jboss.logging.Logger;
import org.keycloak.common.util.StringPropertyReplacer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.getAppServerQualifiers;

View file

@ -24,8 +24,6 @@ import org.keycloak.testsuite.arquillian.AuthServerTestEnricher;
public class ContainerAssume {
private static final Logger log = Logger.getLogger(ContainerAssume.class);
private static final String fuse6 = "fuse63";
private static final String fuse7 = "fuse7";
public static void assumeNotAuthServerUndertow() {
Assume.assumeFalse("Doesn't work on auth-server-undertow",
@ -37,12 +35,4 @@ public class ContainerAssume {
String.format("Ignoring test since %s is set to false",
AuthServerTestEnricher.AUTH_SERVER_CLUSTER_PROPERTY), AuthServerTestEnricher.AUTH_SERVER_CLUSTER);
}
public static void assumeNotAppServerFuse6() {
Assume.assumeFalse("The test doesn't work on " + fuse6, fuse6.equals(System.getProperty("app.server")));
}
public static void assumeNotAppServerFuse7() {
Assume.assumeFalse("The test doesn't work on " + fuse7, System.getProperty("app.server").contains(fuse7));
}
}

View file

@ -20,7 +20,6 @@ import org.jboss.arquillian.container.test.api.Deployer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.BeforeClass;
import org.junit.Test;
import org.keycloak.admin.client.resource.AuthorizationResource;
import org.keycloak.admin.client.resource.ClientResource;
@ -28,10 +27,9 @@ import org.keycloak.admin.client.resource.ClientsResource;
import org.keycloak.representations.idm.ClientRepresentation;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.idm.authorization.PolicyRepresentation;
import org.keycloak.testsuite.ProfileAssume;
import org.keycloak.testsuite.adapter.AbstractExampleAdapterTest;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import java.io.File;
import java.io.FileNotFoundException;

View file

@ -24,7 +24,7 @@ import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.keycloak.testsuite.arquillian.AppServerTestEnricher;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import static org.assertj.core.api.Java6Assertions.assertThat;

View file

@ -22,9 +22,8 @@ import java.io.IOException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.keycloak.testsuite.adapter.page.PhotozClientAuthzTestApp;
import org.keycloak.testsuite.arquillian.AppServerTestEnricher;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
/**
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>

View file

@ -21,9 +21,8 @@ import java.io.IOException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.keycloak.testsuite.adapter.page.PhotozClientAuthzTestApp;
import org.keycloak.testsuite.arquillian.AppServerTestEnricher;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
/**
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>

View file

@ -23,7 +23,7 @@ import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
/**
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>

View file

@ -25,7 +25,7 @@ import org.keycloak.representations.idm.authorization.ResourceRepresentation;
import java.io.File;
import java.io.IOException;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
/**
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>

View file

@ -24,7 +24,7 @@ import org.junit.Test;
import org.keycloak.representations.idm.authorization.ResourcePermissionRepresentation;
import org.keycloak.representations.idm.authorization.ResourceRepresentation;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
/**
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>

View file

@ -23,7 +23,7 @@ import org.junit.Test;
import java.io.File;
import java.io.IOException;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
/**
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>

View file

@ -21,7 +21,7 @@ import java.io.IOException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
/**
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>

View file

@ -32,7 +32,6 @@ import org.jboss.arquillian.container.test.api.Deployer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.BeforeClass;
import org.junit.Test;
import org.keycloak.admin.client.resource.AuthorizationResource;
import org.keycloak.admin.client.resource.ClientResource;
@ -42,10 +41,9 @@ import org.keycloak.representations.idm.ClientRepresentation;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.idm.authorization.ResourcePermissionRepresentation;
import org.keycloak.representations.idm.authorization.ResourceRepresentation;
import org.keycloak.testsuite.ProfileAssume;
import org.keycloak.testsuite.adapter.AbstractExampleAdapterTest;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.util.UIUtils;
import org.openqa.selenium.By;

View file

@ -33,7 +33,7 @@ import org.keycloak.testsuite.adapter.AbstractExampleAdapterTest;
import org.keycloak.testsuite.adapter.page.AngularCorsProductTestApp;
import org.keycloak.testsuite.adapter.page.CorsDatabaseServiceTestApp;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.auth.page.account.Account;
import org.keycloak.testsuite.auth.page.login.OIDCLogin;
import org.keycloak.testsuite.util.JavascriptBrowser;

View file

@ -39,7 +39,7 @@ import org.keycloak.testsuite.adapter.AbstractExampleAdapterTest;
import org.keycloak.testsuite.adapter.page.HawtioPage;
import org.keycloak.testsuite.arquillian.AppServerTestEnricher;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.arquillian.containers.SelfManagedAppContainerLifecycle;
import org.keycloak.testsuite.auth.page.login.OIDCLogin;
import org.keycloak.testsuite.util.DroneUtils;

View file

@ -16,29 +16,25 @@
*/
package org.keycloak.testsuite.adapter.example.fuse;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO;
import static org.keycloak.testsuite.utils.fuse.FuseUtils.assertCommand;
import static org.keycloak.testsuite.utils.fuse.FuseUtils.getCommandOutput;
import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlDoesntStartWith;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWithLoginUrlOf;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServerConnection;
@ -47,14 +43,6 @@ import javax.management.ReflectionException;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.future.ConnectFuture;
import org.apache.sshd.client.channel.ChannelExec;
import org.apache.sshd.client.channel.ClientChannelEvent;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.client.session.ClientSession.ClientSessionEvent;
import org.hamcrest.Matchers;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.Page;
import org.junit.Assert;
@ -64,19 +52,24 @@ import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.adapter.AbstractExampleAdapterTest;
import org.keycloak.testsuite.adapter.page.Hawtio2Page;
import org.keycloak.testsuite.adapter.page.HawtioPage;
import org.keycloak.testsuite.adapter.page.fuse.AdminInterface;
import org.keycloak.testsuite.adapter.page.fuse.CustomerListing;
import org.keycloak.testsuite.adapter.page.fuse.CustomerPortalFuseExample;
import org.keycloak.testsuite.adapter.page.fuse.ProductPortalFuseExample;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.auth.page.account.Account;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.auth.page.login.OIDCLogin;
import org.keycloak.testsuite.util.ContainerAssume;
import org.keycloak.testsuite.util.DroneUtils;
import org.keycloak.testsuite.util.JavascriptBrowser;
import org.keycloak.testsuite.util.WaitUtils;
import org.keycloak.testsuite.utils.fuse.FuseUtils.Result;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
@AppServerContainer(ContainerConstants.APP_SERVER_FUSE63)
@AppServerContainer(ContainerConstants.APP_SERVER_FUSE7X)
public class FuseAdminAdapterTest extends AbstractExampleAdapterTest {
public class FuseAdapterTest extends AbstractExampleAdapterTest {
@Drone
@JavascriptBrowser
@ -85,18 +78,27 @@ public class FuseAdminAdapterTest extends AbstractExampleAdapterTest {
@Page
@JavascriptBrowser
private HawtioPage hawtioPage;
@Page
@JavascriptBrowser
private Hawtio2Page hawtio2Page;
@Page
@JavascriptBrowser
private OIDCLogin testRealmLoginPageFuse;
private SshClient client;
protected enum Result { OK, NOT_FOUND, NO_CREDENTIALS, NO_ROLES };
@Page
@JavascriptBrowser
protected CustomerPortalFuseExample customerPortal;
@Page
@JavascriptBrowser
protected CustomerListing customerListing;
@Page
@JavascriptBrowser
protected AdminInterface adminInterface;
@Page
@JavascriptBrowser
protected ProductPortalFuseExample productPortal;
@Page
@JavascriptBrowser
protected Account testRealmAccount;
@Override
public void addAdapterTestRealms(List<RealmRepresentation> testRealms) {
@ -108,6 +110,9 @@ public class FuseAdminAdapterTest extends AbstractExampleAdapterTest {
public void setDefaultPageUriParameters() {
super.setDefaultPageUriParameters();
testRealmLoginPageFuse.setAuthRealm(DEMO);
testRealmPage.setAuthRealm(DEMO);
testRealmLoginPage.setAuthRealm(DEMO);
testRealmAccount.setAuthRealm(DEMO);
}
@Before
@ -115,12 +120,17 @@ public class FuseAdminAdapterTest extends AbstractExampleAdapterTest {
DroneUtils.addWebDriver(jsDriver);
}
@Test
public void hawtio1LoginTest() throws Exception {
// Note that this does work only in Fuse 6 with Hawtio 1, Fuse 7 contains Hawtio 2
ContainerAssume.assumeNotAppServerFuse7();
@Override
public boolean isImportAfterEachMethod() {
return false;
}
@Test
@AppServerContainer(value = ContainerConstants.APP_SERVER_FUSE7X, skip = true)
public void hawtio1LoginTest() throws Exception {
hawtioPage.navigateTo();
WaitUtils.waitForPageToLoad();
assertCurrentUrlDoesntStartWith(hawtioPage);
testRealmLoginPageFuse.form().login("user", "invalid-password");
assertCurrentUrlDoesntStartWith(hawtioPage);
@ -145,13 +155,12 @@ public class FuseAdminAdapterTest extends AbstractExampleAdapterTest {
}
@Test
@AppServerContainer(value = ContainerConstants.APP_SERVER_FUSE63, skip = true)
public void hawtio2LoginTest() throws Exception {
// Note that this does work only in Fuse 7 with Hawtio 2, Fuse 6 contains Hawtio 1
ContainerAssume.assumeNotAppServerFuse6();
hawtio2Page.navigateTo();
WaitUtils.waitForPageToLoad();
assertCurrentUrlDoesntStartWith(hawtio2Page);
testRealmLoginPageFuse.form().login("user", "invalid-password");
assertCurrentUrlDoesntStartWith(hawtio2Page);
@ -182,10 +191,8 @@ public class FuseAdminAdapterTest extends AbstractExampleAdapterTest {
}
@Test
@AppServerContainer(value = ContainerConstants.APP_SERVER_FUSE7X, skip = true)
public void sshLoginTestFuse6() throws Exception {
// Note that this does not work for Fuse 7 since the error codes have changed
ContainerAssume.assumeNotAppServerFuse7();
assertCommand("mary", "password", "shell:date", Result.NO_CREDENTIALS);
assertCommand("john", "password", "shell:info", Result.NO_CREDENTIALS);
assertCommand("john", "password", "shell:date", Result.OK);
@ -193,10 +200,8 @@ public class FuseAdminAdapterTest extends AbstractExampleAdapterTest {
}
@Test
@AppServerContainer(value = ContainerConstants.APP_SERVER_FUSE63, skip = true)
public void sshLoginTestFuse7() throws Exception {
// Note that this works for Fuse 7 and newer
ContainerAssume.assumeNotAppServerFuse6();
assertCommand("mary", "password", "shell:date", Result.NOT_FOUND);
assertCommand("john", "password", "shell:info", Result.NOT_FOUND);
assertCommand("john", "password", "shell:date", Result.OK);
@ -218,102 +223,37 @@ public class FuseAdminAdapterTest extends AbstractExampleAdapterTest {
private void assertRoles(String username, String... expectedRoles) throws Exception {
final String commandOutput = getCommandOutput(username, "password", "jaas:whoami -r --no-format");
final List<String> parsedOutput = Arrays.asList(commandOutput.split("\\n+"));
assertThat(parsedOutput, Matchers.containsInAnyOrder(expectedRoles));
assertThat(parsedOutput, containsInAnyOrder(expectedRoles));
}
@Test
public void jmxLoginTest() throws Exception {
setJMXAuthentication("keycloak", "password");
ObjectName mbean = new ObjectName("org.apache.karaf:type=config,name=root");
//invalid credentials
try {
getJMXConnector("mary", "password1").getMBeanServerConnection();
log.debug("jmxLoginTest - testing: invalid credentials");
try (JMXConnector jmxConnector = getJMXConnector(10, TimeUnit.SECONDS, "mary", "password1")) {
jmxConnector.getMBeanServerConnection();
Assert.fail();
} catch (SecurityException se) {}
//no role
MBeanServerConnection connection = getJMXConnector("mary", "password").getMBeanServerConnection();
} catch (TimeoutException expected) {
assertThat(expected.getCause().toString(), containsString("java.lang.SecurityException: Authentication failed"));
}
log.debug("jmxLoginTest - testing: no role");
try (JMXConnector jmxConnector = getJMXConnector("mary", "password")) {
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
assertJmxInvoke(false, connection, mbean, "listProperties", new Object [] {""}, new String [] {String.class.getName()});
assertJmxInvoke(false, connection, mbean, "setProperty", new Object [] {"", "x", "y"}, new String [] {String.class.getName(), String.class.getName(), String.class.getName()});
//read only role
connection = getJMXConnector("john", "password").getMBeanServerConnection();
}
log.debug("jmxLoginTest - testing: read only role");
try (JMXConnector jmxConnector = getJMXConnector("john", "password")) {
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
assertJmxInvoke(true, connection, mbean, "listProperties", new Object [] {""}, new String [] {String.class.getName()});
assertJmxInvoke(false, connection, mbean, "setProperty", new Object [] {"", "x", "y"}, new String [] {String.class.getName(), String.class.getName(), String.class.getName()});
//read write role
connection = getJMXConnector("root", "password").getMBeanServerConnection();
}
log.debug("jmxLoginTest - testing: read write role");
try (JMXConnector jmxConnector = getJMXConnector("root", "password")) {
MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
assertJmxInvoke(true, connection, mbean, "listProperties", new Object [] {""}, new String [] {String.class.getName()});
assertJmxInvoke(true, connection, mbean, "setProperty", new Object [] {"", "x", "y"}, new String [] {String.class.getName(), String.class.getName(), String.class.getName()});
setJMXAuthentication("karaf", "admin");
}
protected String assertCommand(String user, String password, String command, Result result) throws Exception, IOException {
if (!command.endsWith("\n"))
command += "\n";
String output = getCommandOutput(user, password, command);
switch(result) {
case OK:
Assert.assertThat(output,
not(anyOf(containsString("Insufficient credentials"), Matchers.containsString("Command not found"))));
break;
case NOT_FOUND:
Assert.assertThat(output,
containsString("Command not found"));
break;
case NO_CREDENTIALS:
Assert.assertThat(output,
containsString("Insufficient credentials"));
break;
case NO_ROLES:
Assert.assertThat(output,
containsString("Current user has no associated roles"));
break;
default:
Assert.fail("Unexpected enum value: " + result);
}
return output;
}
protected String getCommandOutput(String user, String password, String command) throws Exception, IOException {
if (!command.endsWith("\n"))
command += "\n";
try (ClientSession session = openSshChannel(user, password);
ChannelExec channel = session.createExecChannel(command);
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
channel.setOut(out);
channel.setErr(out);
channel.open();
channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED, ClientChannelEvent.EOF), 0);
return new String(out.toByteArray());
}
}
protected ClientSession openSshChannel(String username, String password) throws Exception {
client = SshClient.setUpDefaultClient();
client.start();
ConnectFuture future = client.connect(username, "localhost", 8101);
future.await();
ClientSession session = future.getSession();
Set<ClientSessionEvent> ret = EnumSet.of(ClientSessionEvent.WAIT_AUTH);
while (ret.contains(ClientSessionEvent.WAIT_AUTH)) {
session.addPasswordIdentity(password);
session.auth().verify();
ret = session.waitFor(EnumSet.of(ClientSessionEvent.WAIT_AUTH, ClientSessionEvent.CLOSED, ClientSessionEvent.AUTHED), 0);
}
if (ret.contains(ClientSessionEvent.CLOSED)) {
throw new Exception("Could not open SSH channel");
}
return session;
}
protected void setJMXAuthentication(String realm, String password) throws Exception {
assertCommand("admin", "password", "config:edit org.apache.karaf.management; config:propset jmxRealm " + realm + "; config:update", Result.OK);
getMBeanServerConnection(10000, TimeUnit.MILLISECONDS, "admin", password);
}
private Object assertJmxInvoke(boolean expectSuccess, MBeanServerConnection connection, ObjectName mbean, String method,
@ -328,33 +268,112 @@ public class FuseAdminAdapterTest extends AbstractExampleAdapterTest {
}
}
private MBeanServerConnection getMBeanServerConnection(long timeout, final TimeUnit unit, String username, String password) throws Exception {
private JMXConnector getJMXConnector(String username, String password) throws Exception {
return getJMXConnector(2, TimeUnit.MINUTES, username, password);
}
private JMXConnector getJMXConnector(long timeout, TimeUnit unit, String username, String password) throws Exception {
Exception lastException = null;
long timeoutMillis = System.currentTimeMillis() + unit.toMillis(timeout);
while (System.currentTimeMillis() < timeoutMillis) {
try {
return getJMXConnector(username, password).getMBeanServerConnection();
Map<String, ?> env = Collections.singletonMap(JMXConnector.CREDENTIALS, new String[] { username, password });
return JMXConnectorFactory.connect(new JMXServiceURL(getJmxServiceUrl()), env);
} catch (Exception ex) {
lastException = ex;
Thread.sleep(500);
ex.printStackTrace();
log.debug("Loop: Getting MBean Server Connection: last caught exception: " + lastException.getClass().getName());
}
}
log.error("Failed to get MBean Server Connection within " + timeout + " " + unit.toString());
TimeoutException timeoutException = new TimeoutException();
timeoutException.initCause(lastException);
throw timeoutException;
}
private JMXConnector getJMXConnector(String userName, String password) throws Exception {
JMXServiceURL url = new JMXServiceURL(getJmxServiceUrl());
String[] credentials = new String[] { userName, password };
Map<String, ?> env = Collections.singletonMap(JMXConnector.CREDENTIALS, credentials);
JMXConnector connector = JMXConnectorFactory.connect(url, env);
return connector;
}
private String getJmxServiceUrl() throws Exception {
return "service:jmx:rmi://localhost:44444/jndi/rmi://localhost:1099/karaf-root";
}
@Test
public void testCustomerListingAndAccountManagement() {
customerPortal.navigateTo();
assertCurrentUrlStartsWith(customerPortal);
customerPortal.clickCustomerListingLink();
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
testRealmLoginPageFuse.form().login("bburke@redhat.com", "password");
assertCurrentUrlStartsWith(customerListing);
assertThat(DroneUtils.getCurrentDriver().getPageSource(), allOf(
containsString("Username: bburke@redhat.com"),
containsString("Bill Burke"),
containsString("Stian Thorgersen")
));
// account mgmt
customerListing.clickAccountManagement();
assertCurrentUrlStartsWith(testRealmAccount);
assertThat(testRealmAccount.getUsername(), equalTo("bburke@redhat.com"));
DroneUtils.getCurrentDriver().navigate().back();
customerListing.clickLogOut();
// assert user not logged in
customerPortal.clickCustomerListingLink();
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
}
@Test
public void testAdminInterface() {
customerPortal.navigateTo();
assertCurrentUrlStartsWith(customerPortal);
customerPortal.clickAdminInterfaceLink();
WaitUtils.waitForPageToLoad();
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
testRealmLoginPageFuse.form().login("admin", "password");
assertCurrentUrlStartsWith(adminInterface);
assertThat(DroneUtils.getCurrentDriver().getPageSource(), containsString("Hello admin!"));
assertThat(DroneUtils.getCurrentDriver().getPageSource(), containsString("This second sentence is returned from a Camel RestDSL endpoint"));
customerListing.navigateTo();
WaitUtils.waitForPageToLoad();
customerListing.clickLogOut();
WaitUtils.waitForPageToLoad();
WaitUtils.pause(2500);
customerPortal.navigateTo();//needed for phantomjs
WaitUtils.waitForPageToLoad();
customerPortal.clickAdminInterfaceLink();
WaitUtils.waitForPageToLoad();
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
testRealmLoginPageFuse.form().login("bburke@redhat.com", "password");
assertCurrentUrlStartsWith(adminInterface);
assertThat(DroneUtils.getCurrentDriver().getPageSource(), containsString("Status code is 403"));
}
@Test
public void testProductPortal() {
productPortal.navigateTo();
WaitUtils.waitForPageToLoad();
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
testRealmLoginPageFuse.form().login("bburke@redhat.com", "password");
assertCurrentUrlStartsWith(productPortal);
assertThat(productPortal.getProduct1UnsecuredText(), containsString("401: Unauthorized"));
assertThat(productPortal.getProduct1SecuredText(), containsString("Product received: id=1"));
assertThat(productPortal.getProduct2SecuredText(), containsString("Product received: id=2"));
productPortal.clickLogOutLink();
WaitUtils.waitForPageToLoad();
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
}
}

View file

@ -1,164 +0,0 @@
/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.testsuite.adapter.example.fuse;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO;
import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWithLoginUrlOf;
import java.io.File;
import java.util.List;
import org.jboss.arquillian.graphene.page.Page;
import org.junit.Test;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.adapter.AbstractExampleAdapterTest;
import org.keycloak.testsuite.adapter.page.fuse.AdminInterface;
import org.keycloak.testsuite.adapter.page.fuse.CustomerListing;
import org.keycloak.testsuite.adapter.page.fuse.CustomerPortalFuseExample;
import org.keycloak.testsuite.adapter.page.fuse.ProductPortalFuseExample;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.auth.page.account.Account;
import org.keycloak.testsuite.util.WaitUtils;
import org.hamcrest.Matchers;
/**
*
* @author tkyjovsk
*/
@AppServerContainer(ContainerConstants.APP_SERVER_FUSE63)
@AppServerContainer(ContainerConstants.APP_SERVER_FUSE7X)
public class FuseExampleAdapterTest extends AbstractExampleAdapterTest {
@Page
protected CustomerPortalFuseExample customerPortal;
@Page
protected CustomerListing customerListing;
@Page
protected AdminInterface adminInterface;
@Page
protected ProductPortalFuseExample productPortal;
@Page
protected Account testRealmAccount;
@Override
public void addAdapterTestRealms(List<RealmRepresentation> testRealms) {
RealmRepresentation fuseRealm = loadRealm(new File(TEST_APPS_HOME_DIR + "/fuse/demorealm.json"));
testRealms.add(fuseRealm);
}
@Override
public void setDefaultPageUriParameters() {
super.setDefaultPageUriParameters();
testRealmPage.setAuthRealm(DEMO);
testRealmLoginPage.setAuthRealm(DEMO);
testRealmAccount.setAuthRealm(DEMO);
}
// no Arquillian deployments - examples already installed by maven
@Test
public void testCustomerListingAndAccountManagement() {
customerPortal.navigateTo();
assertCurrentUrlStartsWith(customerPortal);
customerPortal.clickCustomerListingLink();
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
testRealmLoginPage.form().login("bburke@redhat.com", "password");
assertCurrentUrlStartsWith(customerListing);
String src = driver.getPageSource();
assertThat(src, Matchers.allOf(
containsString("Username: bburke@redhat.com"),
containsString("Bill Burke"),
containsString("Stian Thorgersen")
));
// account mgmt
customerListing.clickAccountManagement();
assertCurrentUrlStartsWith(testRealmAccount);
assertEquals(testRealmAccount.getUsername(), "bburke@redhat.com");
driver.navigate().back();
customerListing.clickLogOut();
// assert user not logged in
customerPortal.clickCustomerListingLink();
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
}
@Test
public void testAdminInterface() {
customerPortal.navigateTo();
assertCurrentUrlStartsWith(customerPortal);
customerPortal.clickAdminInterfaceLink();
WaitUtils.waitForPageToLoad();
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
testRealmLoginPage.form().login("admin", "password");
assertCurrentUrlStartsWith(adminInterface);
assertThat(driver.getPageSource(), containsString("Hello admin!"));
assertThat(driver.getPageSource(), containsString("This second sentence is returned from a Camel RestDSL endpoint"));
customerListing.navigateTo();
WaitUtils.waitForPageToLoad();
customerListing.clickLogOut();
WaitUtils.waitForPageToLoad();
WaitUtils.pause(2500);
customerPortal.navigateTo();//needed for phantomjs
WaitUtils.waitForPageToLoad();
customerPortal.clickAdminInterfaceLink();
WaitUtils.waitForPageToLoad();
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
testRealmLoginPage.form().login("bburke@redhat.com", "password");
assertCurrentUrlStartsWith(adminInterface);
assertThat(driver.getPageSource(), containsString("Status code is 403"));
}
@Test
public void testProductPortal() {
productPortal.navigateTo();
WaitUtils.waitForPageToLoad();
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
testRealmLoginPage.form().login("bburke@redhat.com", "password");
assertCurrentUrlStartsWith(productPortal);
assertThat(productPortal.getProduct1UnsecuredText(), containsString("401: Unauthorized"));
assertThat(productPortal.getProduct1SecuredText(), containsString("Product received: id=1"));
assertThat(productPortal.getProduct2SecuredText(), containsString("Product received: id=2"));
productPortal.clickLogOutLink();
WaitUtils.waitForPageToLoad();
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
}
}

View file

@ -32,7 +32,7 @@ import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.adapter.AbstractAdapterTest;
import org.keycloak.testsuite.arquillian.AppServerTestEnricher;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.pages.AccountUpdateProfilePage;
import org.keycloak.testsuite.pages.AppServerWelcomePage;
import org.keycloak.testsuite.util.DroneUtils;

View file

@ -59,7 +59,7 @@ import org.keycloak.testsuite.ProfileAssume;
import org.keycloak.testsuite.adapter.AbstractAdapterTest;
import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.broker.BrokerTestTools;
import org.keycloak.testsuite.page.AbstractPageWithInjectedUrl;
import org.keycloak.testsuite.pages.AccountUpdateProfilePage;

View file

@ -43,7 +43,7 @@ import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest;
import org.keycloak.testsuite.admin.ApiUtil;
import org.keycloak.testsuite.arquillian.AuthServerTestEnricher;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.broker.BrokerTestTools;
import org.keycloak.testsuite.page.AbstractPageWithInjectedUrl;
import org.keycloak.testsuite.pages.AccountUpdateProfilePage;

View file

@ -20,7 +20,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.utils.annotation.UseServletFilter;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)

View file

@ -66,7 +66,7 @@ import org.keycloak.testsuite.adapter.page.SecurePortalWithCustomSessionConfig;
import org.keycloak.testsuite.adapter.page.TokenMinTTLPage;
import org.keycloak.testsuite.admin.ApiUtil;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.auth.page.account.Applications;
import org.keycloak.testsuite.auth.page.login.OAuthGrant;
import org.keycloak.testsuite.auth.page.login.OIDCLogin;

View file

@ -30,7 +30,7 @@ import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest;
import org.keycloak.testsuite.adapter.page.MultiTenant;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.util.URLAssert;
import org.keycloak.testsuite.util.WaitUtils;

View file

@ -59,7 +59,7 @@ import org.keycloak.testsuite.adapter.page.SecurePortal;
import org.keycloak.testsuite.adapter.page.TokenMinTTLPage;
import org.keycloak.testsuite.admin.ApiUtil;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.util.URLAssert;
import org.openqa.selenium.By;

View file

@ -17,7 +17,7 @@ import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest;
import org.keycloak.testsuite.adapter.filter.AdapterActionsFilter;
import org.keycloak.testsuite.adapter.page.OfflineToken;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.pages.AccountApplicationsPage;
import org.keycloak.testsuite.pages.LoginPage;
import org.keycloak.testsuite.pages.OAuthGrantPage;

View file

@ -8,7 +8,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.utils.annotation.UseServletFilter;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
/**
* @author mhajas

View file

@ -137,7 +137,7 @@ import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest;
import org.keycloak.testsuite.adapter.page.*;
import org.keycloak.testsuite.admin.ApiUtil;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.auth.page.login.Login;
import org.keycloak.testsuite.auth.page.login.SAMLIDPInitiatedLogin;
import org.keycloak.testsuite.auth.page.login.SAMLPostLoginTenant1;

View file

@ -42,7 +42,7 @@ import org.keycloak.testsuite.adapter.page.CustomerPortalSubsystem;
import org.keycloak.testsuite.adapter.page.ProductPortalSubsystem;
import org.keycloak.testsuite.arquillian.AppServerTestEnricher;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.arquillian.containers.SelfManagedAppContainerLifecycle;
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)

View file

@ -34,7 +34,7 @@ import org.keycloak.testsuite.adapter.page.SessionPortal;
import org.keycloak.testsuite.auth.page.account.Sessions;
import org.keycloak.testsuite.auth.page.login.Login;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.util.SecondBrowser;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

View file

@ -50,7 +50,7 @@ import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest;
import org.keycloak.testsuite.adapter.page.ProductPortal;
import org.keycloak.testsuite.admin.ApiUtil;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.auth.page.login.PageWithLoginUrl;
import org.keycloak.testsuite.federation.UserMapStorageFactory;
import org.keycloak.testsuite.pages.ConsentPage;

View file

@ -43,7 +43,7 @@ import org.keycloak.testsuite.adapter.AbstractAdapterClusteredTest;
import org.keycloak.testsuite.adapter.page.SessionPortalDistributable;
import org.keycloak.testsuite.adapter.servlet.SessionServlet;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.auth.page.AuthRealm;
import org.keycloak.testsuite.auth.page.login.OIDCLogin;
import org.keycloak.testsuite.util.DroneUtils;

View file

@ -24,7 +24,7 @@ import org.keycloak.testsuite.adapter.AbstractSAMLAdapterClusteredTest;
import org.keycloak.testsuite.adapter.page.EmployeeServletDistributable;
import org.keycloak.testsuite.adapter.servlet.SendUsernameServlet;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
/**
*

View file

@ -27,7 +27,7 @@ import org.keycloak.testsuite.adapter.AbstractSAMLAdapterClusteredTest;
import org.keycloak.testsuite.adapter.servlet.SendUsernameServlet;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.annotation.InitialDcState;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.crossdc.ServerSetup;
import static org.hamcrest.Matchers.is;

View file

@ -3,7 +3,7 @@ package org.keycloak.testsuite.adapter.servlet.jetty;
import org.junit.Ignore;
import org.keycloak.testsuite.adapter.servlet.DemoServletsAdapterTest;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
@AppServerContainer(ContainerConstants.APP_SERVER_JETTY94)
@AppServerContainer(ContainerConstants.APP_SERVER_JETTY93)

View file

@ -3,7 +3,7 @@ package org.keycloak.testsuite.adapter.servlet.jetty;
import org.junit.Ignore;
import org.keycloak.testsuite.adapter.servlet.SAMLServletAdapterTest;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
@AppServerContainer(ContainerConstants.APP_SERVER_JETTY94)
@AppServerContainer(ContainerConstants.APP_SERVER_JETTY93)

View file

@ -1475,12 +1475,6 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>1.2.0</version>
</dependency>
<!-- Email Test Server -->
<dependency>
<groupId>com.icegreen</groupId>

View file

@ -87,5 +87,20 @@
<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
</project>

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.testsuite.arquillian.containers;
package org.keycloak.testsuite.utils.arquillian;
public interface ContainerConstants {
public static final String APP_SERVER_PREFIX = "app-server-";

View file

@ -0,0 +1,271 @@
/*
* Copyright 2019 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.testsuite.utils.fuse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.EnumSet;
import java.util.Set;
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.channel.ChannelExec;
import org.apache.sshd.client.channel.ClientChannelEvent;
import org.apache.sshd.client.future.ConnectFuture;
import org.apache.sshd.client.session.ClientSession;
import org.jboss.arquillian.core.spi.Validate;
import org.jboss.logging.Logger;
import org.junit.Assert;
import static org.hamcrest.Matchers.*;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
public class FuseUtils {
private static final Logger log = Logger.getLogger(FuseUtils.class);
private static boolean initiated = false;
private static final String managementUser = System.getProperty("app.server.management.user", "admin");
private static final String managementPassword = System.getProperty("app.server.management.password", "password");
private static final String additionalFuseRepos = System.getProperty("additional.fuse.repos");
private static final String userHome = System.getProperty("user.home");
private static final String projectVersion = System.getProperty("project.version");
private static final String mvnRepoLocal;
private static final String mvnLocalSettings;
public enum Result { OK, NOT_FOUND, NO_CREDENTIALS, NO_ROLES, EMPTY };
static {
Validate.notNullOrEmpty(managementUser, "app.server.management.user is not set.");
Validate.notNullOrEmpty(managementPassword, "app.server.management.password is not set.");
Validate.notNullOrEmpty(additionalFuseRepos, "additional.fuse.repos is not set.");
mvnRepoLocal = System.getProperty("maven.repo.local", userHome + "/.m2/repository");
mvnLocalSettings = System.getProperty("maven.local.settings", userHome + "/.m2/settings.xml");
}
public static void setUpFuse(String appServer) throws IOException {
if (!initiated) {
switch (appServer) {
case ContainerConstants.APP_SERVER_FUSE7X :
setUpFuse7();
break;
case ContainerConstants.APP_SERVER_FUSE63 :
setUpFuse6();
break;
default:
throw new UnsupportedOperationException(appServer + " is not supported!");
}
initiated = true;
}
}
private static void setUpFuse7() throws IOException {
log.debug("Going to set up fuse server");
assertCommand(managementUser, managementPassword,
"config:edit org.ops4j.pax.url.mvn; " +
"config:property-set org.ops4j.pax.url.mvn.localRepository " + mvnRepoLocal + "; " +
"config:property-set org.ops4j.pax.url.mvn.settings " + mvnLocalSettings + "; " +
"config:property-append org.ops4j.pax.url.mvn.repositories " + additionalFuseRepos + "; " +
"config:update",
Result.EMPTY);
assertCommand(managementUser, managementPassword,
"config:edit jmx.acl.org.apache.karaf.security.jmx; " +
"config:property-append list* viewer; " +
"config:property-append set* jmxAdmin; " +
"config:property-append * jmxAdmin,admin; " +
"config:update",
Result.EMPTY);
assertCommand(managementUser, managementPassword,
"feature:repo-add mvn:org.keycloak/keycloak-osgi-features/" + projectVersion + "/xml/features; " +
"feature:repo-add mvn:org.keycloak.testsuite/fuse-example-keycloak-features/" + projectVersion + "/xml/features; " +
"feature:install pax-http-undertow; " +
"feature:install keycloak-jaas keycloak-pax-http-undertow; " +
"feature:install keycloak-fuse-7.0-example",
Result.OK);
assertCommand(managementUser, managementPassword,
"config:edit --factory --alias cxf org.ops4j.pax.web.context; " +
"config:property-set bundle.symbolicName org.apache.cxf.cxf-rt-transports-http; " +
"config:property-set context.id default; " +
"config:property-set context.param.keycloak.config.resolver org.keycloak.adapters.osgi.HierarchicalPathBasedKeycloakConfigResolver; " +
"config:property-set login.config.authMethod KEYCLOAK; " +
"config:property-set security.cxf.url /cxf/customerservice/*; " +
"config:property-set security.cxf.roles \"admin, user\"; " +
"config:update",
Result.EMPTY);
assertCommand(managementUser, managementPassword,
"system:property -p hawtio.keycloakEnabled true; " +
"system:property -p hawtio.realm keycloak; " +
"system:property -p hawtio.keycloakClientConfig ${karaf.etc}/keycloak-hawtio-client.json; " +
"system:property -p hawtio.keycloakServerConfig ${karaf.etc}/keycloak-bearer.json; " +
"system:property -p hawtio.roles admin,manager,viewer,ssh; " +
"system:property -p hawtio.rolePrincipalClasses org.keycloak.adapters.jaas.RolePrincipal,org.apache.karaf.jaas.boot.principal.RolePrincipal;" +
"restart io.hawt.hawtio-war",
Result.EMPTY);
assertCommand(managementUser, managementPassword,
"config:edit org.apache.karaf.management; " +
"config:property-set jmxRealm keycloak;" +
"config:update",
Result.EMPTY);
assertCommand(managementUser, managementPassword,
"config:edit org.apache.karaf.shell; " +
"config:property-set sshRealm keycloak; " +
"config:update",
Result.EMPTY);
log.debug("Fuse server should be ready");
}
private static void setUpFuse6() throws IOException {
log.debug("Going to set up fuse server");
assertCommand(managementUser, managementPassword,
"config:edit org.ops4j.pax.url.mvn; " +
"config:propset org.ops4j.pax.url.mvn.localRepository " + mvnRepoLocal + "; " +
"config:propset org.ops4j.pax.url.mvn.settings " + mvnLocalSettings + "; " +
"config:propappend org.ops4j.pax.url.mvn.repositories " + additionalFuseRepos + "; " +
"config:update",
Result.EMPTY);
assertCommand(managementUser, managementPassword,
"config:edit jmx.acl.org.apache.karaf.security.jmx; " +
"config:propappend list* viewer; " +
"config:propappend set* jmxAdmin; " +
"config:propappend * jmxAdmin,admin; " +
"config:update",
Result.EMPTY);
assertCommand(managementUser, managementPassword,
"features:addurl mvn:org.keycloak/keycloak-osgi-features/" + projectVersion + "/xml/features; " +
"features:addurl mvn:org.keycloak.testsuite/fuse-example-keycloak-features/" + projectVersion + "/xml/features; " +
"features:install keycloak-fuse-6.3-example",
Result.OK);
String appServerHome = System.getProperty("app.server.home");
Validate.notNullOrEmpty(appServerHome, "app.server.home is not set.");
assertCommand(managementUser, managementPassword,
"system-property -p hawtio.roles admin,user; " +
"system-property -p hawtio.keycloakEnabled true; " +
"system-property -p hawtio.realm keycloak; " +
"system-property -p hawtio.keycloakClientConfig file://" + appServerHome + "/etc/keycloak-hawtio-client.json; " +
"system-property -p hawtio.rolePrincipalClasses org.keycloak.adapters.jaas.RolePrincipal,org.apache.karaf.jaas.boot.principal.RolePrincipal; ",
Result.EMPTY);
String output = getCommandOutput(managementUser, managementPassword, "osgi:list | grep hawtio | grep web;");
Assert.assertThat(output, containsString("hawtio"));
String id = output.substring(output.indexOf("[") + 1, output.indexOf("]")).trim();
log.debug("osgi hawtio-web id: " + id);
assertCommand(managementUser, managementPassword,
"osgi:restart " + id,
Result.EMPTY);
assertCommand(managementUser, managementPassword,
"config:edit org.apache.karaf.management; " +
"config:propset jmxRealm keycloak;" +
"config:update",
Result.EMPTY);
assertCommand(managementUser, managementPassword,
"config:edit org.apache.karaf.shell; " +
"config:propset sshRealm keycloak; " +
"config:update",
Result.EMPTY);
log.debug("Fuse server should be ready");
}
public static String assertCommand(String user, String password, String command, Result result) throws IOException {
if (!command.endsWith("\n"))
command += "\n";
String output = getCommandOutput(user, password, command);
log.debug("Command: " + command + ", user: " + user + ", password: " + password + ", output: " + output);
switch(result) {
case EMPTY:
Assert.assertThat(output, isEmptyString());
break;
case OK:
Assert.assertThat(output,
not(anyOf(
containsString("Insufficient credentials"),
containsString("Command not found"),
containsString("Error executing command"),
containsString("Authentication failed"))
));
break;
case NOT_FOUND:
Assert.assertThat(output,
containsString("Command not found"));
break;
case NO_CREDENTIALS:
Assert.assertThat(output,
containsString("Insufficient credentials"));
break;
case NO_ROLES:
Assert.assertThat(output,
containsString("Current user has no associated roles"));
break;
default:
Assert.fail("Unexpected enum value: " + result);
}
return output;
}
public static String getCommandOutput(String user, String password, String command) throws IOException {
if (!command.endsWith("\n"))
command += "\n";
try (ClientSession session = openSshChannel(user, password);
ChannelExec channel = session.createExecChannel(command);
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
channel.setOut(out);
channel.setErr(out);
channel.open();
channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED, ClientChannelEvent.EOF), 0);
return new String(out.toByteArray());
}
}
private static ClientSession openSshChannel(String username, String password) throws IOException {
SshClient client = SshClient.setUpDefaultClient();
client.start();
ConnectFuture future = client.connect(username, "localhost", 8101);
future.await();
ClientSession session = future.getSession();
Set<ClientSession.ClientSessionEvent> ret = EnumSet.of(ClientSession.ClientSessionEvent.WAIT_AUTH);
while (ret.contains(ClientSession.ClientSessionEvent.WAIT_AUTH)) {
session.addPasswordIdentity(password);
session.auth().verify();
ret = session.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.WAIT_AUTH, ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.AUTHED), 0);
}
if (ret.contains(ClientSession.ClientSessionEvent.CLOSED)) {
throw new RuntimeException("Could not open SSH channel");
}
return session;
}
}