Skip to content

Commit

Permalink
refactor: introduce constants for test account credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
swalchemist committed Sep 16, 2023
1 parent 0d2caba commit 2b79ea6
Showing 1 changed file with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@
@ContextConfiguration(classes = DefaultIntegrationTestConfig.class)
public class SamlLoginIT {

public static final String MARISSA4_USERNAME = "marissa4";
private static final String MARISSA4_PASSWORD = "saml2";
public static final String MARISSA4_EMAIL = "[email protected]";
public static final String MARISSA2_USERNAME = "marissa2";
private static final String MARISSA2_PASSWORD = "saml2";
public static final String MARISSA3_USERNAME = "marissa3";
private static final String MARISSA3_PASSWORD = "saml2";
private static final String SAML_ORIGIN = "simplesamlphp";
@Autowired @Rule
public IntegrationTestRule integrationTestRule;
Expand Down Expand Up @@ -456,13 +463,13 @@ public void testGroupIntegration() throws Exception {
createIdentityProvider(SAML_ORIGIN);
LoginPage.go(webDriver, baseUrl)
.startSamlLogin()
.login("marissa4", "saml2");
.login(MARISSA4_USERNAME, MARISSA4_PASSWORD);
}

@Test
public void testFavicon_Should_Not_Save() throws Exception {
webDriver.get(baseUrl + "/favicon.ico");
testSimpleSamlLogin("/login", "Where to?", "marissa4", "saml2");
testSimpleSamlLogin("/login", "Where to?", MARISSA4_USERNAME, MARISSA4_PASSWORD);
}


Expand Down Expand Up @@ -536,13 +543,13 @@ protected void deleteUser(String origin, String username) {

@Test
public void test_SamlInvitation_Automatic_Redirect_In_Zone2() throws Exception {
perform_SamlInvitation_Automatic_Redirect_In_Zone2("marissa2", "saml2", true);
perform_SamlInvitation_Automatic_Redirect_In_Zone2("marissa2", "saml2", true);
perform_SamlInvitation_Automatic_Redirect_In_Zone2("marissa2", "saml2", true);
perform_SamlInvitation_Automatic_Redirect_In_Zone2(MARISSA2_USERNAME, MARISSA2_PASSWORD, true);
perform_SamlInvitation_Automatic_Redirect_In_Zone2(MARISSA2_USERNAME, MARISSA2_PASSWORD, true);
perform_SamlInvitation_Automatic_Redirect_In_Zone2(MARISSA2_USERNAME, MARISSA2_PASSWORD, true);

perform_SamlInvitation_Automatic_Redirect_In_Zone2("marissa3", "saml2", false);
perform_SamlInvitation_Automatic_Redirect_In_Zone2("marissa3", "saml2", false);
perform_SamlInvitation_Automatic_Redirect_In_Zone2("marissa3", "saml2", false);
perform_SamlInvitation_Automatic_Redirect_In_Zone2(MARISSA3_USERNAME, MARISSA3_PASSWORD, false);
perform_SamlInvitation_Automatic_Redirect_In_Zone2(MARISSA3_USERNAME, MARISSA3_PASSWORD, false);
perform_SamlInvitation_Automatic_Redirect_In_Zone2(MARISSA3_USERNAME, MARISSA3_PASSWORD, false);
}

public void perform_SamlInvitation_Automatic_Redirect_In_Zone2(String username, String password, boolean emptyList) {
Expand Down Expand Up @@ -855,16 +862,16 @@ public void testSamlLogin_Map_Groups_In_Zone1() {
//we should now be in the Simple SAML PHP site
webDriver.findElement(By.xpath(SIMPLESAMLPHP_LOGIN_PROMPT_XPATH_EXPR));
webDriver.findElement(By.name("username")).clear();
webDriver.findElement(By.name("username")).sendKeys("marissa4");
webDriver.findElement(By.name("password")).sendKeys("saml2");
webDriver.findElement(By.name("username")).sendKeys(MARISSA4_USERNAME);
webDriver.findElement(By.name("password")).sendKeys(MARISSA4_PASSWORD);
webDriver.findElement(By.xpath("//input[@value='Login']")).click();

assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString("Where to?"));
webDriver.get(baseUrl + "/logout.do");
webDriver.get(zoneUrl + "/logout.do");

//validate that the groups were mapped
String samlUserId = IntegrationTestUtils.getUserId(adminTokenInZone, zoneUrl, provider.getOriginKey(), "[email protected]");
String samlUserId = IntegrationTestUtils.getUserId(adminTokenInZone, zoneUrl, provider.getOriginKey(), MARISSA4_EMAIL);
uaaSamlUserGroup = IntegrationTestUtils.getGroup(adminTokenInZone, null, zoneUrl, "uaa.saml.user");
uaaSamlAdminGroup = IntegrationTestUtils.getGroup(adminTokenInZone, null, zoneUrl, "uaa.saml.admin");
assertTrue(isMember(samlUserId, uaaSamlUserGroup));
Expand Down

0 comments on commit 2b79ea6

Please sign in to comment.