Skip to content

Commit

Permalink
Add integration test for VaultReactiveHealthIndicator
Browse files Browse the repository at this point in the history
Add test for the reactive health indicator.

See gh-397
  • Loading branch information
mp911de committed Apr 2, 2020
1 parent 66ea2c4 commit 7b45968
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.cloud.vault.config;

import org.junit.Test;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
import org.springframework.cloud.vault.util.IntegrationTestSupport;
import org.springframework.cloud.vault.util.Settings;
import org.springframework.cloud.vault.util.TestRestTemplateFactory;
import org.springframework.vault.client.ClientHttpConnectorFactory;
import org.springframework.vault.core.ReactiveVaultTemplate;
import org.springframework.vault.support.ClientOptions;

import static org.assertj.core.api.Assertions.assertThat;

/**
* Integration tests for {@link VaultReactiveHealthIndicator}.
*
* @author Mark Paluch
*/
public class VaultReactiveHealthIndicatorIntegrationTests extends IntegrationTestSupport {

@Test
public void shouldReturnHealthState() {

ReactiveVaultTemplate vaultTemplate = new ReactiveVaultTemplate(
TestRestTemplateFactory.TEST_VAULT_ENDPOINT, ClientHttpConnectorFactory
.create(new ClientOptions(), Settings
.createSslConfiguration()), () -> Mono.just(Settings.token()));

VaultReactiveHealthIndicator healthIndicator = new VaultReactiveHealthIndicator(vaultTemplate);

healthIndicator.doHealthCheck(Health.up()).as(StepVerifier::create)
.consumeNextWith(actual -> {
assertThat(actual.getStatus()).isEqualTo(Status.UP);
}).verifyComplete();
}
}

0 comments on commit 7b45968

Please sign in to comment.