fix: using localtest.me instead of nip.io

closes: #40645

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
Steven Hawkins 2025-07-26 05:36:01 -04:00 committed by GitHub
parent 4b51a2ea36
commit 10947d002f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 34 additions and 34 deletions

View File

@ -1,5 +1,5 @@
name: Update /etc/hosts
description: Update /etc/hosts file to hardcode known nip.io hostnames. This is to avoid test instability due to DNS resolution issues.
description: Update /etc/hosts file to hardcode known hostnames. This is to avoid test instability due to DNS resolution issues.
runs:
using: composite
@ -10,7 +10,7 @@ runs:
if: runner.os == 'Linux'
shell: bash
run: |
printf "\n\n$(cat .github/actions/update-hosts/nipio-hosts)" | sudo tee -a /etc/hosts
printf "\n\n$(cat .github/actions/update-hosts/hosts)" | sudo tee -a /etc/hosts
- id: update-hosts-windows
name: Update C:\Windows\System32\drivers\etc\hosts
@ -18,4 +18,4 @@ runs:
shell: powershell
run: |
"`n`n" | Add-Content C:\Windows\System32\drivers\etc\hosts
Get-Content .github/actions/update-hosts/nipio-hosts | Add-Content C:\Windows\System32\drivers\etc\hosts
Get-Content .github/actions/update-hosts/hosts | Add-Content C:\Windows\System32\drivers\etc\hosts

2
.github/actions/update-hosts/hosts vendored Normal file
View File

@ -0,0 +1,2 @@
127.0.0.1 localtest.me admin.localtest.me localhost-myapp.localtest.me localhost-sso.localtest.me realmFrontend.localtest.me proxy.kc.localtest.me
::1 localtest.me admin.localtest.me localhost-myapp.localtest.me localhost-sso.localtest.me realmFrontend.localtest.me proxy.kc.localtest.me

View File

@ -1,2 +0,0 @@
127.0.0.1 localtest.me 127.0.0.1.nip.io admin.127.0.0.1.nip.io localhost-myapp.127.0.0.1.nip.io localhost-sso.127.0.0.1.nip.io realmFrontend.127.0.0.1.nip.io proxy.kc.127.0.0.1.nip.io
::1 localtest.me 127.0.0.1.nip.io admin.127.0.0.1.nip.io localhost-myapp.127.0.0.1.nip.io localhost-sso.127.0.0.1.nip.io realmFrontend.127.0.0.1.nip.io proxy.kc.127.0.0.1.nip.io

View File

