Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only list ACTIVE vault secrets #154

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;

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

/**
* Requires an existing vault, identified by the OCI_VAULT_ID environment variable.
* The vault must have a secret named "mysecret" present.
* The vault must have at least one secret named "mysecret" present.
* This secret must be in the "ACTIVE" lifecycle state.
*/
@SpringBootTest
@EnabledIfEnvironmentVariable(named = "OCI_COMPARTMENT_ID", matches = ".+")
Expand All @@ -33,7 +35,11 @@ public class VaultTemplateIT {
@Autowired
VaultController vaultController;

private final String secretName = "mysecret";
@Value("${secretName:mysecret}")
private String secretName;

@Value("${numSecrets:1}")
private int numSecrets;

@Test
void getSecret() {
Expand All @@ -59,7 +65,7 @@ void updateSecret() {
@Test
void listSecret() {
List<SecretSummary> summaries = vaultTemplate.listSecrets();
assertThat(summaries).hasSize(1);
assertThat(summaries).hasSizeGreaterThanOrEqualTo(numSecrets);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public List<SecretSummary> listSecrets() {
do {
ListSecretsRequest request = ListSecretsRequest.builder()
.vaultId(vaultId)
.lifecycleState(SecretSummary.LifecycleState.Active)
.compartmentId(compartmentId)
.page(page)
.build();
Expand Down
Loading