aboutsummaryrefslogtreecommitdiffstats
path: root/athenz-identity-provider-service/src/test/java/com/yahoo/vespa
diff options
context:
space:
mode:
Diffstat (limited to 'athenz-identity-provider-service/src/test/java/com/yahoo/vespa')
-rw-r--r--athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/IdentityDocumentGeneratorTest.java32
-rw-r--r--athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidatorTest.java28
-rw-r--r--athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/CertificatesTest.java16
-rw-r--r--athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/CertificateAuthorityApiTest.java68
-rw-r--r--athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/ContainerTester.java10
-rw-r--r--athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/InstanceSerializerTest.java38
6 files changed, 96 insertions, 96 deletions
diff --git a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/IdentityDocumentGeneratorTest.java b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/IdentityDocumentGeneratorTest.java
index 508124935c1..9205baff0fc 100644
--- a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/IdentityDocumentGeneratorTest.java
+++ b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/IdentityDocumentGeneratorTest.java
@@ -25,14 +25,14 @@ import com.yahoo.vespa.hosted.provision.node.Generation;
import com.yahoo.vespa.hosted.provision.node.IP;
import com.yahoo.vespa.hosted.provision.node.Nodes;
import com.yahoo.vespa.hosted.provision.testutils.MockNodeFlavors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Optional;
import java.util.Set;
import static com.yahoo.vespa.hosted.athenz.instanceproviderservice.TestUtils.getAthenzProviderConfig;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -45,27 +45,27 @@ public class IdentityDocumentGeneratorTest {
private static final Zone ZONE = new Zone(SystemName.cd, Environment.dev, RegionName.from("us-north-1"));
@Test
- public void generates_valid_identity_document() {
+ void generates_valid_identity_document() {
String parentHostname = "docker-host";
String containerHostname = "docker-container";
ApplicationId appid = ApplicationId.from(
TenantName.from("tenant"), ApplicationName.from("application"), InstanceName.from("default"));
Allocation allocation = new Allocation(appid,
- ClusterMembership.from("container/default/0/0", Version.fromString("1.2.3"), Optional.empty()),
- new NodeResources(1, 1, 1, 1),
- Generation.initial(),
- false);
+ ClusterMembership.from("container/default/0/0", Version.fromString("1.2.3"), Optional.empty()),
+ new NodeResources(1, 1, 1, 1),
+ Generation.initial(),
+ false);
Node parentNode = Node.create("ostkid",
- IP.Config.ofEmptyPool(Set.of("127.0.0.1")),
- parentHostname,
- new MockNodeFlavors().getFlavorOrThrow("default"),
- NodeType.host).build();
+ IP.Config.ofEmptyPool(Set.of("127.0.0.1")),
+ parentHostname,
+ new MockNodeFlavors().getFlavorOrThrow("default"),
+ NodeType.host).build();
Node containerNode = Node.reserve(Set.of("::1"),
- containerHostname,
- parentHostname,
- new MockNodeFlavors().getFlavorOrThrow("default").resources(),
- NodeType.tenant)
+ containerHostname,
+ parentHostname,
+ new MockNodeFlavors().getFlavorOrThrow("default").resources(),
+ NodeType.tenant)
.allocation(allocation).build();
NodeRepository nodeRepository = mock(NodeRepository.class);
Nodes nodes = mock(Nodes.class);
diff --git a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidatorTest.java b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidatorTest.java
index 6dc2e58059f..9a91d7372da 100644
--- a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidatorTest.java
+++ b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/InstanceValidatorTest.java
@@ -25,7 +25,7 @@ import com.yahoo.vespa.hosted.provision.NodeRepository;
import com.yahoo.vespa.hosted.provision.node.IP;
import com.yahoo.vespa.hosted.provision.node.Nodes;
import com.yahoo.vespa.hosted.provision.testutils.MockNodeFlavors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.time.Instant;
import java.util.ArrayList;
@@ -42,8 +42,8 @@ import java.util.stream.Stream;
import static com.yahoo.vespa.hosted.athenz.instanceproviderservice.InstanceValidator.SERVICE_PROPERTIES_DOMAIN_KEY;
import static com.yahoo.vespa.hosted.athenz.instanceproviderservice.InstanceValidator.SERVICE_PROPERTIES_SERVICE_KEY;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -62,14 +62,14 @@ public class InstanceValidatorTest {
private final AthenzService vespaTenantDomain = new AthenzService("vespa.vespa.tenant");
@Test
- public void application_does_not_exist() {
+ void application_does_not_exist() {
SuperModelProvider superModelProvider = mockSuperModelProvider();
InstanceValidator instanceValidator = new InstanceValidator(null, superModelProvider, null, null, vespaTenantDomain);
assertFalse(instanceValidator.isValidInstance(createRegisterInstanceConfirmation(applicationId, domain, service)));
}
@Test
- public void application_does_not_have_domain_set() {
+ void application_does_not_have_domain_set() {
SuperModelProvider superModelProvider = mockSuperModelProvider(
mockApplicationInfo(applicationId, 5, Collections.emptyList()));
InstanceValidator instanceValidator = new InstanceValidator(null, superModelProvider, null, new IdentityDocumentSigner(), vespaTenantDomain);
@@ -78,9 +78,9 @@ public class InstanceValidatorTest {
}
@Test
- public void application_has_wrong_domain() {
+ void application_has_wrong_domain() {
ServiceInfo serviceInfo = new ServiceInfo("serviceName", "type", Collections.emptyList(),
- Collections.singletonMap(SERVICE_PROPERTIES_DOMAIN_KEY, "not-domain"), "confId", "hostName");
+ Collections.singletonMap(SERVICE_PROPERTIES_DOMAIN_KEY, "not-domain"), "confId", "hostName");
SuperModelProvider superModelProvider = mockSuperModelProvider(
mockApplicationInfo(applicationId, 5, Collections.singletonList(serviceInfo)));
@@ -90,13 +90,13 @@ public class InstanceValidatorTest {
}
@Test
- public void application_has_same_domain_and_service() {
+ void application_has_same_domain_and_service() {
Map<String, String> properties = new HashMap<>();
properties.put(SERVICE_PROPERTIES_DOMAIN_KEY, domain);
properties.put(SERVICE_PROPERTIES_SERVICE_KEY, service);
ServiceInfo serviceInfo = new ServiceInfo("serviceName", "type", Collections.emptyList(),
- properties, "confId", "hostName");
+ properties, "confId", "hostName");
SuperModelProvider superModelProvider = mockSuperModelProvider(
mockApplicationInfo(applicationId, 5, Collections.singletonList(serviceInfo)));
@@ -108,7 +108,7 @@ public class InstanceValidatorTest {
}
@Test
- public void rejects_invalid_provider_unique_id_in_csr() {
+ void rejects_invalid_provider_unique_id_in_csr() {
SuperModelProvider superModelProvider = mockSuperModelProvider();
InstanceValidator instanceValidator = new InstanceValidator(null, superModelProvider, null, null, vespaTenantDomain);
InstanceConfirmation instanceConfirmation = createRegisterInstanceConfirmation(applicationId, domain, service);
@@ -118,7 +118,7 @@ public class InstanceValidatorTest {
}
@Test
- public void rejects_unknown_ips_in_csr() {
+ void rejects_unknown_ips_in_csr() {
NodeRepository nodeRepository = mockNodeRepo();
InstanceValidator instanceValidator = new InstanceValidator(null, mockSuperModelProvider(), nodeRepository, null, vespaTenantDomain);
InstanceConfirmation instanceConfirmation = createRegisterInstanceConfirmation(applicationId, domain, service);
@@ -134,7 +134,7 @@ public class InstanceValidatorTest {
}
@Test
- public void accepts_valid_refresh_requests() {
+ void accepts_valid_refresh_requests() {
NodeRepository nodeRepository = mock(NodeRepository.class);
Nodes nodes = mock(Nodes.class);
when(nodeRepository.nodes()).thenReturn(nodes);
@@ -151,7 +151,7 @@ public class InstanceValidatorTest {
}
@Test
- public void rejects_refresh_on_ip_mismatch() {
+ void rejects_refresh_on_ip_mismatch() {
NodeRepository nodeRepository = mockNodeRepo();
InstanceValidator instanceValidator = new InstanceValidator(null, null, nodeRepository, new IdentityDocumentSigner(), vespaTenantDomain);
@@ -169,7 +169,7 @@ public class InstanceValidatorTest {
}
@Test
- public void rejects_refresh_when_node_is_not_allocated() {
+ void rejects_refresh_when_node_is_not_allocated() {
NodeRepository nodeRepository = mock(NodeRepository.class);
Nodes nodes = mock(Nodes.class);
when(nodeRepository.nodes()).thenReturn(nodes);
diff --git a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/CertificatesTest.java b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/CertificatesTest.java
index 19ee3d22330..dd3ddeeb804 100644
--- a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/CertificatesTest.java
+++ b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/CertificatesTest.java
@@ -5,7 +5,7 @@ import com.yahoo.security.KeyAlgorithm;
import com.yahoo.security.KeyUtils;
import com.yahoo.security.SubjectAlternativeName;
import com.yahoo.test.ManualClock;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.security.KeyPair;
import java.security.cert.X509Certificate;
@@ -13,8 +13,8 @@ import java.time.Duration;
import java.util.List;
import static java.time.temporal.ChronoUnit.SECONDS;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author mpolden
@@ -25,7 +25,7 @@ public class CertificatesTest {
private final X509Certificate caCertificate = CertificateTester.createCertificate("CA", keyPair);
@Test
- public void expiry() {
+ void expiry() {
var clock = new ManualClock();
var certificates = new Certificates(clock);
var csr = CertificateTester.createCsr();
@@ -37,7 +37,7 @@ public class CertificatesTest {
}
@Test
- public void add_san_from_csr() throws Exception {
+ void add_san_from_csr() throws Exception {
var certificates = new Certificates(new ManualClock());
var dnsName = "host.example.com";
var ip = "192.0.2.42";
@@ -49,13 +49,13 @@ public class CertificatesTest {
var subjectAlternativeNames = List.copyOf(certificate.getSubjectAlternativeNames());
assertEquals(List.of(SubjectAlternativeName.Type.DNS.getTag(), dnsName),
- subjectAlternativeNames.get(0));
+ subjectAlternativeNames.get(0));
assertEquals(List.of(SubjectAlternativeName.Type.IP.getTag(), ip),
- subjectAlternativeNames.get(1));
+ subjectAlternativeNames.get(1));
}
@Test
- public void parse_instance_id() {
+ void parse_instance_id() {
var instanceId = "1.cluster1.default.app1.tenant1.us-north-1.prod.node";
var instanceIdWithSuffix = instanceId + ".instanceid.athenz.dev-us-north-1.vespa.aws.oath.cloud";
var csr = CertificateTester.createCsr(List.of("foo", "bar", instanceIdWithSuffix));
diff --git a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/CertificateAuthorityApiTest.java b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/CertificateAuthorityApiTest.java
index 7bfc4ad41a4..bf2115e8759 100644
--- a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/CertificateAuthorityApiTest.java
+++ b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/CertificateAuthorityApiTest.java
@@ -17,8 +17,8 @@ import com.yahoo.vespa.athenz.client.zts.DefaultZtsClient;
import com.yahoo.vespa.hosted.ca.CertificateTester;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpUriRequest;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import javax.net.ssl.SSLContext;
import java.net.URI;
@@ -28,9 +28,9 @@ import java.security.cert.X509Certificate;
import java.util.List;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author mpolden
@@ -45,25 +45,25 @@ public class CertificateAuthorityApiTest extends ContainerTester {
private static final String CONTAINER_IDENTITY = "vespa.external.tenant";
private static final String HOST_IDENTITY = "vespa.external.tenant-host";
- @Before
+ @BeforeEach
public void before() {
setCaCertificateAndKey();
}
@Test
- public void register_instance() throws Exception {
+ void register_instance() throws Exception {
// POST instance registration
var csr = CertificateTester.createCsr(List.of("node1.example.com", INSTANCE_ID_WITH_SUFFIX));
assertIdentityResponse(new Request("http://localhost:12345/ca/v1/instance/",
- instanceRegistrationJson(csr),
- Request.Method.POST));
+ instanceRegistrationJson(csr),
+ Request.Method.POST));
// POST instance registration with ZTS client
var ztsClient = new TestZtsClient(new AthenzPrincipal(new AthenzService(HOST_IDENTITY)), null, URI.create("http://localhost:12345/ca/v1/"), SSLContext.getDefault());
var instanceIdentity = ztsClient.registerInstance(new AthenzService("vespa.external", "provider_prod_us-north-1"),
- new AthenzService(CONTAINER_IDENTITY),
- getAttestationData(),
- csr);
+ new AthenzService(CONTAINER_IDENTITY),
+ getAttestationData(),
+ csr);
assertEquals("CN=Vespa CA", instanceIdentity.certificate().getIssuerX500Principal().getName());
}
@@ -84,7 +84,7 @@ public class CertificateAuthorityApiTest extends ContainerTester {
}
@Test
- public void refresh_instance() throws Exception {
+ void refresh_instance() throws Exception {
// Register instance to get cert
var certificate = registerInstance();
@@ -92,41 +92,41 @@ public class CertificateAuthorityApiTest extends ContainerTester {
var principal = new AthenzPrincipal(new AthenzService(CONTAINER_IDENTITY));
var csr = CertificateTester.createCsr(principal.getIdentity().getFullName(), List.of("node1.example.com", INSTANCE_ID_WITH_SUFFIX));
var request = new Request("http://localhost:12345/ca/v1/instance/vespa.external.provider_prod_us-north-1/vespa.external/tenant/" + INSTANCE_ID,
- instanceRefreshJson(csr),
- Request.Method.POST,
- principal);
+ instanceRefreshJson(csr),
+ Request.Method.POST,
+ principal);
request.getAttributes().put(RequestUtils.JDISC_REQUEST_X509CERT, new X509Certificate[]{certificate});
assertIdentityResponse(request);
// POST instance refresh with ZTS client
var ztsClient = new TestZtsClient(principal, certificate, URI.create("http://localhost:12345/ca/v1/"), SSLContext.getDefault());
var instanceIdentity = ztsClient.refreshInstance(new AthenzService("vespa.external", "provider_prod_us-north-1"),
- new AthenzService(CONTAINER_IDENTITY),
- INSTANCE_ID,
- csr);
+ new AthenzService(CONTAINER_IDENTITY),
+ INSTANCE_ID,
+ csr);
assertEquals("CN=Vespa CA", instanceIdentity.certificate().getIssuerX500Principal().getName());
}
@Test
- public void invalid_requests() throws Exception {
+ void invalid_requests() throws Exception {
// POST instance registration with missing fields
assertResponse(400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"POST http://localhost:12345/ca/v1/instance/ failed: Missing required field 'provider'\"}",
- new Request("http://localhost:12345/ca/v1/instance/",
- new byte[0],
- Request.Method.POST));
+ new Request("http://localhost:12345/ca/v1/instance/",
+ new byte[0],
+ Request.Method.POST));
// POST instance registration without DNS name in CSR
var csr = CertificateTester.createCsr();
var request = new Request("http://localhost:12345/ca/v1/instance/",
- instanceRegistrationJson(csr),
- Request.Method.POST);
+ instanceRegistrationJson(csr),
+ Request.Method.POST);
assertResponse(400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"POST http://localhost:12345/ca/v1/instance/ failed: No instance ID found in CSR\"}", request);
// POST instance refresh with missing field
assertResponse(400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"POST http://localhost:12345/ca/v1/instance/vespa.external.provider_prod_us-north-1/vespa.external/tenant/1.cluster1.default.app1.tenant1.us-north-1.prod.node failed: Missing required field 'csr'\"}",
- new Request("http://localhost:12345/ca/v1/instance/vespa.external.provider_prod_us-north-1/vespa.external/tenant/" + INSTANCE_ID,
- new byte[0],
- Request.Method.POST));
+ new Request("http://localhost:12345/ca/v1/instance/vespa.external.provider_prod_us-north-1/vespa.external/tenant/" + INSTANCE_ID,
+ new byte[0],
+ Request.Method.POST));
// POST instance refresh where instanceId does not match CSR dnsName
var principal = new AthenzPrincipal(new AthenzService(CONTAINER_IDENTITY));
@@ -148,9 +148,9 @@ public class CertificateAuthorityApiTest extends ContainerTester {
try {
var invalidCsr = CertificateTester.createCsr(principal.getIdentity().getFullName(), List.of("node1.example.com", INVALID_INSTANCE_ID_WITH_SUFFIX));
var instanceIdentity = ztsClient.refreshInstance(new AthenzService("vespa.external", "provider_prod_us-north-1"),
- new AthenzService(CONTAINER_IDENTITY),
- INSTANCE_ID,
- invalidCsr);
+ new AthenzService(CONTAINER_IDENTITY),
+ INSTANCE_ID,
+ invalidCsr);
fail("Refresh instance should have failed");
} catch (Exception e) {
String expectedMessage = "Received error from ZTS: code=0, message=\"POST http://localhost:12345/ca/v1/instance/vespa.external.provider_prod_us-north-1/vespa.external/tenant/1.cluster1.default.app1.tenant1.us-north-1.prod.node failed: Mismatch between instance ID in URL path and instance ID in CSR [instanceId=1.cluster1.default.app1.tenant1.us-north-1.prod.node,instanceIdFromCsr=1.cluster1.default.otherapp.othertenant.us-north-1.prod.node]\"";
@@ -174,9 +174,9 @@ public class CertificateAuthorityApiTest extends ContainerTester {
assertEquals("tenant", root.field("service").asString());
assertEquals(INSTANCE_ID, root.field("instanceId").asString());
var pemEncodedCertificate = root.field("x509Certificate").asString();
- assertTrue("Response contains PEM certificate",
- pemEncodedCertificate.startsWith("-----BEGIN CERTIFICATE-----") &&
- pemEncodedCertificate.endsWith("-----END CERTIFICATE-----\n"));
+ assertTrue(pemEncodedCertificate.startsWith("-----BEGIN CERTIFICATE-----") &&
+ pemEncodedCertificate.endsWith("-----END CERTIFICATE-----\n"),
+ "Response contains PEM certificate");
}, request);
}
diff --git a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/ContainerTester.java b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/ContainerTester.java
index ad0715cbbea..8112f5779e5 100644
--- a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/ContainerTester.java
+++ b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/ContainerTester.java
@@ -5,14 +5,14 @@ import com.yahoo.application.Networking;
import com.yahoo.application.container.JDisc;
import com.yahoo.application.container.handler.Request;
import com.yahoo.vespa.hosted.ca.restapi.mock.SecretStoreMock;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import java.io.UncheckedIOException;
import java.nio.charset.CharacterCodingException;
import java.util.function.Consumer;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* The superclass of REST API tests which require a functional container instance.
@@ -23,12 +23,12 @@ public class ContainerTester {
private JDisc container;
- @Before
+ @BeforeEach
public void startContainer() {
container = JDisc.fromServicesXml(servicesXml(), Networking.enable);
}
- @After
+ @AfterEach
public void stopContainer() {
container.close();
}
diff --git a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/InstanceSerializerTest.java b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/InstanceSerializerTest.java
index 904ebc65f35..df75e09b957 100644
--- a/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/InstanceSerializerTest.java
+++ b/athenz-identity-provider-service/src/test/java/com/yahoo/vespa/hosted/ca/restapi/InstanceSerializerTest.java
@@ -15,7 +15,7 @@ import com.yahoo.vespa.hosted.ca.CertificateTester;
import com.yahoo.vespa.hosted.ca.instance.InstanceIdentity;
import com.yahoo.vespa.hosted.ca.instance.InstanceRefresh;
import com.yahoo.vespa.hosted.ca.instance.InstanceRegistration;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.UncheckedIOException;
@@ -25,7 +25,7 @@ import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author mpolden
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertEquals;
public class InstanceSerializerTest {
@Test
- public void deserialize_instance_registration() {
+ void deserialize_instance_registration() {
var csr = CertificateTester.createCsr();
var csrPem = Pkcs10CsrUtils.toPem(csr);
SignedIdentityDocument signedIdentityDocument = new SignedIdentityDocument(
@@ -49,36 +49,36 @@ public class InstanceSerializerTest {
IdentityType.NODE);
var json = String.format("{\n" +
- " \"provider\": \"provider_prod_us-north-1\",\n" +
- " \"domain\": \"vespa.external\",\n" +
- " \"service\": \"tenant\",\n" +
- " \"attestationData\":\"%s\",\n" +
- " \"csr\": \"" + csrPem + "\"\n" +
- "}", StringUtilities.escape(EntityBindingsMapper.toAttestationData(signedIdentityDocument)));
+ " \"provider\": \"provider_prod_us-north-1\",\n" +
+ " \"domain\": \"vespa.external\",\n" +
+ " \"service\": \"tenant\",\n" +
+ " \"attestationData\":\"%s\",\n" +
+ " \"csr\": \"" + csrPem + "\"\n" +
+ "}", StringUtilities.escape(EntityBindingsMapper.toAttestationData(signedIdentityDocument)));
var instanceRegistration = new InstanceRegistration("provider_prod_us-north-1", "vespa.external",
- "tenant", signedIdentityDocument,
- csr);
+ "tenant", signedIdentityDocument,
+ csr);
var deserialized = InstanceSerializer.registrationFromSlime(SlimeUtils.jsonToSlime(json));
assertEquals(instanceRegistration, deserialized);
}
@Test
- public void serialize_instance_identity() {
+ void serialize_instance_identity() {
var certificate = CertificateTester.createCertificate();
var pem = X509CertificateUtils.toPem(certificate);
var identity = new InstanceIdentity("provider_prod_us-north-1", "tenant", "node1.example.com",
- Optional.of(certificate));
+ Optional.of(certificate));
var json = "{" +
- "\"provider\":\"provider_prod_us-north-1\"," +
- "\"service\":\"tenant\"," +
- "\"instanceId\":\"node1.example.com\"," +
- "\"x509Certificate\":\"" + pem.replace("\n", "\\n") + "\"" +
- "}";
+ "\"provider\":\"provider_prod_us-north-1\"," +
+ "\"service\":\"tenant\"," +
+ "\"instanceId\":\"node1.example.com\"," +
+ "\"x509Certificate\":\"" + pem.replace("\n", "\\n") + "\"" +
+ "}";
assertEquals(json, asJsonString(InstanceSerializer.identityToSlime(identity)));
}
@Test
- public void serialize_instance_refresh() {
+ void serialize_instance_refresh() {
var csr = CertificateTester.createCsr();
var csrPem = Pkcs10CsrUtils.toPem(csr);
var json = "{\"csr\": \"" + csrPem + "\"}";