@ -39,13 +39,13 @@ import org.keycloak.testframework.server.KeycloakServerConfigBuilder;
@KeycloakIntegrationTest(config = AdminRootEdgeTest.AdminUrlConfig.class)
public class AdminRootEdgeTest {
// full url with https, with default hostname-admin
private static final String HOSTNAME = "https://127.0.0.1.nip.io:8080";
private static final String HOSTNAME = "https://localtest.me:8080";
@InjectHttpClient(followRedirects = false)
private HttpClient client;
@ParameterizedTest
@ValueSource(strings = {"http://127.0.0.1:8080", "http://127.0.0.1.nip.io:8080"})
@ValueSource(strings = {"http://127.0.0.1:8080", "http://localtest.me:8080"})
public void testRedirect(String hostname) throws Exception {
HttpResponse response = client.execute(new HttpGet(hostname + "/admin"));

View File

@ -45,8 +45,8 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
@KeycloakIntegrationTest(config = AdminRootTest.AdminUrlConfig.class)
public class AdminRootTest {
// This might not be robust enough. If something made KC on a different port, this would fail.
private static final String HOSTNAME = "http://127.0.0.1.nip.io:8080";
private static final String HOSTNAME_ADMIN = "http://admin.127.0.0.1.nip.io:8080";
private static final String HOSTNAME = "http://localtest.me:8080";
private static final String HOSTNAME_ADMIN = "http://admin.localtest.me:8080";
private static final String HOSTNAME_LOCAL_ADMIN = "http://localhost:8080";
@InjectHttpClient(followRedirects = false)

View File

@ -567,8 +567,8 @@ More info: http://javahowto.blogspot.cz/2010/09/java-agentlibjdwp-for-attaching.
In order to reproduce some specific cookies behaviour in browsers (like SameSite policies or 3rd party cookie blocking),
some subset of tests needs to be ran with different hosts for auth server and app/IdP server in order to simulate third
party contexts. Those hosts must be different from localhost as that host has some special treatment from browsers. At
the same time both hosts must use different domains to be considered cross-origin, e.g. `127.0.0.1.nip.io` and
`127.0.0.1.xip.io`. NOT `app1.127.0.0.1.nip.io` and `app2.127.0.0.1.nip.io`!!
the same time both hosts must use different domains to be considered cross-origin, e.g. `localtest.me` and
`127.0.0.1.xip.io`. NOT `app1.localtest.me` and `app2.localtest.me`!!
Also, those new cookies policies are currently not yet enabled by default (which will change in the near future). To test
those policies, you need the latest stable Firefox together with `firefox-strict-cookies` profile. This profile sets the
@ -603,7 +603,7 @@ we rely on [nip.io](https://nip.io) for DNS switching, so tests will work everyw
### Tips & Tricks:
Although it _should_ work in general, you may experience an exception like this:
```
java.lang.RuntimeException: java.net.UnknownHostException: keycloak.127.0.0.1.nip.io: nodename nor servname provided,
java.lang.RuntimeException: java.net.UnknownHostException: keycloak.localtest.me: nodename nor servname provided,
or not known at org.keycloak.testsuite.util.OAuthClient.doWellKnownRequest(OAuthClient.java:1032)
at org.keycloak.testsuite.url.DefaultHostnameTest.assertBackendForcedToFrontendWithMatchingHostname(
DefaultHostnameTest.java:226)

View File

@ -67,7 +67,7 @@ public class DefaultCookieProviderTest extends AbstractKeycloakTest {
@Test
public void testCookieDefaultsWithInsecureContext() {
KeycloakTestingClient testingInsecure = KeycloakTestingClient.getInstance("http://127.0.0.1.nip.io:8180/auth");
KeycloakTestingClient testingInsecure = KeycloakTestingClient.getInstance("http://localtest.me:8180/auth");
Response response = testingInsecure.server("master").runWithResponse(session -> {
CookieProvider cookies = session.getProvider(CookieProvider.class);

View File

@ -88,8 +88,8 @@ public class LDAPSamlIdPInitiatedVaryingLetterCaseTest extends AbstractLDAPTest
private static final String MY_APP = "myapp";
private static final String EXT_SSO = "sso";
private static final String EXT_SSO_URL = "http://localhost-" + EXT_SSO + ".127.0.0.1.nip.io";
private static final String DUMMY_URL = "http://localhost-" + EXT_SSO + "-dummy.127.0.0.1.nip.io";
private static final String EXT_SSO_URL = "http://localhost-" + EXT_SSO + ".localtest.me";
private static final String DUMMY_URL = "http://localhost-" + EXT_SSO + "-dummy.localtest.me";
private static final String FLOW_AUTO_LINK = "AutoLink";
private String idpAlias;

View File

@ -53,7 +53,7 @@ import static org.keycloak.testsuite.util.ServerURLs.AUTH_SERVER_SCHEME;
*/
public class HostnameV2Test extends AbstractKeycloakTest {
private static final String realmFrontendName = "frontendUrlRealm";
private static final String realmFrontendUrl = "https://realmFrontend.127.0.0.1.nip.io:445";
private static final String realmFrontendUrl = "https://realmFrontend.localtest.me:445";
@Override
public void addTestRealms(List<RealmRepresentation> testRealms) {
@ -65,7 +65,7 @@ public class HostnameV2Test extends AbstractKeycloakTest {
@Test
public void testFixedFrontendHostname() {
String hostname = "127.0.0.1.nip.io";
String hostname = "localtest.me";
String dynamicUrl = getDynamicBaseUrl(hostname);
updateServerHostnameSettings(hostname, null, false, true);
@ -76,7 +76,7 @@ public class HostnameV2Test extends AbstractKeycloakTest {
@Test
public void testFixedFrontendHostnameUrl() {
String fixedUrl = "https://127.0.0.1.nip.io:444";
String fixedUrl = "https://localtest.me:444";
updateServerHostnameSettings(fixedUrl, null, false, true);
@ -86,8 +86,8 @@ public class HostnameV2Test extends AbstractKeycloakTest {
@Test
public void testFixedFrontendAndAdminHostnameUrl() {
String fixedFrontendUrl = "http://127.0.0.1.nip.io:444";
String fixedAdminUrl = "https://admin.127.0.0.1.nip.io:445";
String fixedFrontendUrl = "http://localtest.me:444";
String fixedAdminUrl = "https://admin.localtest.me:445";
updateServerHostnameSettings(fixedFrontendUrl, fixedAdminUrl, false, true);
@ -97,10 +97,10 @@ public class HostnameV2Test extends AbstractKeycloakTest {
@Test
public void testFixedFrontendHostnameUrlWithDefaultPort() {
String fixedFrontendUrl = "https://127.0.0.1.nip.io";
String fixedAdminUrl = "https://admin.127.0.0.1.nip.io";
String fixedFrontendUrl = "https://localtest.me";
String fixedAdminUrl = "https://admin.localtest.me";
updateServerHostnameSettings("https://127.0.0.1.nip.io:443", "https://admin.127.0.0.1.nip.io:443", false, true);
updateServerHostnameSettings("https://localtest.me:443", "https://admin.localtest.me:443", false, true);
testFrontendAndBackendUrls("master", fixedFrontendUrl, fixedFrontendUrl);
testAdminUrls("master", fixedFrontendUrl, fixedAdminUrl);
@ -108,7 +108,7 @@ public class HostnameV2Test extends AbstractKeycloakTest {
@Test
public void testDynamicBackend() {
String fixedUrl = "https://127.0.0.1.nip.io:444";
String fixedUrl = "https://localtest.me:444";
updateServerHostnameSettings(fixedUrl, null, true, true);
@ -126,8 +126,8 @@ public class HostnameV2Test extends AbstractKeycloakTest {
@Test
public void testRealmFrontendUrlWithOtherUrlsSet() {
String fixedFrontendUrl = "https://127.0.0.1.nip.io:444";
String fixedAdminUrl = "https://admin.127.0.0.1.nip.io:445";
String fixedFrontendUrl = "https://localtest.me:444";
String fixedAdminUrl = "https://admin.localtest.me:445";
updateServerHostnameSettings(fixedFrontendUrl, fixedAdminUrl, true, true);
@ -137,7 +137,7 @@ public class HostnameV2Test extends AbstractKeycloakTest {
@Test
public void testAdminLocal() throws Exception {
updateServerHostnameSettings("https://127.0.0.1.nip.io:444", null, false, true);
updateServerHostnameSettings("https://localtest.me:444", null, false, true);
// This is a hack. AdminLocal is used only on the Welcome Screen, nowhere else. Welcome Screen by default redirects to Admin Console if admin users exists.
// So we delete it and later recreate it.
@ -146,7 +146,7 @@ public class HostnameV2Test extends AbstractKeycloakTest {
suiteContext.setAdminPasswordUpdated(false);
try (CloseableHttpClient client = HttpClientBuilder.create().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build()) {
// X-Forwarded-For is needed to trigger the correct message with a link, make Keycloak think we're not accessing it locally
SimpleHttp get = SimpleHttpDefault.doGet(getDynamicBaseUrl("127.0.0.1.nip.io"), client).header("X-Forwarded-For", "127.0.0.1");
SimpleHttp get = SimpleHttpDefault.doGet(getDynamicBaseUrl("localtest.me"), client).header("X-Forwarded-For", "127.0.0.1");
String welcomePage = get.asString();
assertThat(welcomePage, containsString("localhost"));
@ -160,7 +160,7 @@ public class HostnameV2Test extends AbstractKeycloakTest {
@Test
public void testRealmFrontendUrl() {
updateServerHostnameSettings("127.0.0.1.nip.io", null, false, true);
updateServerHostnameSettings("localtest.me", null, false, true);
testFrontendAndBackendUrls(realmFrontendName, realmFrontendUrl, realmFrontendUrl);
testAdminUrls(realmFrontendName, realmFrontendUrl, realmFrontendUrl);
@ -175,19 +175,19 @@ public class HostnameV2Test extends AbstractKeycloakTest {
// @Test
// public void testStrictModeMustBeDisabledWhenHostnameIsSpecified() {
// testStartupFailure("hostname is configured, hostname-strict must be set to true",
// "127.0.0.1.nip.io", null, null, false);
// "localtest.me", null, null, false);
// }
@Test
public void testInvalidHostnameUrl() {
testStartupFailure("Provided hostname is neither a plain hostname nor a valid URL",
"htt://127.0.0.1.nip.io", null, null, true);
"htt://localtest.me", null, null, true);
}
@Test
public void testInvalidAdminUrl() {
testStartupFailure("Provided hostname-admin is not a valid URL",
"127.0.0.1.nip.io", "htt://admin.127.0.0.1.nip.io", null, true);
"localtest.me", "htt://admin.localtest.me", null, true);
}
@Test
@ -199,7 +199,7 @@ public class HostnameV2Test extends AbstractKeycloakTest {
@Test
public void testBackchannelDynamicRequiresFullHostnameUrl() {
testStartupFailure("hostname-backchannel-dynamic must be set to false if hostname is not provided as full URL",
"127.0.0.1.nip.io", null, true, true);
"localtest.me", null, true, true);
}
private String getDynamicBaseUrl(String hostname) {

View File

@ -11,7 +11,7 @@ import org.keycloak.testsuite.arquillian.undertow.lb.SimpleUndertowLoadBalancer;
public class ReverseProxy implements TestRule {
public static String DEFAULT_PROXY_HOST = "proxy.kc.127.0.0.1.nip.io";
public static String DEFAULT_PROXY_HOST = "proxy.kc.localtest.me";
public static final int DEFAULT_HTTP_PORT = 8666;
public static final int DEFAULT_HTTPS_PORT = 8667;