From 3309e4acf916703538c079fe8c42858e1e952ded Mon Sep 17 00:00:00 2001 From: pwielebs Date: Wed, 11 Mar 2020 12:42:39 +0100 Subject: Add UTs for remaining methods Issue-ID: AAF-996 Signed-off-by: pwielebs Change-Id: Id2407e66d012dce2b067a9ac3eaeb424bcf58095 --- .../configuration/EnvValidationUtilsTest.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvValidationUtilsTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvValidationUtilsTest.java index 8f4fe6a3..36b3b1a4 100644 --- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvValidationUtilsTest.java +++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/configuration/EnvValidationUtilsTest.java @@ -38,4 +38,40 @@ class EnvValidationUtilsTest { public void shouldRejectInvalidPath(String path){ assertFalse(EnvValidationUtils.isPathValid(path)); } + + @ParameterizedTest + @ValueSource(strings = {"PL", "DE", "PT", "US"}) + public void shouldAcceptValidCountryCode(String countryCode){ + assertTrue(EnvValidationUtils.isCountryValid(countryCode)); + } + + @ParameterizedTest + @ValueSource(strings = {"1P", "PLP", "P#", "&*"}) + public void shouldRejectInvalidCountryCode(String countryCode){ + assertFalse(EnvValidationUtils.isCountryValid(countryCode)); + } + + @ParameterizedTest + @ValueSource(strings = {"caname", "caname1", "123caName", "ca1name"}) + public void shouldAcceptValidAlphanumeric(String caName){ + assertTrue(EnvValidationUtils.isAlphaNumeric(caName)); + } + + @ParameterizedTest + @ValueSource(strings = {"44caname$", "#caname1", "1c_aname", "ca1-name"}) + public void shouldRejectInvalidAlphanumeric(String caName){ + assertFalse(EnvValidationUtils.isAlphaNumeric(caName)); + } + + @ParameterizedTest + @ValueSource(strings = {"example.com", "www.example.com"}) + public void shouldAcceptValidCommonName(String commonName){ + assertTrue(EnvValidationUtils.isCommonNameValid(commonName)); + } + + @ParameterizedTest + @ValueSource(strings = {"https://example.com", "http://example.com", "example.com:8080", "0.0.0.0", "@#$%.com"}) + public void shouldRejectInvalidCommonName(String commonName){ + assertFalse(EnvValidationUtils.isCommonNameValid(commonName)); + } } \ No newline at end of file -- cgit 1.2.3-korg