mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-08 20:12:23 +00:00
integrate whitelabel switchin into test setup #5153
This commit is contained in:
1 parent
7e46168c56
commit
39fe761eb8
2 files changed
+38
-1
No files matched your search
+36
@@ -40,6 +40,7 @@ import com.sap.sailing.selenium.core.WindowManager;
|
||||
import com.sap.sailing.selenium.pages.PageObject;
|
||||
import com.sap.sse.common.Duration;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
import com.sun.jersey.api.container.httpserver.HttpServerFactory;
|
||||
|
||||
/**
|
||||
* <p>Abstract base class for unit tests with Selenium. This class is already annotated as required to get executed
|
||||
@@ -64,6 +65,8 @@ public abstract class AbstractSeleniumTest {
|
||||
|
||||
private static final String CLEAR_STATE_URL = "sailingserver/test-support/clearState"; //$NON-NLS-1$
|
||||
|
||||
private static final String SWITCH_WHITELABEL_URL = "sailingserver/test-support/switch/whitelabel/"; //$NON-NLS-1$
|
||||
|
||||
private static final String OBTAIN_ACCESS_TOKEN_URL = "security/api/restsecurity/access_token";
|
||||
|
||||
private static final String CREATE_SESSION_URL = "sailingserver/test-support/createSession";
|
||||
@@ -136,8 +139,41 @@ public abstract class AbstractSeleniumTest {
|
||||
*/
|
||||
protected void clearState(String contextRoot) {
|
||||
clearState(contextRoot, false);
|
||||
setWhitelabel(false, contextRoot);
|
||||
}
|
||||
|
||||
protected void setWhitelabel(boolean status, String contextRoot) {
|
||||
try {
|
||||
URL url = new URL(contextRoot + SWITCH_WHITELABEL_URL + Boolean.toString(status));
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("PUT");
|
||||
connection.connect();
|
||||
if (connection.getResponseCode() != 200) {
|
||||
throw new RuntimeException(connection.getResponseMessage());
|
||||
}
|
||||
} catch (IOException exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean getWhitelabel(String contextRoot) {
|
||||
try {
|
||||
URL url = new URL(contextRoot + SWITCH_WHITELABEL_URL + "status");
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.connect();
|
||||
if (connection.getResponseCode() != 200) {
|
||||
throw new RuntimeException(connection.getResponseMessage());
|
||||
}
|
||||
String response = (String)connection.getContent();
|
||||
return Boolean.valueOf(response);
|
||||
} catch (IOException exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void setUpAuthenticatedSession(WebDriver webDriver) {
|
||||
// To be able to set a cookie we need to load a page having the target origin
|
||||
webDriver.get(getContextRoot());
|
||||
|
||||
+2
-1
@@ -94,12 +94,13 @@ public class WhitelabelTest extends AbstractSeleniumTest {
|
||||
}
|
||||
details.linkRace(new RaceDescriptor("M", DEFAULT_FLEET, true, false, 0), new TrackedRaceDescriptor(REGATTA_49ER_WITH_SUFFIX, BOAT_CLASS_49ER, MEDAL_RACE_49ER));
|
||||
}
|
||||
setWhitelabel(true, getContextRoot());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHomepageWhitelabel() throws UnsupportedEncodingException {
|
||||
HomePage homePage = HomePage.goToPage(getWebDriver(), getContextRoot(), true);
|
||||
HomePage homePage = HomePage.goToPage(getWebDriver(), getContextRoot());
|
||||
|
||||
assertThat(homePage.getPageTitle(), not(containsString("SAP")));
|
||||
|
||||
|
||||
Reference in new issue
Block a user