aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-athenz/src/test
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@oath.com>2018-05-28 13:14:30 +0200
committerBjørn Christian Seime <bjorncs@oath.com>2018-05-28 13:14:30 +0200
commit6faa134c70c79a491c6130680da6b146d4685ec1 (patch)
treedddb09b1434d8eb73f4f75fa32a6e01a6a3e5c2d /vespa-athenz/src/test
parentc721dbc32a95a5a754464461bf154141ad6c5f07 (diff)
Remove deprecated identity-document entity types
Diffstat (limited to 'vespa-athenz/src/test')
-rw-r--r--vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/bindings/IdentityDocumentTest.java34
-rw-r--r--vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/AthenzIdentityProviderImplTest.java36
2 files changed, 24 insertions, 46 deletions
diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/bindings/IdentityDocumentTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/bindings/IdentityDocumentTest.java
deleted file mode 100644
index cfc6e33b911..00000000000
--- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/bindings/IdentityDocumentTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.yahoo.vespa.athenz.api.bindings;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-import com.google.common.collect.ImmutableSet;
-import com.yahoo.vespa.athenz.identityprovider.api.VespaUniqueInstanceId;
-import com.yahoo.vespa.athenz.identityprovider.api.bindings.IdentityDocument;
-import com.yahoo.vespa.athenz.identityprovider.api.bindings.ProviderUniqueId;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.time.Instant;
-
-import static org.junit.Assert.assertEquals;
-
-public class IdentityDocumentTest {
-
- @Test
- public void test_serialization_deserialization() throws IOException {
- IdentityDocument document = new IdentityDocument(
- ProviderUniqueId.fromVespaUniqueInstanceId(
- VespaUniqueInstanceId.fromDottedString("1.clusterId.instance.application.tenant.region.environment")),
- "cfg.prod.xyz",
- "foo.bar",
- Instant.now(),
- ImmutableSet.of("127.0.0.1", "::1"));
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.registerModule(new JavaTimeModule());
- String documentString = mapper.writeValueAsString(document);
- IdentityDocument deserializedDocument = mapper.readValue(documentString, IdentityDocument.class);
- assertEquals(document, deserializedDocument);
- }
-}
diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/AthenzIdentityProviderImplTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/AthenzIdentityProviderImplTest.java
index 98f0aa9b7ef..2e9b29f5327 100644
--- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/AthenzIdentityProviderImplTest.java
+++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/AthenzIdentityProviderImplTest.java
@@ -1,10 +1,18 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.identityprovider.client;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.yahoo.container.core.identity.IdentityConfig;
import com.yahoo.container.jdisc.athenz.AthenzIdentityProviderException;
import com.yahoo.jdisc.Metric;
import com.yahoo.test.ManualClock;
+import com.yahoo.vespa.athenz.api.AthenzService;
+import com.yahoo.vespa.athenz.identityprovider.api.EntityBindingsMapper;
+import com.yahoo.vespa.athenz.identityprovider.api.IdentityDocument;
+import com.yahoo.vespa.athenz.identityprovider.api.SignedIdentityDocument;
+import com.yahoo.vespa.athenz.identityprovider.api.VespaUniqueInstanceId;
import com.yahoo.vespa.athenz.tls.KeyStoreBuilder;
import com.yahoo.vespa.athenz.tls.KeyStoreUtils;
import org.junit.Rule;
@@ -15,10 +23,12 @@ import org.mockito.stubbing.Answer;
import java.io.File;
import java.io.IOException;
+import java.net.URI;
import java.security.KeyStore;
import java.security.cert.X509Certificate;
import java.time.Duration;
import java.time.Instant;
+import java.util.Collections;
import java.util.Date;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Supplier;
@@ -121,17 +131,19 @@ public class AthenzIdentityProviderImplTest {
return file;
}
- private static String getIdentityDocument() {
- return "{\n" +
- " \"identity-document\": \"eyJwcm92aWRlci11bmlxdWUtaWQiOnsidGVuYW50IjoidGVuYW50IiwiYXBwbGljYXRpb24iOiJhcHBsaWNhdGlvbiIsImVudmlyb25tZW50IjoiZGV2IiwicmVnaW9uIjoidXMtbm9ydGgtMSIsImluc3RhbmNlIjoiZGVmYXVsdCIsImNsdXN0ZXItaWQiOiJkZWZhdWx0IiwiY2x1c3Rlci1pbmRleCI6MH0sImNvbmZpZ3NlcnZlci1ob3N0bmFtZSI6ImxvY2FsaG9zdCIsImluc3RhbmNlLWhvc3RuYW1lIjoieC55LmNvbSIsImNyZWF0ZWQtYXQiOjE1MDg3NDgyODUuNzQyMDAwMDAwfQ==\",\n" +
- " \"signature\": \"kkEJB/98cy1FeXxzSjtvGH2a6BFgZu/9/kzCcAqRMZjENxnw5jyO1/bjZVzw2Sz4YHPsWSx2uxb32hiQ0U8rMP0zfA9nERIalSP0jB/hMU8laezGhdpk6VKZPJRC6YKAB9Bsv2qUIfMsSxkMqf66GUvjZAGaYsnNa2yHc1jIYHOGMeJO+HNPYJjGv26xPfAOPIKQzs3RmKrc3FoweTCsIwm5oblqekdJvVWYe0obwlOSB5uwc1zpq3Ie1QBFtJRuCGMVHg1pDPxXKBHLClGIrEvzLmICy6IRdHszSO5qiwujUD7sbrbM0sB/u0cYucxbcsGRUmBvme3UAw2mW9POVQ==\",\n" +
- " \"signing-key-version\": 0,\n" +
- " \"provider-unique-id\": \"tenant.application.dev.us-north-1.default.default.0\",\n" +
- " \"dns-suffix\": \"dnsSuffix\",\n" +
- " \"provider-service\": \"service\",\n" +
- " \"zts-endpoint\": \"localhost/zts\", \n" +
- " \"document-version\": 1\n" +
- "}";
-
+ private static String getIdentityDocument() throws JsonProcessingException {
+ VespaUniqueInstanceId instanceId = new VespaUniqueInstanceId(0, "default", "default", "application", "tenant", "us-north-1", "dev");
+ SignedIdentityDocument signedIdentityDocument = new SignedIdentityDocument(
+ new IdentityDocument(instanceId, "localhost", "x.y.com", Instant.EPOCH, Collections.emptySet()),
+ "dummysignature",
+ 0,
+ instanceId,
+ "dev-us-north-1.vespa.cloud",
+ new AthenzService("vespa.vespa.provider_dev_us-north-1"),
+ URI.create("https://zts:4443/zts/v1"),
+ 1);
+
+ return new ObjectMapper().registerModule(new JavaTimeModule())
+ .writeValueAsString(EntityBindingsMapper.toSignedIdentityDocumentEntity(signedIdentityDocument));
}
}