Skip to content

Commit

Permalink
Make sure we have an assumption to avoid test fail if DNS is not set up
Browse files Browse the repository at this point in the history
  • Loading branch information
fhanik committed Jun 6, 2016
1 parent f74abeb commit 8e63590
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Expand Up @@ -47,10 +47,12 @@
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;


import static org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.doesSupportZoneDNS;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;


@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = DefaultIntegrationTestConfig.class) @ContextConfiguration(classes = DefaultIntegrationTestConfig.class)
Expand Down Expand Up @@ -139,6 +141,7 @@ public void testSuccessfulLogin() throws Exception {


@Test @Test
public void testNoZoneFound() throws Exception { public void testNoZoneFound() throws Exception {
assumeTrue("Expected testzone1/2/3/4.localhost to resolve to 127.0.0.1", doesSupportZoneDNS());
webDriver.get(baseUrl.replace("localhost","testzone4.localhost") + "/login"); webDriver.get(baseUrl.replace("localhost","testzone4.localhost") + "/login");
assertEquals("The subdomain does not map to a valid identity zone.",webDriver.findElement(By.tagName("p")).getText()); assertEquals("The subdomain does not map to a valid identity zone.",webDriver.findElement(By.tagName("p")).getText());
} }
Expand Down
Expand Up @@ -63,16 +63,15 @@
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;


import java.io.IOException; import java.io.IOException;
import java.net.Inet4Address;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;


import static org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.createSimplePHPSamlIDP; import static org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.createSimplePHPSamlIDP;
import static org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.doesSupportZoneDNS;
import static org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.getZoneAdminToken; import static org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.getZoneAdminToken;
import static org.cloudfoundry.identity.uaa.provider.ExternalIdentityProviderDefinition.EMAIL_ATTRIBUTE_NAME; import static org.cloudfoundry.identity.uaa.provider.ExternalIdentityProviderDefinition.EMAIL_ATTRIBUTE_NAME;
import static org.cloudfoundry.identity.uaa.provider.ExternalIdentityProviderDefinition.GROUP_ATTRIBUTE_NAME; import static org.cloudfoundry.identity.uaa.provider.ExternalIdentityProviderDefinition.GROUP_ATTRIBUTE_NAME;
Expand Down Expand Up @@ -1180,17 +1179,6 @@ public void testLoginClientIDPAuthorizationAlreadyLoggedIn() throws Exception {
} }




protected boolean doesSupportZoneDNS() {
try {
return Arrays.equals(Inet4Address.getByName("testzone1.localhost").getAddress(), new byte[] {127,0,0,1}) &&
Arrays.equals(Inet4Address.getByName("testzone2.localhost").getAddress(), new byte[] {127,0,0,1}) &&
Arrays.equals(Inet4Address.getByName("testzone3.localhost").getAddress(), new byte[] {127,0,0,1}) &&
Arrays.equals(Inet4Address.getByName("testzone4.localhost").getAddress(), new byte[] {127,0,0,1});
} catch (UnknownHostException e) {
return false;
}
}

public SamlIdentityProviderDefinition createTestZone2IDP(String alias) { public SamlIdentityProviderDefinition createTestZone2IDP(String alias) {
return createSimplePHPSamlIDP(alias, "testzone2"); return createSimplePHPSamlIDP(alias, "testzone2");
} }
Expand Down
Expand Up @@ -68,8 +68,10 @@


import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.Inet4Address;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
import java.net.UnknownHostException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
Expand All @@ -95,6 +97,17 @@ protected boolean hasError(HttpStatus statusCode) {
} }
}; };


public static boolean doesSupportZoneDNS() {
try {
return Arrays.equals(Inet4Address.getByName("testzone1.localhost").getAddress(), new byte[] {127,0,0,1}) &&
Arrays.equals(Inet4Address.getByName("testzone2.localhost").getAddress(), new byte[] {127,0,0,1}) &&
Arrays.equals(Inet4Address.getByName("testzone3.localhost").getAddress(), new byte[] {127,0,0,1}) &&
Arrays.equals(Inet4Address.getByName("testzone4.localhost").getAddress(), new byte[] {127,0,0,1});
} catch (UnknownHostException e) {
return false;
}
}

public static ClientCredentialsResourceDetails getClientCredentialsResource(String url, public static ClientCredentialsResourceDetails getClientCredentialsResource(String url,
String[] scope, String[] scope,
String clientId, String clientId,
Expand Down

0 comments on commit 8e63590

Please sign in to comment.