diff options
author | pawel <pawel.kasperkiewicz@nokia.com> | 2019-11-06 12:38:18 +0100 |
---|---|---|
committer | awudzins <adam.wudzinski@nokia.com> | 2019-11-08 10:26:13 +0100 |
commit | 4b7a95ec2282fadb00c419a96c00b62f8a1d4028 (patch) | |
tree | 596963ff3e2d029e0e8ce501b8b5f74d25011341 /src/test/java/org/onap/dcae/TLSTest.java | |
parent | f6689f93640789c7d960eef879ef7cfce1b285d1 (diff) |
Remove certOnly and basicAuth from authentication methods
Issue-ID: DCAEGEN2-1776
Signed-off-by: pawel <pawel.kasperkiewicz@nokia.com>
Change-Id: I475dcce9de8c7c05d2a05cf51dc862b5bf920164
Diffstat (limited to 'src/test/java/org/onap/dcae/TLSTest.java')
-rw-r--r-- | src/test/java/org/onap/dcae/TLSTest.java | 58 |
1 files changed, 4 insertions, 54 deletions
diff --git a/src/test/java/org/onap/dcae/TLSTest.java b/src/test/java/org/onap/dcae/TLSTest.java index 49a089cc..e55b6052 100644 --- a/src/test/java/org/onap/dcae/TLSTest.java +++ b/src/test/java/org/onap/dcae/TLSTest.java @@ -32,8 +32,8 @@ import org.springframework.http.HttpStatus; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.when; -import static org.onap.dcae.TLSTest.HttpsConfiguration.USERNAME; -import static org.onap.dcae.TLSTest.HttpsConfiguration.PASSWORD; +import static org.onap.dcae.TLSTest.HttpsConfigurationWithTLSAuthenticationAndBasicAuth.USERNAME; +import static org.onap.dcae.TLSTest.HttpsConfigurationWithTLSAuthenticationAndBasicAuth.PASSWORD; public class TLSTest extends TLSTestBase { @@ -53,37 +53,6 @@ public class TLSTest extends TLSTestBase { } @Nested - @Import(HttpsConfiguration.class) - class HttpsTest extends TestClassBase { - - - @Test - public void shouldHttpsRequestWithoutBasicAuthFail() { - assertThrows(Exception.class, this::makeHttpsRequest); - } - - @Test - public void shouldHttpsRequestWithBasicAuthSucceed() { - assertEquals(HttpStatus.OK, makeHttpsRequestWithBasicAuth(USERNAME, PASSWORD).getStatusCode()); - } - } - - @Nested - @Import(HttpsConfigurationWithTLSAuthentication.class) - class HttpsWithTLSAuthenticationTest extends TestClassBase { - - @Test - public void shouldHttpsRequestWithoutCertificateFail() { - assertThrows(Exception.class, this::makeHttpsRequest); - } - - @Test - public void shouldHttpsRequestWithCertificateSucceed() { - assertEquals(HttpStatus.OK, makeHttpsRequestWithClientCert().getStatusCode()); - } - } - - @Nested @Import(HttpsConfigurationWithTLSAuthenticationAndBasicAuth.class) class HttpsWithTLSAuthenticationAndBasicAuthTest extends TestClassBase { @@ -107,38 +76,19 @@ public class TLSTest extends TLSTestBase { } } - static class HttpsConfiguration extends TLSTestBase.ConfigurationBase { + static class HttpsConfigurationWithTLSAuthenticationAndBasicAuth extends TLSTestBase.ConfigurationBase { public static final String USERNAME = "TestUser"; public static final String PASSWORD = "TestPassword"; - @Override protected void configureSettings(ApplicationSettings settings) { when(settings.keystoreFileLocation()).thenReturn(KEYSTORE.toString()); when(settings.keystorePasswordFileLocation()).thenReturn(KEYSTORE_PASSWORD_FILE.toString()); - when(settings.authMethod()).thenReturn(AuthMethodType.BASIC_AUTH.value()); when(settings.validAuthorizationCredentials()).thenReturn(HashMap.of(USERNAME, "$2a$10$51tDgG2VNLde5E173Ay/YO.Fq.aD.LR2Rp8pY3QAKriOSPswvGviy")); - when(settings.httpPort()).thenReturn(1111); - } - } - - static class HttpsConfigurationWithTLSAuthentication extends HttpsConfiguration { - @Override - protected void configureSettings(ApplicationSettings settings) { - super.configureSettings(settings); - when(settings.authMethod()).thenReturn(AuthMethodType.CERT_ONLY.value()); + when(settings.authMethod()).thenReturn(AuthMethodType.CERT_BASIC_AUTH.value()); when(settings.truststoreFileLocation()).thenReturn(TRUSTSTORE.toString()); when(settings.truststorePasswordFileLocation()).thenReturn(TRUSTSTORE_PASSWORD_FILE.toString()); when(settings.certSubjectMatcher()).thenReturn(CERT_SUBJECT_MATCHER.toString()); when(settings.httpPort()).thenReturn(1111); } } - - static class HttpsConfigurationWithTLSAuthenticationAndBasicAuth extends HttpsConfigurationWithTLSAuthentication { - @Override - protected void configureSettings(ApplicationSettings settings) { - super.configureSettings(settings); - when(settings.authMethod()).thenReturn(AuthMethodType.CERT_BASIC_AUTH.value()); - when(settings.httpPort()).thenReturn(1111); - } - } }
\ No newline at end of file |