@Test public void shouldCheckCustomHttpStatusCodes() throws ConfigValidationException { UrlConfig urlConfig = UrlConfig.urlConfigBuilder() .withHttpCheck(new HttpCheckConfig(true, ImmutableList.of(304))) .withPaths(ImmutableList.of("/")).build(); JobConfig jobConfig = localTestConfig("200", Browser.Type.CHROME_HEADLESS, false, urlConfig); try { runJLineup(jobConfig, Step.before); fail(); } catch (Exception e) { assertThat(e.getCause().getCause().getCause().getMessage(), containsString("Accessibility check")); assertThat(e.getCause().getCause().getCause().getMessage(), containsString("returned status code 200")); } }
@Test public void shouldCheckHttpStatusCodeError() { UrlConfig urlConfig = UrlConfig.urlConfigBuilder() .withHttpCheck(new HttpCheckConfig(true)) .withPaths(ImmutableList.of("/")).build(); JobConfig jobConfig = localTestConfig("500", Browser.Type.CHROME_HEADLESS, false, urlConfig); try { runJLineup(jobConfig, Step.before); fail(); } catch (Exception e) { assertThat(e.getCause().getCause().getCause().getMessage(), containsString("Accessibility check")); assertThat(e.getCause().getCause().getCause().getMessage(), containsString("returned status code 500")); } }
@Test public void shouldNotCheckHttpStatusCodeErrorIfNotConfigured() throws ConfigValidationException { UrlConfig urlConfig = UrlConfig.urlConfigBuilder() .withHttpCheck(new HttpCheckConfig(false)) .withPaths(ImmutableList.of("/")).build(); JobConfig jobConfig = localTestConfig("500", Browser.Type.CHROME_HEADLESS, false, urlConfig); runJLineup(jobConfig, Step.before); //no exception }
@Test public void shouldSetCookieOnCorrectPath() throws ConfigValidationException { UrlConfig urlConfig = UrlConfig.urlConfigBuilder() .withCookie(new Cookie("CookieName", "CookieValue")) .withPaths(ImmutableList.of("/")).build(); JobConfig jobConfig = localTestConfig("somerootpath/somevalidsubpath", Browser.Type.CHROME_HEADLESS, true, urlConfig); runJLineup(jobConfig, Step.before); }