use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class BasicAuthHttpHeaderProviderTest method test_auth_instance_enabled_use_service_specific_creds.
@Test
public void test_auth_instance_enabled_use_service_specific_creds() {
Registration registration = Registration.create("foo", "http://health").name("sb-admin-server").build();
Instance instance = Instance.create(InstanceId.of("id")).register(registration);
assertThat(this.headersProviderEnableInstanceAuth.getHeaders(instance).get(HttpHeaders.AUTHORIZATION)).containsOnly("Basic YWRtaW46YWRtaW4=");
}
use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class BasicAuthHttpHeaderProviderTest method test_auth_header_with_dashes.
@Test
public void test_auth_header_with_dashes() {
Registration registration = Registration.create("foo", "http://health").metadata("user-name", "test").metadata("user-password", "drowssap").build();
Instance instance = Instance.create(InstanceId.of("id")).register(registration);
assertThat(this.headersProvider.getHeaders(instance).get(HttpHeaders.AUTHORIZATION)).containsOnly("Basic dGVzdDpkcm93c3NhcA==");
}
use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class BasicAuthHttpHeaderProviderTest method test_no_header.
@Test
public void test_no_header() {
Registration registration = Registration.create("foo", "http://health").build();
Instance instance = Instance.create(InstanceId.of("id")).register(registration);
assertThat(this.headersProvider.getHeaders(instance)).isEmpty();
}
use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class InstanceRegistrationUpdatedEventMixinTest method verifySerialize.
@Test
public void verifySerialize() throws IOException {
InstanceId id = InstanceId.of("test123");
Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS);
Registration registration = Registration.create("test", "http://localhost:9080/heath").managementUrl("http://localhost:9080/").serviceUrl("http://localhost:8080/").source("http-api").metadata("PASSWORD", "qwertz123").metadata("user", "humptydumpty").build();
InstanceRegistrationUpdatedEvent event = new InstanceRegistrationUpdatedEvent(id, 12345678L, timestamp, registration);
JsonContent<InstanceRegistrationUpdatedEvent> jsonContent = jsonTester.write(event);
assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123");
assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(12345678);
assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000);
assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("REGISTRATION_UPDATED");
assertThat(jsonContent).extractingJsonPathValue("$.registration").isNotNull();
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.name").isEqualTo("test");
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.managementUrl").isEqualTo("http://localhost:9080/");
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.healthUrl").isEqualTo("http://localhost:9080/heath");
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.serviceUrl").isEqualTo("http://localhost:8080/");
assertThat(jsonContent).extractingJsonPathStringValue("$.registration.source").isEqualTo("http-api");
assertThat(jsonContent).extractingJsonPathMapValue("$.registration.metadata").containsOnly(entry("PASSWORD", "******"), entry("user", "humptydumpty"));
}
use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class InstanceRegistrationUpdatedEventMixinTest method verifyDeserializeWithOnlyRequiredProperties.
@Test
public void verifyDeserializeWithOnlyRequiredProperties() throws JSONException, JsonProcessingException {
String json = new JSONObject().put("instance", "test123").put("timestamp", 1587751031.000000000).put("type", "REGISTRATION_UPDATED").put("registration", new JSONObject().put("name", "test").put("healthUrl", "http://localhost:9080/heath")).toString();
InstanceRegistrationUpdatedEvent event = objectMapper.readValue(json, InstanceRegistrationUpdatedEvent.class);
assertThat(event).isNotNull();
assertThat(event.getInstance()).isEqualTo(InstanceId.of("test123"));
assertThat(event.getVersion()).isEqualTo(0L);
assertThat(event.getTimestamp()).isEqualTo(Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS));
Registration registration = event.getRegistration();
assertThat(registration).isNotNull();
assertThat(registration.getName()).isEqualTo("test");
assertThat(registration.getManagementUrl()).isNull();
assertThat(registration.getHealthUrl()).isEqualTo("http://localhost:9080/heath");
assertThat(registration.getServiceUrl()).isNull();
assertThat(registration.getSource()).isNull();
assertThat(registration.getMetadata()).isEmpty();
}
Aggregations