From f7af861b31b61c828f44315b852bb31f90fe6ee9 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Fri, 23 Jul 2021 14:09:03 -0500 Subject: [PATCH] Migrate SecureStorageControllerTest to JUnit 5 --- .../SecureStorageControllerTest.java | 38 +++++++++---------- .../VoiceVerificationControllerTest.java | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/SecureStorageControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/SecureStorageControllerTest.java index 6e4fdb106..94fb62361 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/SecureStorageControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/SecureStorageControllerTest.java @@ -5,10 +5,16 @@ package org.whispersystems.textsecuregcm.tests.controllers; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + import com.google.common.collect.ImmutableSet; +import io.dropwizard.auth.PolymorphicAuthValueFactoryProvider; +import io.dropwizard.testing.junit5.DropwizardExtensionsSupport; +import io.dropwizard.testing.junit5.ResourceExtension; +import javax.ws.rs.core.Response; import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.whispersystems.textsecuregcm.auth.DisabledPermittedAccount; import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentialGenerator; import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentials; @@ -17,28 +23,22 @@ import org.whispersystems.textsecuregcm.storage.Account; import org.whispersystems.textsecuregcm.tests.util.AuthHelper; import org.whispersystems.textsecuregcm.util.SystemMapper; -import javax.ws.rs.core.Response; - -import io.dropwizard.auth.PolymorphicAuthValueFactoryProvider; -import io.dropwizard.testing.junit.ResourceTestRule; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; - -public class SecureStorageControllerTest { +@ExtendWith(DropwizardExtensionsSupport.class) +class SecureStorageControllerTest { private static final ExternalServiceCredentialGenerator storageCredentialGenerator = new ExternalServiceCredentialGenerator(new byte[32], new byte[32], false); - @ClassRule - public static final ResourceTestRule resources = ResourceTestRule.builder() - .addProvider(AuthHelper.getAuthFilter()) - .addProvider(new PolymorphicAuthValueFactoryProvider.Binder<>(ImmutableSet.of(Account.class, DisabledPermittedAccount.class))) - .setMapper(SystemMapper.getMapper()) - .setTestContainerFactory(new GrizzlyWebTestContainerFactory()) - .addResource(new SecureStorageController(storageCredentialGenerator)) - .build(); + private static final ResourceExtension resources = ResourceExtension.builder() + .addProvider(AuthHelper.getAuthFilter()) + .addProvider(new PolymorphicAuthValueFactoryProvider.Binder<>(ImmutableSet.of(Account.class, DisabledPermittedAccount.class))) + .setMapper(SystemMapper.getMapper()) + .setTestContainerFactory(new GrizzlyWebTestContainerFactory()) + .addResource(new SecureStorageController(storageCredentialGenerator)) + .build(); @Test - public void testGetCredentials() throws Exception { + void testGetCredentials() throws Exception { ExternalServiceCredentials credentials = resources.getJerseyTest() .target("/v1/storage/auth") .request() @@ -50,7 +50,7 @@ public class SecureStorageControllerTest { } @Test - public void testGetCredentialsBadAuth() throws Exception { + void testGetCredentialsBadAuth() throws Exception { Response response = resources.getJerseyTest() .target("/v1/storage/auth") .request() diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/VoiceVerificationControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/VoiceVerificationControllerTest.java index d9d546b7a..a6381de15 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/VoiceVerificationControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/VoiceVerificationControllerTest.java @@ -26,7 +26,7 @@ import org.whispersystems.textsecuregcm.tests.util.AuthHelper; import org.whispersystems.textsecuregcm.util.SystemMapper; @ExtendWith(DropwizardExtensionsSupport.class) -public class VoiceVerificationControllerTest { +class VoiceVerificationControllerTest { private static final ResourceExtension resources = ResourceExtension.builder() .addProvider(AuthHelper.getAuthFilter())