Search in sources :

Example 16 with Instance

use of de.codecentric.boot.admin.server.domain.entities.Instance 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==");
}
Also used : Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Registration(de.codecentric.boot.admin.server.domain.values.Registration) Test(org.junit.jupiter.api.Test)

Example 17 with Instance

use of de.codecentric.boot.admin.server.domain.entities.Instance 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();
}
Also used : Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Registration(de.codecentric.boot.admin.server.domain.values.Registration) Test(org.junit.jupiter.api.Test)

Example 18 with Instance

use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.

the class InstanceRegistryTest method refresh.

@Test
public void refresh() {
    // Given instance is already reegistered and has status and info.
    StatusInfo status = StatusInfo.ofUp();
    Info info = Info.from(singletonMap("foo", "bar"));
    Registration registration = Registration.create("abc", "http://localhost:8080/health").build();
    InstanceId id = idGenerator.generateId(registration);
    Instance app = Instance.create(id).register(registration).withStatusInfo(status).withInfo(info);
    StepVerifier.create(repository.save(app)).expectNextCount(1).verifyComplete();
    // When instance registers second time
    InstanceId refreshId = registry.register(Registration.create("abc", "http://localhost:8080/health").build()).block();
    assertThat(refreshId).isEqualTo(id);
    StepVerifier.create(registry.getInstance(id)).assertNext((registered) -> {
        // Then info and status are retained
        assertThat(registered.getInfo()).isEqualTo(info);
        assertThat(registered.getStatusInfo()).isEqualTo(status);
    }).verifyComplete();
}
Also used : Registration(de.codecentric.boot.admin.server.domain.values.Registration) BeforeEach(org.junit.jupiter.api.BeforeEach) StepVerifier(reactor.test.StepVerifier) InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Info(de.codecentric.boot.admin.server.domain.values.Info) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) Instance(de.codecentric.boot.admin.server.domain.entities.Instance) EventsourcingInstanceRepository(de.codecentric.boot.admin.server.domain.entities.EventsourcingInstanceRepository) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) StatusInfo(de.codecentric.boot.admin.server.domain.values.StatusInfo) Collections.singletonMap(java.util.Collections.singletonMap) InMemoryEventStore(de.codecentric.boot.admin.server.eventstore.InMemoryEventStore) InstanceRepository(de.codecentric.boot.admin.server.domain.entities.InstanceRepository) StatusInfo(de.codecentric.boot.admin.server.domain.values.StatusInfo) InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Registration(de.codecentric.boot.admin.server.domain.values.Registration) Info(de.codecentric.boot.admin.server.domain.values.Info) StatusInfo(de.codecentric.boot.admin.server.domain.values.StatusInfo) Test(org.junit.jupiter.api.Test)

Example 19 with Instance

use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.

the class ChainingStrategyTest method should_return_empty_endpoints_when_all_empty.

@Test
public void should_return_empty_endpoints_when_all_empty() {
    // given
    Instance instance = Instance.create(InstanceId.of("id"));
    ChainingStrategy strategy = new ChainingStrategy((a) -> Mono.empty());
    // when/then
    StepVerifier.create(strategy.detectEndpoints(instance)).expectNext(Endpoints.empty()).verifyComplete();
}
Also used : Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Test(org.junit.jupiter.api.Test)

Example 20 with Instance

use of de.codecentric.boot.admin.server.domain.entities.Instance in project spring-boot-admin by codecentric.

the class ChainingStrategyTest method should_chain_on_empty.

@Test
public void should_chain_on_empty() {
    // given
    Instance instance = Instance.create(InstanceId.of("id"));
    ChainingStrategy strategy = new ChainingStrategy((a) -> Mono.empty(), (a) -> Mono.empty(), (a) -> Mono.just(Endpoints.single("id", "path")));
    // when/then
    StepVerifier.create(strategy.detectEndpoints(instance)).expectNext(Endpoints.single("id", "path")).verifyComplete();
}
Also used : Instance(de.codecentric.boot.admin.server.domain.entities.Instance) Test(org.junit.jupiter.api.Test)

Aggregations

Instance (de.codecentric.boot.admin.server.domain.entities.Instance)44 Test (org.junit.jupiter.api.Test)42 Registration (de.codecentric.boot.admin.server.domain.values.Registration)23 InstanceId (de.codecentric.boot.admin.server.domain.values.InstanceId)16 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)14 StepVerifier (reactor.test.StepVerifier)14 StatusInfo (de.codecentric.boot.admin.server.domain.values.StatusInfo)13 BeforeEach (org.junit.jupiter.api.BeforeEach)13 Mono (reactor.core.publisher.Mono)10 InstanceRepository (de.codecentric.boot.admin.server.domain.entities.InstanceRepository)9 EventsourcingInstanceRepository (de.codecentric.boot.admin.server.domain.entities.EventsourcingInstanceRepository)8 InMemoryEventStore (de.codecentric.boot.admin.server.eventstore.InMemoryEventStore)8 Flux (reactor.core.publisher.Flux)8 ArrayList (java.util.ArrayList)7 Collections.singletonMap (java.util.Collections.singletonMap)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 Application (de.codecentric.boot.admin.server.domain.entities.Application)6 Info (de.codecentric.boot.admin.server.domain.values.Info)6 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)6 Mockito.mock (org.mockito.Mockito.mock)6