diff options
author | 2018-08-13 16:37:33 -0400 | |
---|---|---|
committer | 2018-08-13 16:58:18 -0400 | |
commit | 41a3f1b3b0e14fb1df40273adb4b4b1937c5a977 (patch) | |
tree | b9b120e75e4489932b894a36493cd35b7cf3ad71 /pomba/network-discovery/src/test | |
parent | e80c1047cfd31742c8f876b06a99a738969c8c3d (diff) |
Added code for password obfuscation
Issue-ID: SDNC-317
Change-Id: I5114f1dd7dd093e9df6ebd3d91c3cbd47ef31ef9
Signed-off-by: Mohammadreza Pasandideh <mohammadreza.pasandideh@amdocs.com>
Diffstat (limited to 'pomba/network-discovery/src/test')
2 files changed, 43 insertions, 2 deletions
diff --git a/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/AuthorizationConfigurationTest.java b/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/AuthorizationConfigurationTest.java new file mode 100644 index 0000000..c34c53c --- /dev/null +++ b/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/AuthorizationConfigurationTest.java @@ -0,0 +1,39 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 Amdocs + * ============================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END===================================================== + */ + +package org.onap.sdnc.apps.pomba.networkdiscovery.unittest.service; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.junit.Test; +import org.onap.sdnc.apps.pomba.networkdiscovery.AuthorizationConfiguration; + +public class AuthorizationConfigurationTest +{ + AuthorizationConfiguration authorizationConfiguration = + mock(AuthorizationConfiguration.class); + + @Test + public void testGetNdBasicAuthHeader() { + String msg = "Basic YWRtaW46YWRtaW4="; + when(authorizationConfiguration.getNdBasicAuthHeader()).thenReturn(msg); + assertEquals(msg, authorizationConfiguration.getNdBasicAuthHeader()); + } +} diff --git a/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java b/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java index f908dfd..100c671 100644 --- a/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java +++ b/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java @@ -46,6 +46,7 @@ import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import org.eclipse.jetty.util.security.Password; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -75,7 +76,7 @@ import org.springframework.test.context.web.WebAppConfiguration; @TestPropertySource(properties = { "enricher.url=http://localhost:9505", "basicAuth.username=admin", - "basicAuth.password=admin" + "basicAuth.password=OBF:1u2a1toa1w8v1tok1u30" }) public class NetworkDiscoveryTest { private static final String V1 = "v1"; @@ -84,7 +85,8 @@ public class NetworkDiscoveryTest { private static final String RESOURCE_TYPE_VSERVER = "vserver"; private static final String CALLBACK_PATH = "/callback"; - private static final String AUTH = "Basic " + Base64.getEncoder().encodeToString("admin:admin".getBytes()); + private static final String AUTH = "Basic " + Base64.getEncoder().encodeToString(( + "admin:" + Password.deobfuscate("OBF:1u2a1toa1w8v1tok1u30")).getBytes()); @Autowired private Environment environment; |