aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@yahooinc.com>2023-02-06 13:00:02 +0100
committerBjørn Christian Seime <bjorncs@yahooinc.com>2023-02-06 13:00:02 +0100
commitbc3ce2d5e0b385c6c469ce174a1ee746fb813000 (patch)
tree908ad57bca1963d17c73f84f4dd09b478ab738a6
parentc1ceb4407c3f6f035abac5d89f326c892a39cabd (diff)
Add test case with missing cluster type
-rw-r--r--vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/IdentityDocumentSignerTest.java35
1 files changed, 25 insertions, 10 deletions
diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/IdentityDocumentSignerTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/IdentityDocumentSignerTest.java
index 13feb4b3b29..f53518d9a07 100644
--- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/IdentityDocumentSignerTest.java
+++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/IdentityDocumentSignerTest.java
@@ -25,19 +25,20 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class IdentityDocumentSignerTest {
public static final int KEY_VERSION = 0;
+ private static final IdentityType identityType = TENANT;
+ private static final VespaUniqueInstanceId id =
+ new VespaUniqueInstanceId(1, "cluster-id", "instance", "application", "tenant", "region", "environment", identityType);
+ private static final AthenzService providerService = new AthenzService("vespa", "service");
+ private static final KeyPair keyPair = KeyUtils.generateKeypair(KeyAlgorithm.RSA);
+ private static final String configserverHostname = "configserverhostname";
+ private static final String instanceHostname = "instancehostname";
+ private static final Instant createdAt = Instant.EPOCH;
+ private static final HashSet<String> ipAddresses = new HashSet<>(Arrays.asList("1.2.3.4", "::1"));
+ private static final ClusterType clusterType = ClusterType.CONTAINER;
+
@Test
void generates_and_validates_signature() {
IdentityDocumentSigner signer = new IdentityDocumentSigner();
- IdentityType identityType = TENANT;
- VespaUniqueInstanceId id =
- new VespaUniqueInstanceId(1, "cluster-id", "instance", "application", "tenant", "region", "environment", identityType);
- AthenzService providerService = new AthenzService("vespa", "service");
- KeyPair keyPair = KeyUtils.generateKeypair(KeyAlgorithm.RSA);
- String configserverHostname = "configserverhostname";
- String instanceHostname = "instancehostname";
- Instant createdAt = Instant.EPOCH;
- HashSet<String> ipAddresses = new HashSet<>(Arrays.asList("1.2.3.4", "::1"));
- var clusterType = ClusterType.CONTAINER;
String signature =
signer.generateSignature(id, providerService, configserverHostname, instanceHostname, createdAt,
ipAddresses, identityType, clusterType, keyPair.getPrivate());
@@ -49,4 +50,18 @@ public class IdentityDocumentSignerTest {
assertTrue(signer.hasValidSignature(signedIdentityDocument, keyPair.getPublic()));
}
+ @Test
+ void handles_missing_cluster_type() {
+ IdentityDocumentSigner signer = new IdentityDocumentSigner();
+ String signature =
+ signer.generateSignature(id, providerService, configserverHostname, instanceHostname, createdAt,
+ ipAddresses, identityType, /*clusterType*/null, keyPair.getPrivate());
+
+ SignedIdentityDocument signedIdentityDocument = new SignedIdentityDocument(
+ signature, KEY_VERSION, id, providerService, DEFAULT_DOCUMENT_VERSION, configserverHostname,
+ instanceHostname, createdAt, ipAddresses, identityType, /*clusterType*/null);
+
+ assertTrue(signer.hasValidSignature(signedIdentityDocument, keyPair.getPublic()));
+ }
+
} \ No newline at end of file