|
| 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 | +package org.springframework.vault.core.lease; |
| 17 | + |
| 18 | +import java.util.Collections; |
| 19 | + |
| 20 | +import org.junit.jupiter.api.BeforeAll; |
| 21 | +import org.junit.jupiter.api.Test; |
| 22 | +import org.junit.jupiter.api.extension.ExtendWith; |
| 23 | + |
| 24 | +import org.springframework.beans.factory.annotation.Autowired; |
| 25 | +import org.springframework.test.context.junit.jupiter.SpringExtension; |
| 26 | +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; |
| 27 | +import org.springframework.vault.core.VaultIntegrationTestConfiguration; |
| 28 | +import org.springframework.vault.core.VaultKeyValueOperations; |
| 29 | +import org.springframework.vault.core.VaultKeyValueOperationsSupport; |
| 30 | +import org.springframework.vault.util.IntegrationTestSupport; |
| 31 | +import org.springframework.vault.util.PrepareVault; |
| 32 | +import org.springframework.vault.util.VaultInitializer; |
| 33 | + |
| 34 | +import static org.assertj.core.api.Assertions.*; |
| 35 | + |
| 36 | +/** |
| 37 | + * Integration tests for rotating generic secrets. |
| 38 | + * |
| 39 | + * @author Mark Paluch |
| 40 | + */ |
| 41 | +@ExtendWith(SpringExtension.class) |
| 42 | +@SpringJUnitConfig( |
| 43 | + classes = { VaultIntegrationTestConfiguration.class, RotatingGenericSecretsIntegrationTestConfiguration.class }) |
| 44 | +public class RotatingGenericSecretsIntegrationTests extends IntegrationTestSupport { |
| 45 | + |
| 46 | + @BeforeAll |
| 47 | + static void beforeAll() { |
| 48 | + |
| 49 | + VaultInitializer initializer = new VaultInitializer(); |
| 50 | + |
| 51 | + initializer.initialize(); |
| 52 | + PrepareVault prepare = initializer.prepare(); |
| 53 | + |
| 54 | + VaultKeyValueOperations versioned = prepare.getVaultOperations().opsForKeyValue("versioned", |
| 55 | + VaultKeyValueOperationsSupport.KeyValueBackend.KV_2); |
| 56 | + |
| 57 | + versioned.put("rotating", Collections.singletonMap("key", "value")); |
| 58 | + } |
| 59 | + |
| 60 | + @Test |
| 61 | + void name(@Autowired RotatingGenericSecretsIntegrationTestConfiguration.PropertySourceHolder holder) { |
| 62 | + |
| 63 | + assertThat(holder.propertySource.getProperty("generic.rotating.key")).isEqualTo("value"); |
| 64 | + } |
| 65 | + |
| 66 | +} |
0 commit comments