use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class ApplicationOperationsTest method test_getHealth.
@Test
@SuppressWarnings("rawtypes")
public void test_getHealth() {
Application app = Application.create("test").withHealthUrl("http://health").withManagementUrl("http://mgmt").build();
ArgumentCaptor<HttpEntity> requestEntity = ArgumentCaptor.forClass(HttpEntity.class);
HttpHeaders headers = new HttpHeaders();
headers.add("auth", "foo:bar");
when(headersProvider.getHeaders(eq(app))).thenReturn(headers);
when(restTemplate.exchange(eq(URI.create("http://health")), eq(HttpMethod.GET), requestEntity.capture(), eq(Map.class))).thenReturn(ResponseEntity.ok().body((Map) singletonMap("foo", "bar")));
ResponseEntity<Map<String, Serializable>> response = ops.getHealth(app);
assertThat(response.getBody()).containsEntry("foo", "bar");
assertThat(requestEntity.getValue().getHeaders()).containsEntry("auth", asList("foo:bar"));
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class ApplicationOperationsTest method test_getInfo.
@Test
@SuppressWarnings("rawtypes")
public void test_getInfo() {
Application app = Application.create("test").withHealthUrl("http://health").withManagementUrl("http://mgmt").build();
ArgumentCaptor<HttpEntity> requestEntity = ArgumentCaptor.forClass(HttpEntity.class);
HttpHeaders headers = new HttpHeaders();
headers.add("auth", "foo:bar");
when(headersProvider.getHeaders(eq(app))).thenReturn(headers);
when(restTemplate.exchange(eq(URI.create("http://mgmt/info")), eq(HttpMethod.GET), requestEntity.capture(), eq(Map.class))).thenReturn(ResponseEntity.ok().body((Map) singletonMap("foo", "bar")));
ResponseEntity<Map<String, Serializable>> response = ops.getInfo(app);
assertThat(response.getBody()).containsEntry("foo", "bar");
assertThat(requestEntity.getValue().getHeaders()).containsEntry("auth", asList("foo:bar"));
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class BasicAuthHttpHeaderProviderTest method test_no_header.
@Test
public void test_no_header() {
Application app = Application.create("test").withHealthUrl("/health").build();
assertTrue(headersProvider.getHeaders(app).isEmpty());
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class BasicAuthHttpHeaderProviderTest method test_auth_header.
@Test
public void test_auth_header() {
Application app = Application.create("test").withHealthUrl("/health").addMetadata("user.name", "test").addMetadata("user.password", "drowssap").build();
assertThat(headersProvider.getHeaders(app).get(HttpHeaders.AUTHORIZATION).get(0), is("Basic dGVzdDpkcm93c3NhcA=="));
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class ApplicationDiscoveryListenerTest method test_register_and_convert.
@Test
public void test_register_and_convert() {
when(discovery.getServices()).thenReturn(Collections.singletonList("service"));
when(discovery.getInstances("service")).thenReturn(Collections.singletonList((ServiceInstance) new DefaultServiceInstance("service", "localhost", 80, false)));
listener.onInstanceRegistered(new InstanceRegisteredEvent<>(new Object(), null));
assertEquals(1, registry.getApplications().size());
Application application = registry.getApplications().iterator().next();
assertEquals("http://localhost:80/health", application.getHealthUrl());
assertEquals("http://localhost:80", application.getManagementUrl());
assertEquals("http://localhost:80", application.getServiceUrl());
assertEquals("service", application.getName());
}
Aggregations