keycloak-uncached

Details

diff --git a/services/src/main/java/org/keycloak/url/FixedHostnameProvider.java b/services/src/main/java/org/keycloak/url/FixedHostnameProvider.java
index d871270..b6b5f9c 100644
--- a/services/src/main/java/org/keycloak/url/FixedHostnameProvider.java
+++ b/services/src/main/java/org/keycloak/url/FixedHostnameProvider.java
@@ -34,7 +34,24 @@ public class FixedHostnameProvider implements HostnameProvider {
 
     @Override
     public int getPort(UriInfo originalUriInfo) {
-        return originalUriInfo.getRequestUri().getScheme().equals("https") ? httpsPort : httpPort;
+        boolean https = originalUriInfo.getRequestUri().getScheme().equals("https");
+        if (https) {
+            if (httpsPort == -1) {
+                return originalUriInfo.getRequestUri().getPort();
+            } else if (httpsPort == 443) {
+                return -1;
+            } else {
+                return httpsPort;
+            }
+        } else {
+            if (httpPort == -1) {
+                return originalUriInfo.getRequestUri().getPort();
+            } else if (httpPort == 80) {
+                return -1;
+            } else {
+                return httpPort;
+            }
+        }
     }
 
 }
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/url/FixedHostnameTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/url/FixedHostnameTest.java
index 4b4828c..518e795 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/url/FixedHostnameTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/url/FixedHostnameTest.java
@@ -114,9 +114,9 @@ public class FixedHostnameTest extends AbstractKeycloakTest {
 
     private void configureFixedHostname() throws Exception {
         if (suiteContext.getAuthServerInfo().isUndertow()) {
-            configureUndertow("fixed", "keycloak.127.0.0.1.nip.io", "8180", "8543");
+            configureUndertow("fixed", "keycloak.127.0.0.1.nip.io");
         } else if (suiteContext.getAuthServerInfo().isJBossBased()) {
-            configureWildFly("fixed", "keycloak.127.0.0.1.nip.io", "8180", "8543");
+            configureWildFly("fixed", "keycloak.127.0.0.1.nip.io");
         } else {
             throw new RuntimeException("Don't know how to config");
         }
@@ -127,9 +127,9 @@ public class FixedHostnameTest extends AbstractKeycloakTest {
 
     private void clearFixedHostname() throws Exception {
         if (suiteContext.getAuthServerInfo().isUndertow()) {
-            configureUndertow("request", "localhost", "-1", "-1");
+            configureUndertow("request", "localhost");
         } else if (suiteContext.getAuthServerInfo().isJBossBased()) {
-            configureWildFly("request", "localhost", "-1", "-1");
+            configureWildFly("request", "localhost");
         } else {
             throw new RuntimeException("Don't know how to config");
         }
@@ -137,25 +137,21 @@ public class FixedHostnameTest extends AbstractKeycloakTest {
         reconnectAdminClient();
     }
 
-    private void configureUndertow(String provider, String hostname, String httpPort, String httpsPort) {
+    private void configureUndertow(String provider, String hostname) {
         controller.stop(suiteContext.getAuthServerInfo().getQualifier());
 
         System.setProperty("keycloak.hostname.provider", provider);
         System.setProperty("keycloak.hostname.fixed.hostname", hostname);
-        System.setProperty("keycloak.hostname.fixed.httpPort", httpPort);
-        System.setProperty("keycloak.hostname.fixed.httpsPort", httpsPort);
 
         controller.start(suiteContext.getAuthServerInfo().getQualifier());
     }
 
-    private void configureWildFly(String provider, String hostname, String httpPort, String httpsPort) throws Exception {
+    private void configureWildFly(String provider, String hostname) throws Exception {
         OnlineManagementClient client = AuthServerTestEnricher.getManagementClient();
         Administration administration = new Administration(client);
 
         client.execute("/subsystem=keycloak-server/spi=hostname:write-attribute(name=default-provider, value=" + provider + ")");
         client.execute("/subsystem=keycloak-server/spi=hostname/provider=fixed:write-attribute(name=properties.hostname,value=" + hostname + ")");
-        client.execute("/subsystem=keycloak-server/spi=hostname/provider=fixed:write-attribute(name=properties.httpPort,value=" + httpPort + ")");
-        client.execute("/subsystem=keycloak-server/spi=hostname/provider=fixed:write-attribute(name=properties.httpsPort,value=" + httpsPort + ")");
 
         administration.reloadIfRequired();