8000 Use EventAssertion in some remaining tests and downgrade java to 21 for FIPS by rmartinc · Pull Request #49143 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/scripts/run-fips-it.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env bash
set -x

JAVA_VERSION=21

rm -f /etc/system-fips
dnf install -y java-25-openjdk-devel
dnf install -y "java-${JAVA_VERSION}-openjdk-devel"
fips-mode-setup --enable --no-bootcfg
fips-mode-setup --check | grep "FIPS mode is enabled."
if [ $? -ne 0 ]; then
Expand All @@ -21,7 +23,7 @@ if [ $? -ne 0 ]; then
exit 1
fi
echo "Tests: $TESTS"
export JAVA_HOME=/etc/alternatives/java_sdk_25
export JAVA_HOME="/etc/alternatives/java_sdk_${JAVA_VERSION}"
set -o pipefail

# Build adapter distributions
Expand All @@ -43,10 +45,10 @@ if [ $? -ne 0 ]; then
fi

# Profile app-server-wildfly needs to be explicitly set for FIPS tests
./mvnw test -Dsurefire.rerunFailingTestsCount=$SUREFIRE_RERUN_FAILING_COUNT -nsu -B -Pauth-server-quarkus,auth-server-fips140-2,app-server-wildfly -Dredhat.crypto-policies=false $STRICT_OPTIONS -Dtest=$TESTS -pl testsuite/integration-arquillian/tests/base 2>&1 | misc/log/trimmer.sh
./mvnw test -Dsurefire.rerunFailingTestsCount=$SUREFIRE_RERUN_FAILING_COUNT -nsu -B -Pauth-server-quarkus,auth-server-fips140-2,app-server-wildfly -Dcom.redhat.fips=false -Dredhat.crypto-policies=false $STRICT_OPTIONS -Dtest=$TESTS -pl testsuite/integration-arquillian/tests/base 2>&1 | misc/log/trimmer.sh
if [ $? -ne 0 ]; then
exit 1
fi

# New Base Tests
./mvnw package -nsu -B -Dredhat.crypto-policies=false -Dtest=$TESTSUITE_NAME -pl tests/base
./mvnw package -nsu -B -Dcom.redhat.fips=false -Dredhat.crypto-policies=false -Dtest=$TESTSUITE_NAME -pl tests/base
10 changes: 6 additions & 4 deletions .github/scripts/run-fips-ut.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#!/usr/bin/env bash

JAVA_VERSION=21

rm -f /etc/system-fips
dnf install -y java-25-openjdk-devel crypto-policies-scripts
dnf install -y "java-${JAVA_VERSION}-openjdk-devel"
fips-mode-setup --enable --no-bootcfg
fips-mode-setup --check | grep "FIPS mode is enabled."
if [ $? -ne 0 ]; then
exit 1
fi
export JAVA_HOME=/etc/alternatives/java_sdk_25
export JAVA_HOME="/etc/alternatives/java_sdk_${JAVA_VERSION}"

# Build all dependent modules
./mvnw install -nsu -B -am -pl crypto/default,crypto/fips1402 -DskipTests

./mvnw test -nsu -B -pl crypto/default,crypto/fips1402 -Dredhat.crypto-policies=true
./mvnw test -nsu -B -pl crypto/default,crypto/fips1402 -Dcom.redhat.fips=true -Dredhat.crypto-policies=true
if [ $? -ne 0 ]; then
exit 1
fi

./mvnw test -nsu -B -pl crypto/default,crypto/fips1402 -Dredhat.crypto-policies=true -Dorg.bouncycastle.fips.approved_only=true
./mvnw test -nsu -B -pl crypto/default,crypto/fips1402 -Dcom.redhat.fips=true -Dredhat.crypto-policies=true -Dorg.bouncycastle.fips.approved_only=true
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.keycloak.testframework.events.EventAssertion;
import org.keycloak.testframework.realm.UserBuilder;
import org.keycloak.testsuite.ActionURIUtils;
import org.keycloak.testsuite.AssertEvents;
import org.keycloak.testsuite.admin.AdminApiUtil;
import org.keycloak.testsuite.pages.ErrorPage;
import org.keycloak.testsuite.pages.LoginConfigTotpPage;
Expand Down Expand Up @@ -515,14 +514,14 @@ public void updatePasswordDifferentAuthSession() throws Exception {
+ "auth_session_id=" + authSessionId))) {
Assert.assertEquals(302, response2.getStatusLine().getStatusCode());
}
events.expect(EventType.RESTART_AUTHENTICATION).user((String) null).assertEvent();
EventAssertion.assertSuccess(events.poll()).type(EventType.RESTART_AUTHENTICATION).userId(null);

// authenticate the user in the browser
oauth.openLoginForm();
loginPage.assertCurrent();
loginPage.login("test-user@localhost", "password");
appPage.assertCurrent();
events.expectLogin().user(AssertEvents.isUUID()).detail(Details.USERNAME, "test-user@localhost").assertEvent();
EventAssertion.expectLoginSuccess(events.poll()).hasUserId().details(Details.USERNAME, "test-user@localhost");

// navigate to the authenticate page with the other auth_session_id, tab_id and client_data
driver.navigate().to(oauth.getBaseUrl() + "/realms/" + oauth.getRealm()
Expand All @@ -531,8 +530,8 @@ public void updatePasswordDifferentAuthSession() throws Exception {
+ "&tab_id=" + attrs.get("tab_id")
+ "&client_data=" + attrs.get("client_data"));
errorPage.assertCurrent();
events.expect(EventType.LOGIN_ERROR).error(Errors.INVALID_CODE).user((String) null)
.detail(Details.REASON, "cookie does not match auth_session query parameter").assertEvent();
EventAssertion.assertError(events.poll()).type(EventType.LOGIN_ERROR).error(Errors.INVALID_CODE).userId(null)
.details(Details.REASON, "cookie does not match auth_session query parameter");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,13 +745,12 @@ public void testNotBeforeTokens() {

assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());

events.expect(EventType.USER_INFO_REQUEST_ERROR)
EventAssertion.assertError(events.poll()).type(EventType.US 6C72 ER_INFO_REQUEST_ERROR)
.error(Errors.INVALID_TOKEN)
.user(Matchers.nullValue(String.class))
.session(Matchers.nullValue(String.class))
.detail(Details.AUTH_METHOD, Details.VALIDATE_ACCESS_TOKEN)
.client((String) null)
.assertEvent();
.userId(null)
.sessionId(null)
.details(Details.AUTH_METHOD, Details.VALIDATE_ACCESS_TOKEN)
.clientId(null);

rep.setNotBefore(0);
realm.update(rep);
Expand Down
Loading
0