@Override public void run() { assertHttpStatusCodeEquals(url, expectedCode); } });
@Override public void run() { // TODO Need to drop logging; remove sleep when that's done. while (!Thread.currentThread().isInterrupted()) { assertHttpStatusCodeEquals(url, expectedStatusCode); try { Thread.sleep(1000); } catch (InterruptedException e) { return; // graceful return } } } });
@Override public void run() { for (Entity member : serverPool.getMembers()) { String jbossUrl = member.getAttribute(WebAppService.ROOT_URL); assertHttpStatusCodeEquals(jbossUrl, 200); } assertHttpStatusCodeEquals(nginxUrl, 200); }});
protected static void waitForApps(String webConsoleUri) { HttpTestUtils.assertHttpStatusCodeEquals(webConsoleUri+"/v1/applications", 200, 403); HttpTestUtils.assertHttpStatusCodeEventuallyEquals(webConsoleUri+"/v1/applications", 200); }
@Override public void run() { HttpTestUtils.assertContentContainsText("http://localhost1:"+port+"/hello-world", "Hello"); HttpTestUtils.assertHttpStatusCodeEquals("http://localhost1:"+port+"", 404); HttpTestUtils.assertContentContainsText("http://localhost:"+port+"", "Hello"); HttpTestUtils.assertHttpStatusCodeEquals("http://localhost:"+port+"/hello-world", 404); }}); }
@Override public void run() { for (Entity member : serverPool.getMembers()) { assertHttpStatusCodeEquals(member.getAttribute(WebAppService.ROOT_URL), 200); } assertHttpStatusCodeEquals(nginx.getAttribute(WebAppService.ROOT_URL), 200); }});
@Override public void run() { for (NginxController nginx : nginxs) { assertTrue(nginx.getAttribute(NginxController.SERVICE_UP)); String normalRootUrl = nginx.getAttribute(NginxController.ROOT_URL); int port = nginx.getAttribute(NginxController.PROXY_HTTP_PORT); String rootUrl = (hostname != null) ? ("http://"+hostname+":"+port+"/") : normalRootUrl; String wrongUrl = rootUrl+"doesnotexist"; HttpTestUtils.assertHttpStatusCodeEquals(wrongUrl, 404); for (String pathFor200 : pathsFor200) { String url = rootUrl+pathFor200; HttpTestUtils.assertHttpStatusCodeEquals(url, 200); } } }}); }
@Override public void run() { // TODO get this URL from a WAR file entity HttpTestUtils.assertHttpStatusCodeEquals(Urls.mergePaths(entity.getAttribute(WebAppService.ROOT_URL), "myartifactname", urlSubPathToPageToQuery), 404); assertEquals(entity.getAttribute(JavaWebAppSoftwareProcess.DEPLOYED_WARS), ImmutableSet.of()); }}); }
@Override public void run() { // TODO get this URL from a web-app entity of some kind? String url = Urls.mergePaths(entity.getAttribute(WebAppService.ROOT_URL), urlSubPathToWebApp, urlSubPathToPageToQuery); HttpTestUtils.assertHttpStatusCodeEquals(url, 200); }}); }
@Override public void run() { // TODO get this URL from a WAR file entity HttpTestUtils.assertHttpStatusCodeEquals(Urls.mergePaths(entity.getAttribute(WebAppService.ROOT_URL), urlSubPathToPageToQuery), 200); assertEquals(entity.getAttribute(JavaWebAppSoftwareProcess.DEPLOYED_WARS), ImmutableSet.of("/")); }}); }
@Override public void run() { // TODO get this URL from a WAR file entity HttpTestUtils.assertHttpStatusCodeEquals(Urls.mergePaths(entity.getAttribute(WebAppService.ROOT_URL), urlSubPathToWebApp, urlSubPathToPageToQuery), 200); }}); }
@Override public void run() { // TODO get this URL from a WAR file entity HttpTestUtils.assertHttpStatusCodeEquals(Urls.mergePaths(entity.getAttribute(WebAppService.ROOT_URL), "myartifactname/", urlSubPathToPageToQuery), 200); assertEquals(entity.getAttribute(JavaWebAppSoftwareProcess.DEPLOYED_WARS), ImmutableSet.of("/myartifactname")); }});
@Override public void run() { // Services are running assertTrue(cluster.getAttribute(SoftwareProcess.SERVICE_UP)); for (Entity member : cluster.getMembers()) { assertTrue(member.getAttribute(SoftwareProcess.SERVICE_UP)); } assertTrue(nginx.getAttribute(SoftwareProcess.SERVICE_UP)); // Nginx URL is available HttpTestUtils.assertHttpStatusCodeEquals(url, 200); // Web-server URL is available for (Entity member : cluster.getMembers()) { HttpTestUtils.assertHttpStatusCodeEquals(member.getAttribute(WebAppService.ROOT_URL), 200); } }});
@Override public void run() { // Services are running assertTrue(cluster.getAttribute(SoftwareProcess.SERVICE_UP)); for (Entity member : cluster.getMembers()) { assertTrue(member.getAttribute(SoftwareProcess.SERVICE_UP)); } assertTrue(nginx.getAttribute(SoftwareProcess.SERVICE_UP)); // Nginx URL is available HttpTestUtils.assertHttpStatusCodeEquals(url, 200); // Web-server URL is available for (Entity member : cluster.getMembers()) { HttpTestUtils.assertHttpStatusCodeEquals(member.getAttribute(WebAppService.ROOT_URL), 200); } }});
@Test(groups={"Integration", "Broken"}) public void testSetsBrooklynWebConsolePort() throws Exception { BrooklynNode brooklynNode = app.createAndManageChild(newBrooklynNodeSpecForTest() .configure(BrooklynNode.HTTP_PORT, PortRanges.fromString("45000+"))); app.start(locs); log.info("started "+app+" containing "+brooklynNode+" for "+JavaClassNames.niceClassAndMethod()); Integer httpPort = brooklynNode.getAttribute(BrooklynNode.HTTP_PORT); URI webConsoleUri = brooklynNode.getAttribute(BrooklynNode.WEB_CONSOLE_URI); assertTrue(httpPort >= 45000 && httpPort < 54100, "httpPort="+httpPort); assertEquals((Integer)webConsoleUri.getPort(), httpPort); HttpTestUtils.assertHttpStatusCodeEquals(webConsoleUri.toString(), 200, 401); }
@Override public void run() { // Nginx URL is available MachineLocation machine = Machines.findUniqueMachineLocation(nginx.getLocations()).get(); String url = "http://" + machine.getAddress().getHostName() + ":" + nginx.getAttribute(NginxController.PROXY_HTTP_PORT) + "/swf-booking-mvc"; HttpTestUtils.assertHttpStatusCodeEquals(url, 200); // Web-app URL is available for (Entity member : cluster.getMembers()) { HttpTestUtils.assertHttpStatusCodeEquals(member.getAttribute(JavaWebAppService.ROOT_URL) + "swf-booking-mvc", 200); } }});
@Test(groups={"Integration", "Broken"}) public void testAuthenticationAndHttps() throws Exception { String adminPassword = "p4ssw0rd"; BrooklynNode brooklynNode = app.createAndManageChild(newBrooklynNodeSpecForTest() .configure(BrooklynNode.ENABLED_HTTP_PROTOCOLS, ImmutableList.of("https")) .configure(BrooklynNode.MANAGEMENT_PASSWORD, adminPassword) .configure(BrooklynNode.BROOKLYN_LOCAL_PROPERTIES_CONTENTS, Strings.lines( "brooklyn.webconsole.security.https.required=true", "brooklyn.webconsole.security.users=admin", "brooklyn.webconsole.security.user.admin.password="+adminPassword, "brooklyn.location.localhost.enabled=false") ) ); app.start(locs); log.info("started "+app+" containing "+brooklynNode+" for "+JavaClassNames.niceClassAndMethod()); URI webConsoleUri = brooklynNode.getAttribute(BrooklynNode.WEB_CONSOLE_URI); Assert.assertTrue(webConsoleUri.toString().startsWith("https://"), "web console not https: "+webConsoleUri); Integer httpsPort = brooklynNode.getAttribute(BrooklynNode.HTTPS_PORT); Assert.assertTrue(httpsPort!=null && httpsPort >= 8443 && httpsPort <= 8500); Assert.assertTrue(webConsoleUri.toString().contains(""+httpsPort), "web console not using right https port ("+httpsPort+"): "+webConsoleUri); HttpTestUtils.assertHttpStatusCodeEquals(webConsoleUri.toString(), 401); HttpClient http = HttpTool.httpClientBuilder() .trustAll() .uri(webConsoleUri) .laxRedirect(true) .credentials(new UsernamePasswordCredentials("admin", adminPassword)) .build(); HttpToolResponse response = HttpTool.httpGet(http, webConsoleUri, MutableMap.<String,String>of()); Assert.assertEquals(response.getResponseCode(), 200); }
DynamicWebAppCluster newCluster = (DynamicWebAppCluster) Iterables.find(app().getChildren(), Predicates.instanceOf(DynamicWebAppCluster.class)); assertHttpStatusCodeEquals(jbossUrl, 200);
assertHttpStatusCodeEquals(rootUrl, 200); assertHttpStatusCodeEquals(rootUrl, 200);
@Test(groups="Integration") public void testServiceMirroringHttps() throws Exception { LocalManagementContextForTests mgmtHttps = new LocalManagementContextForTests(); mgmtHttps.getBrooklynProperties().put("brooklyn.webconsole.security.https.required", true); mgmtHttps.getBrooklynProperties().put("brooklyn.webconsole.security.users", "admin"); mgmtHttps.getBrooklynProperties().put("brooklyn.webconsole.security.user.admin.password", "P5ssW0rd"); setUpServer(mgmtHttps, false); Assert.assertTrue(getBaseUri().startsWith("https:"), "URL is not https: "+getBaseUri()); // check auth is required HttpTestUtils.assertHttpStatusCodeEquals(getBaseUri(), 401); serverApp.sensors().set(TestApplication.MY_ATTRIBUTE, "austria"); String serviceId = serverApp.getId(); Entity mirror = localApp.addChild(EntitySpec.create(BrooklynEntityMirror.class) .configure(BrooklynEntityMirror.POLL_PERIOD, Duration.millis(100)) .configure(BrooklynEntityMirror.MANAGEMENT_USER, "admin") .configure(BrooklynEntityMirror.MANAGEMENT_PASSWORD, "P5ssW0rd") .configure(BrooklynEntityMirror.MIRRORED_ENTITY_ID, serviceId) .configure(BrooklynEntityMirror.MIRRORED_ENTITY_URL, getBaseUri()+"/v1/applications/"+serviceId+"/entities/"+serviceId) ); EntityAsserts.assertAttributeEqualsEventually(mirror, TestApplication.MY_ATTRIBUTE, "austria"); log.info("Sensors mirrored are: "+((EntityInternal)mirror).getAllAttributes()); serverApp.sensors().set(TestApplication.MY_ATTRIBUTE, "bermuda"); EntityAsserts.assertAttributeEqualsEventually(mirror, TestApplication.MY_ATTRIBUTE, "bermuda"); serverApp.stop(); assertUnmanagedEventually(mirror); }