|
| 1 | +/* |
| 2 | + * Copyright 2020 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.cloud.vault.config; |
| 18 | + |
| 19 | +import org.junit.Test; |
| 20 | +import reactor.core.publisher.Mono; |
| 21 | +import reactor.test.StepVerifier; |
| 22 | + |
| 23 | +import org.springframework.boot.actuate.health.Health; |
| 24 | +import org.springframework.boot.actuate.health.Status; |
| 25 | +import org.springframework.cloud.vault.util.IntegrationTestSupport; |
| 26 | +import org.springframework.cloud.vault.util.Settings; |
| 27 | +import org.springframework.cloud.vault.util.TestRestTemplateFactory; |
| 28 | +import org.springframework.vault.client.ClientHttpConnectorFactory; |
| 29 | +import org.springframework.vault.core.ReactiveVaultTemplate; |
| 30 | +import org.springframework.vault.support.ClientOptions; |
| 31 | + |
| 32 | +import static org.assertj.core.api.Assertions.assertThat; |
| 33 | + |
| 34 | +/** |
| 35 | + * Integration tests for {@link VaultReactiveHealthIndicator}. |
| 36 | + * |
| 37 | + * @author Mark Paluch |
| 38 | + */ |
| 39 | +public class VaultReactiveHealthIndicatorIntegrationTests extends IntegrationTestSupport { |
| 40 | + |
| 41 | + @Test |
| 42 | + public void shouldReturnHealthState() { |
| 43 | + |
| 44 | + ReactiveVaultTemplate vaultTemplate = new ReactiveVaultTemplate( |
| 45 | + TestRestTemplateFactory.TEST_VAULT_ENDPOINT, ClientHttpConnectorFactory |
| 46 | + .create(new ClientOptions(), Settings |
| 47 | + .createSslConfiguration()), () -> Mono.just(Settings.token())); |
| 48 | + |
| 49 | + VaultReactiveHealthIndicator healthIndicator = new VaultReactiveHealthIndicator(vaultTemplate); |
| 50 | + |
| 51 | + healthIndicator.doHealthCheck(Health.up()).as(StepVerifier::create) |
| 52 | + .consumeNextWith(actual -> { |
| 53 | + assertThat(actual.getStatus()).isEqualTo(Status.UP); |
| 54 | + }).verifyComplete(); |
| 55 | + } |
| 56 | +} |
0 commit comments