From 496c6d598ebc04c3d3c07aef27017ffb6c13879c Mon Sep 17 00:00:00 2001 From: mposolda Date: Tue, 3 Jan 2023 07:26:11 +0100 Subject: [PATCH] Some authorization adapter test failing on Java 17 Closes #16216 --- .../testsuite/example/WebAppHelper.java | 34 +++++++++++++++++++ .../src/main/webapp/error.jsp | 10 ++---- .../src/main/webapp/index.jsp | 8 ++--- .../testsuite/servletauthz/WebAppHelper.java | 33 ++++++++++++++++++ .../src/main/webapp/logout-include.jsp | 10 ++---- .../testsuite/example/WebAppHelper.java | 33 ++++++++++++++++++ .../src/main/webapp/logout-include.jsp | 10 ++---- 7 files changed, 108 insertions(+), 30 deletions(-) create mode 100644 testsuite/integration-arquillian/test-apps/hello-world-authz-service/src/main/java/org/keycloak/testsuite/example/WebAppHelper.java create mode 100644 testsuite/integration-arquillian/test-apps/servlet-authz/src/main/java/org/keycloak/testsuite/servletauthz/WebAppHelper.java create mode 100644 testsuite/integration-arquillian/test-apps/servlet-policy-enforcer/src/main/java/org/keycloak/testsuite/example/WebAppHelper.java diff --git a/testsuite/integration-arquillian/test-apps/hello-world-authz-service/src/main/java/org/keycloak/testsuite/example/WebAppHelper.java b/testsuite/integration-arquillian/test-apps/hello-world-authz-service/src/main/java/org/keycloak/testsuite/example/WebAppHelper.java new file mode 100644 index 0000000000..b9b2da4091 --- /dev/null +++ b/testsuite/integration-arquillian/test-apps/hello-world-authz-service/src/main/java/org/keycloak/testsuite/example/WebAppHelper.java @@ -0,0 +1,34 @@ +/* + * Copyright 2023 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.example; + +/** + * @author Marek Posolda + */ +public class WebAppHelper { + + public static String getAuthUri() { + boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true")); + String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180"); + String authScheme = isTLSEnabled ? "https" : "http"; + return authScheme + "://localhost:" + authPort + "/auth"; + } + +} diff --git a/testsuite/integration-arquillian/test-apps/hello-world-authz-service/src/main/webapp/error.jsp b/testsuite/integration-arquillian/test-apps/hello-world-authz-service/src/main/webapp/error.jsp index 4ac61c3cf0..6db51a452c 100644 --- a/testsuite/integration-arquillian/test-apps/hello-world-authz-service/src/main/webapp/error.jsp +++ b/testsuite/integration-arquillian/test-apps/hello-world-authz-service/src/main/webapp/error.jsp @@ -18,17 +18,11 @@ <%@ page import="org.keycloak.common.util.KeycloakUriBuilder" %> <%@ page import="org.keycloak.constants.ServiceUrlConstants" %> - -<% - boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true")); - String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180"); - String authScheme = isTLSEnabled ? "https" : "http"; - String authUri = authScheme + "://localhost:" + authPort + "/auth"; -%> +<%@ page import="org.keycloak.testsuite.example.WebAppHelper" %> -

">Logout

Access Denied !

diff --git a/testsuite/integration-arquillian/test-apps/hello-world-authz-service/src/main/webapp/index.jsp b/testsuite/integration-arquillian/test-apps/hello-world-authz-service/src/main/webapp/index.jsp index 4db42a7cce..e415033ca0 100644 --- a/testsuite/integration-arquillian/test-apps/hello-world-authz-service/src/main/webapp/index.jsp +++ b/testsuite/integration-arquillian/test-apps/hello-world-authz-service/src/main/webapp/index.jsp @@ -20,20 +20,16 @@ <%@ page import="org.keycloak.common.util.KeycloakUriBuilder" %> <%@ page import="org.keycloak.constants.ServiceUrlConstants" %> <%@ page import="org.keycloak.representations.idm.authorization.Permission" %> +<%@ page import="org.keycloak.testsuite.example.WebAppHelper" %> <% KeycloakSecurityContext keycloakSecurityContext = (KeycloakSecurityContext) request.getAttribute(KeycloakSecurityContext.class.getName()); AuthorizationContext authzContext = keycloakSecurityContext.getAuthorizationContext(); - - boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true")); - String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180"); - String authScheme = isTLSEnabled ? "https" : "http"; - String authUri = authScheme + "://localhost:" + authPort + "/auth"; %>

