Skip to content

Commit

Permalink
fix owner reference tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Wenzel committed Oct 19, 2020
1 parent e9814ce commit 19d219a
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 25 deletions.
8 changes: 5 additions & 3 deletions src/test/java/de/koudingspawn/vault/CertChainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.springframework.context.annotation.Primary;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.UUID;

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static com.github.tomakehurst.wiremock.stubbing.Scenario.STARTED;
Expand Down Expand Up @@ -79,7 +81,7 @@ public void before() {
public void shouldGenerateCertFromVaultResource() {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("certificate").withNamespace("default").build()
new ObjectMetaBuilder().withName("certificate").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);
VaultSpec spec = new VaultSpec();
spec.setType(VaultType.CERT);
Expand Down Expand Up @@ -131,7 +133,7 @@ public void shouldGenerateCertFromVaultResource() {
public void shouldCheckIfCertificateHasChangedAndReturnFalse() throws SecretNotAccessibleException {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("certificate").withNamespace("default").build()
new ObjectMetaBuilder().withName("certificate").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);
VaultSpec spec = new VaultSpec();
spec.setType(VaultType.CERT);
Expand Down Expand Up @@ -169,7 +171,7 @@ public void shouldCheckIfCertificateHasChangedAndReturnFalse() throws SecretNotA
public void shouldCheckIfCertificateHasChangedAndReturnTrue() throws SecretNotAccessibleException {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("certificate").withNamespace("default").build()
new ObjectMetaBuilder().withName("certificate").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);
VaultSpec spec = new VaultSpec();
spec.setType(VaultType.CERT);
Expand Down
8 changes: 5 additions & 3 deletions src/test/java/de/koudingspawn/vault/CertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.springframework.context.annotation.Primary;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.UUID;

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static com.github.tomakehurst.wiremock.stubbing.Scenario.STARTED;
Expand Down Expand Up @@ -79,7 +81,7 @@ public void before() {
public void shouldGenerateCertFromVaultResource() {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("certificate").withNamespace("default").build()
new ObjectMetaBuilder().withName("certificate").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);
VaultSpec spec = new VaultSpec();
spec.setType(VaultType.CERT);
Expand Down Expand Up @@ -130,7 +132,7 @@ public void shouldGenerateCertFromVaultResource() {
public void shouldCheckIfCertificateHasChangedAndReturnFalse() throws SecretNotAccessibleException {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("certificate").withNamespace("default").build()
new ObjectMetaBuilder().withName("certificate").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);
VaultSpec spec = new VaultSpec();
spec.setType(VaultType.CERT);
Expand Down Expand Up @@ -167,7 +169,7 @@ public void shouldCheckIfCertificateHasChangedAndReturnFalse() throws SecretNotA
public void shouldCheckIfCertificateHasChangedAndReturnTrue() throws SecretNotAccessibleException {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("certificate").withNamespace("default").build()
new ObjectMetaBuilder().withName("certificate").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);
VaultSpec spec = new VaultSpec();
spec.setType(VaultType.CERT);
Expand Down
9 changes: 5 additions & 4 deletions src/test/java/de/koudingspawn/vault/DockerCfgTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.io.IOException;
import java.util.Base64;
import java.util.UUID;

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
Expand Down Expand Up @@ -86,7 +87,7 @@ public void before() {
public void shouldGenerateDockerCfgFromVaultResource() throws IOException {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("dockercfg").withNamespace("default").build()
new ObjectMetaBuilder().withName("dockercfg").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);
VaultSpec spec = new VaultSpec();
spec.setType(VaultType.DOCKERCFG);
Expand Down Expand Up @@ -142,7 +143,7 @@ public void shouldGenerateDockerCfgFromVaultResource() throws IOException {
public void shouldCheckIfDockerCfgHasChangedAndReturnTrue() throws SecretNotAccessibleException {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("dockercfg").withNamespace("default").build()
new ObjectMetaBuilder().withName("dockercfg").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);
VaultSpec spec = new VaultSpec();
spec.setType(VaultType.DOCKERCFG);
Expand Down Expand Up @@ -174,7 +175,7 @@ public void shouldCheckIfDockerCfgHasChangedAndReturnTrue() throws SecretNotAcce
public void shouldCheckIfDockerCfgHasChangedAndReturnFalse() throws SecretNotAccessibleException {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("dockercfg").withNamespace("default").build()
new ObjectMetaBuilder().withName("dockercfg").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);
VaultSpec spec = new VaultSpec();
spec.setType(VaultType.DOCKERCFG);
Expand All @@ -197,7 +198,7 @@ public void shouldCheckIfDockerCfgHasChangedAndReturnFalse() throws SecretNotAcc
public void shouldGenerateDockerCfgV2() throws JsonProcessingException {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("dockercfg").withNamespace("default").build()
new ObjectMetaBuilder().withName("dockercfg").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);
VaultSpec spec = new VaultSpec();
spec.setType(VaultType.DOCKERCFG);
Expand Down
10 changes: 6 additions & 4 deletions src/test/java/de/koudingspawn/vault/KeyValueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.springframework.context.annotation.Primary;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.UUID;

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static com.github.tomakehurst.wiremock.stubbing.Scenario.STARTED;
Expand Down Expand Up @@ -77,7 +79,7 @@ public void before() {
public void shouldGenerateSimpleSecretFromVaultCustomResource() {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("simple").withNamespace("default").build());
new ObjectMetaBuilder().withName("simple").withNamespace("default").withUid(UUID.randomUUID().toString()).build());
VaultSpec vaultSpec = new VaultSpec();
vaultSpec.setType(VaultType.KEYVALUE);
vaultSpec.setPath("secret/simple");
Expand All @@ -104,7 +106,7 @@ public void shouldGenerateSimpleSecretFromVaultCustomResource() {
public void shouldCheckIfSimpleSecretHasChangedAndReturnTrue() throws SecretNotAccessibleException {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("simple").withNamespace("default").build());
new ObjectMetaBuilder().withName("simple").withNamespace("default").withUid(UUID.randomUUID().toString()).build());
VaultSpec vaultSpec = new VaultSpec();
vaultSpec.setType(VaultType.KEYVALUE);
vaultSpec.setPath("secret/simple");
Expand Down Expand Up @@ -136,7 +138,7 @@ public void shouldCheckIfSimpleSecretHasChangedAndReturnTrue() throws SecretNotA
public void shouldCheckIfSimpleSecretHasChangedAndReturnFalse() throws SecretNotAccessibleException {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("simple").withNamespace("default").build());
new ObjectMetaBuilder().withName("simple").withNamespace("default").withUid(UUID.randomUUID().toString()).build());
VaultSpec vaultSpec = new VaultSpec();
vaultSpec.setType(VaultType.KEYVALUE);
vaultSpec.setPath("secret/simple");
Expand All @@ -157,7 +159,7 @@ public void shouldCheckIfSimpleSecretHasChangedAndReturnFalse() throws SecretNot
public void preventNullPointerExceptionWhenSecretDoesNotExist() {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("simple").withNamespace("default").build());
new ObjectMetaBuilder().withName("simple").withNamespace("default").withUid(UUID.randomUUID().toString()).build());
VaultSpec vaultSpec = new VaultSpec();
vaultSpec.setType(VaultType.KEYVALUE);
vaultSpec.setPath("secret/simple");
Expand Down
10 changes: 6 additions & 4 deletions src/test/java/de/koudingspawn/vault/KeyValueV2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.UUID;

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static com.github.tomakehurst.wiremock.stubbing.Scenario.STARTED;
Expand Down Expand Up @@ -79,7 +81,7 @@ public void before() {
public void shouldGenerateSimpleSecretFromVaultCustomResource() {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("simple").withNamespace("default").build());
new ObjectMetaBuilder().withName("simple").withNamespace("default").withUid(UUID.randomUUID().toString()).build());
VaultSpec vaultSpec = new VaultSpec();
vaultSpec.setType(VaultType.KEYVALUEV2);
vaultSpec.setPath("secret/simple");
Expand Down Expand Up @@ -125,7 +127,7 @@ public void shouldGenerateSimpleSecretFromVaultCustomResource() {
public void shouldCheckIfSimpleSecretHasChangedAndReturnTrue() throws SecretNotAccessibleException {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("simple").withNamespace("default").build());
new ObjectMetaBuilder().withName("simple").withNamespace("default").withUid(UUID.randomUUID().toString()).build());
VaultSpec vaultSpec = new VaultSpec();
vaultSpec.setType(VaultType.KEYVALUEV2);
vaultSpec.setPath("secret/simple");
Expand Down Expand Up @@ -195,7 +197,7 @@ public void shouldCheckIfSimpleSecretHasChangedAndReturnTrue() throws SecretNotA
public void shouldCheckIfSimpleSecretHasChangedAndReturnFalse() throws SecretNotAccessibleException {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("simple").withNamespace("default").build());
new ObjectMetaBuilder().withName("simple").withNamespace("default").withUid(UUID.randomUUID().toString()).build());
VaultSpec vaultSpec = new VaultSpec();
vaultSpec.setType(VaultType.KEYVALUEV2);
vaultSpec.setPath("secret/simple");
Expand Down Expand Up @@ -235,7 +237,7 @@ public void shouldCheckIfSimpleSecretHasChangedAndReturnFalse() throws SecretNot
public void shouldSupportNestedPath() {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("simple").withNamespace("default").build());
new ObjectMetaBuilder().withName("simple").withNamespace("default").withUid(UUID.randomUUID().toString()).build());
VaultSpec vaultSpec = new VaultSpec();
vaultSpec.setType(VaultType.KEYVALUEV2);
vaultSpec.setPath("secret/simple/nested");
Expand Down
7 changes: 2 additions & 5 deletions src/test/java/de/koudingspawn/vault/PKIChainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Base64;
import java.util.Collections;
import java.util.Date;
import java.util.TimeZone;
import java.util.*;

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
Expand Down Expand Up @@ -252,7 +249,7 @@ private VaultResponseData generateKeyPair() {
private Vault generateVaultResource() {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("pki").withNamespace("default").build()
new ObjectMetaBuilder().withName("pki").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);

VaultSpec spec = new VaultSpec();
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/de/koudingspawn/vault/PKITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Base64;
import java.util.Date;
import java.util.TimeZone;
import java.util.UUID;

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
Expand Down Expand Up @@ -184,7 +185,7 @@ private VaultResponseData generateKeyPair(Date startDate, long valid) throws Exc
private Vault generateVaultResource() {
Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("pki").withNamespace("default").build()
new ObjectMetaBuilder().withName("pki").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);

VaultSpec spec = new VaultSpec();
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/de/koudingspawn/vault/PropertiesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.nio.file.Files;
import java.util.Base64;
import java.util.HashMap;
import java.util.UUID;

import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static de.koudingspawn.vault.Constants.LAST_UPDATE_ANNOTATION;
Expand Down Expand Up @@ -130,7 +131,7 @@ private Vault generatePropertiesManifest() throws IOException {

Vault vault = new Vault();
vault.setMetadata(
new ObjectMetaBuilder().withName("properties").withNamespace("default").build()
new ObjectMetaBuilder().withName("properties").withNamespace("default").withUid(UUID.randomUUID().toString()).build()
);
vault.setSpec(vaultSpec);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.test.context.junit4.SpringRunner;

import java.util.HashMap;
import java.util.UUID;

import static de.koudingspawn.vault.Constants.COMPARE_ANNOTATION;
import static org.junit.Assert.*;
Expand Down Expand Up @@ -158,6 +159,7 @@ private Vault generateVault() {
ObjectMeta meta = new ObjectMeta();
meta.setNamespace(NAMESPACE);
meta.setName(SECRETNAME);
meta.setUid(UUID.randomUUID().toString());
vault.setMetadata(meta);

return vault;
Expand Down

0 comments on commit 19d219a

Please sign in to comment.