diff options
-rwxr-xr-x | sampleApp/config.json | 16 | ||||
-rw-r--r-- | src/main/java/org/onap/music/prom/musicinterface/MusicHandle.java | 12 | ||||
-rw-r--r-- | src/test/java/org/onap/music/prom/musicinterface/MusicHandleTest.java | 2 |
3 files changed, 15 insertions, 15 deletions
diff --git a/sampleApp/config.json b/sampleApp/config.json index dd3ac8f..962e605 100755 --- a/sampleApp/config.json +++ b/sampleApp/config.json @@ -1,9 +1,9 @@ {
- "appName":"",
+ "app-name":"appusingprom",
"aid":"",
- "namespace":"",
- "userid":"",
- "password":"",
+ "namespace":"prom1",
+ "userid":"uid",
+ "password":"pw",
"ensure-active-0": "./ensureSdncActive.sh",
"ensure-active-1": "./ensureSdncActive.sh",
"ensure-passive-0":"./ensureSdncStandby.sh",
@@ -12,8 +12,8 @@ "restart-prom-1":"",
"core-monitor-sleep-time":"1000",
"prom-timeout":"5000",
- "noOfRetryAttempts":"3",
- "replicaIdList":["0", "1"],
- "musicLocation":"127.0.0.1",
- "musicVersion":2
+ "no-of-retry-attempts":"3",
+ "replica-id-list":["0", "1"],
+ "music-location":["127.0.0.1"],
+ "music-version":2
}
diff --git a/src/main/java/org/onap/music/prom/musicinterface/MusicHandle.java b/src/main/java/org/onap/music/prom/musicinterface/MusicHandle.java index d62a1d2..83d148b 100644 --- a/src/main/java/org/onap/music/prom/musicinterface/MusicHandle.java +++ b/src/main/java/org/onap/music/prom/musicinterface/MusicHandle.java @@ -40,6 +40,7 @@ import com.sun.jersey.api.client.WebResource.Builder; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.json.JSONConfiguration; +import java.util.Base64; public class MusicHandle { private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicHandle.class); @@ -61,13 +62,10 @@ public class MusicHandle { if (!namespace.equals("")) { builder.header("ns", namespace); } - if (!userId.equals("")) { - builder.header("userId", userId); + if (!userId.equals("") && !password.equals("")) { + String authString = Base64.getEncoder().encodeToString((userId + ":" + password).getBytes()); + builder.header("Authorization", "Basic " + authString); } - if (!password.equals("")) { - builder.header("password", password); - } - return builder; } @@ -119,6 +117,8 @@ public class MusicHandle { WebResource webResource = createMusicWebResource(musicUrl+"/keyspaces/"+keyspaceName); + Builder b = addMusicHeaders(webResource); + logger.error("music handle create keyspace eventual: " + b); ClientResponse response = addMusicHeaders(webResource) .post(ClientResponse.class, jsonKp); diff --git a/src/test/java/org/onap/music/prom/musicinterface/MusicHandleTest.java b/src/test/java/org/onap/music/prom/musicinterface/MusicHandleTest.java index 48f75c3..120d80c 100644 --- a/src/test/java/org/onap/music/prom/musicinterface/MusicHandleTest.java +++ b/src/test/java/org/onap/music/prom/musicinterface/MusicHandleTest.java @@ -63,7 +63,7 @@ public class MusicHandleTest { public void before() throws Exception { PowerMockito.mockStatic(ConfigReader.class); ArrayList<String> urls = new ArrayList<String>(); - Collections.addAll(urls, "1.2.3.4", "5.6.7.8"); + Collections.addAll(urls, "10.1.2.3", "10.4.5.6"); PowerMockito.when(ConfigReader.getConfigAttribute(Mockito.anyString(), Mockito.anyString())) .thenCallRealMethod(); |