Welcome !

-

">Logout

Your permissions are:

diff --git a/testsuite/integration-arquillian/test-apps/servlet-authz/src/main/java/org/keycloak/testsuite/servletauthz/WebAppHelper.java b/testsuite/integration-arquillian/test-apps/servlet-authz/src/main/java/org/keycloak/testsuite/servletauthz/WebAppHelper.java new file mode 100644 index 0000000000..4c99c446a6 --- /dev/null +++ b/testsuite/integration-arquillian/test-apps/servlet-authz/src/main/java/org/keycloak/testsuite/servletauthz/WebAppHelper.java @@ -0,0 +1,33 @@ +/* + * Copyright 2023 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.servletauthz; + +/** + * @author Marek Posolda + */ +public class WebAppHelper { + + public static String getAuthUri() { + boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true")); + String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180"); + String authScheme = isTLSEnabled ? "https" : "http"; + return authScheme + "://localhost:" + authPort + "/auth"; + } +} diff --git a/testsuite/integration-arquillian/test-apps/servlet-authz/src/main/webapp/logout-include.jsp b/testsuite/integration-arquillian/test-apps/servlet-authz/src/main/webapp/logout-include.jsp index 6a33abc38b..854ab31e39 100644 --- a/testsuite/integration-arquillian/test-apps/servlet-authz/src/main/webapp/logout-include.jsp +++ b/testsuite/integration-arquillian/test-apps/servlet-authz/src/main/webapp/logout-include.jsp @@ -1,18 +1,12 @@ <%@ page import="org.keycloak.common.util.KeycloakUriBuilder" %> <%@ page import="org.keycloak.constants.ServiceUrlConstants" %> +<%@ page import="org.keycloak.testsuite.servletauthz.WebAppHelper" %> <% String scheme = request.getScheme(); String host = request.getServerName(); int port = request.getServerPort(); String contextPath = request.getContextPath(); String redirectUri = scheme + "://" + host + ":" + port + contextPath; - - - boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true")); - String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180"); - String authScheme = isTLSEnabled ? "https" : "http"; - String authHost = System.getProperty("auth.server.host", "localhost"); - String authUri = authScheme + "://" + authHost + ":" + authPort + "/auth"; %> -

Click here ">Sign Out

\ No newline at end of file diff --git a/testsuite/integration-arquillian/test-apps/servlet-policy-enforcer/src/main/java/org/keycloak/testsuite/example/WebAppHelper.java b/testsuite/integration-arquillian/test-apps/servlet-policy-enforcer/src/main/java/org/keycloak/testsuite/example/WebAppHelper.java new file mode 100644 index 0000000000..238c95ba99 --- /dev/null +++ b/testsuite/integration-arquillian/test-apps/servlet-policy-enforcer/src/main/java/org/keycloak/testsuite/example/WebAppHelper.java @@ -0,0 +1,33 @@ +/* + * Copyright 2023 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.example; + +/** + * @author Marek Posolda + */ +public class WebAppHelper { + + public static String getAuthUri() { + boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true")); + String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180"); + String authScheme = isTLSEnabled ? "https" : "http"; + return authScheme + "://localhost:" + authPort + "/auth"; + } +} diff --git a/testsuite/integration-arquillian/test-apps/servlet-policy-enforcer/src/main/webapp/logout-include.jsp b/testsuite/integration-arquillian/test-apps/servlet-policy-enforcer/src/main/webapp/logout-include.jsp index 5da96b59c3..3185ca68e2 100644 --- a/testsuite/integration-arquillian/test-apps/servlet-policy-enforcer/src/main/webapp/logout-include.jsp +++ b/testsuite/integration-arquillian/test-apps/servlet-policy-enforcer/src/main/webapp/logout-include.jsp @@ -1,18 +1,12 @@ <%@ page import="org.keycloak.common.util.KeycloakUriBuilder" %> <%@ page import="org.keycloak.constants.ServiceUrlConstants" %> +<%@ page import="org.keycloak.testsuite.example.WebAppHelper" %> <% String scheme = request.getScheme(); String host = request.getServerName(); int port = request.getServerPort(); String contextPath = request.getContextPath(); String redirectUri = scheme + "://" + host + ":" + port + contextPath; - - - boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true")); - String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180"); - String authScheme = isTLSEnabled ? "https" : "http"; - String authHost = System.getProperty("auth.server.host", "localhost"); - String authUri = authScheme + "://" + authHost + ":" + authPort + "/auth"; %> -

Click here ">Sign Out

\ No newline at end of file