diff options
author | su622b <sunil.unnava@att.com> | 2018-04-11 19:56:37 -0400 |
---|---|---|
committer | su622b <sunil.unnava@att.com> | 2018-04-11 19:56:55 -0400 |
commit | 5519f8372acf8d4f573739b8e819f7a1e569a019 (patch) | |
tree | 46f968c8f84b09fa7a285444baa79d2b4d6c3deb | |
parent | c0aeea3d201d320c83cd30497ac3c3e875e3c107 (diff) |
support for post requests with auth2.0.0-ONAPbeijing2.0.0-ONAP
Issue-ID: DMAAP-404
Change-Id: Iaa85ab5410472fca4dd6118d2a53efc1737609d5
Signed-off-by: su622b <sunil.unnava@att.com>
-rw-r--r-- | pom.xml | 2 | ||||
-rw-r--r-- | src/main/java/com/att/nsa/mr/client/impl/DmaapClientUtil.java | 6 | ||||
-rw-r--r-- | src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java | 4 | ||||
-rw-r--r-- | src/test/java/com/att/nsa/mr/client/impl/MRBaseClientTest.java | 8 | ||||
-rw-r--r-- | version.properties | 2 |
5 files changed, 14 insertions, 8 deletions
@@ -15,7 +15,7 @@ <groupId>org.onap.dmaap.messagerouter.dmaapclient</groupId> <artifactId>dmaapClient</artifactId> <packaging>jar</packaging> - <version>1.1.5-SNAPSHOT</version> + <version>1.1.6-SNAPSHOT</version> <name>dmaap-messagerouter-dmaapclient</name> <description>Client library for MR event routing API</description> <url>https://github.com/att/dmaap-framework</url> diff --git a/src/main/java/com/att/nsa/mr/client/impl/DmaapClientUtil.java b/src/main/java/com/att/nsa/mr/client/impl/DmaapClientUtil.java index 17a37d9..a3a2ce1 100644 --- a/src/main/java/com/att/nsa/mr/client/impl/DmaapClientUtil.java +++ b/src/main/java/com/att/nsa/mr/client/impl/DmaapClientUtil.java @@ -64,6 +64,12 @@ public class DmaapClientUtil { return target.request().header("Authorization", "Basic " + authHeader).get(); } + + public static Response postResponsewtBasicAuth(WebTarget target, String authHeader,byte[] data,String contentType) { + + return target.request().header("Authorization", "Basic " + authHeader).post(Entity.entity(data, contentType)); + + } public static Response getResponsewtNoAuth(WebTarget target) { diff --git a/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java b/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java index c3d1c26..a0c514c 100644 --- a/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java +++ b/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java @@ -101,7 +101,7 @@ public class MRBaseClient extends HttpClient implements MRClient { target = DmaapClientUtil.getTarget(path, username, password); String encoding = Base64.encodeAsString(username + ":" + password); - response = DmaapClientUtil.getResponsewtBasicAuth(target, encoding); + response = DmaapClientUtil.postResponsewtBasicAuth(target, encoding,data, contentType); return getResponseDataInJson(response); } else { @@ -134,7 +134,7 @@ public class MRBaseClient extends HttpClient implements MRClient { target = DmaapClientUtil.getTarget(path, username, password); String encoding = Base64.encodeAsString(username + ":" + password); - response = DmaapClientUtil.getResponsewtBasicAuth(target, encoding); + response = DmaapClientUtil.postResponsewtBasicAuth(target, encoding,data, contentType); responseData = (String)response.readEntity(String.class); return responseData; diff --git a/src/test/java/com/att/nsa/mr/client/impl/MRBaseClientTest.java b/src/test/java/com/att/nsa/mr/client/impl/MRBaseClientTest.java index b05cc7f..56cf954 100644 --- a/src/test/java/com/att/nsa/mr/client/impl/MRBaseClientTest.java +++ b/src/test/java/com/att/nsa/mr/client/impl/MRBaseClientTest.java @@ -305,8 +305,8 @@ public class MRBaseClientTest { PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}"); PowerMockito.when(response.getHeaders()).thenReturn(map); - PowerMockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"), - Base64.encodeAsString("username:password"))).thenReturn(response); + PowerMockito.when(DmaapClientUtil.postResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"), + Base64.encodeAsString("username:password"), new String("{\"test\":\"test\"}").getBytes(), "application/json")).thenReturn(response); mrBaseClient.post("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json", "username", "password", "HTTPAUTH"); @@ -378,8 +378,8 @@ public class MRBaseClientTest { PowerMockito.when(response.readEntity(String.class)).thenReturn("{\"test\":\"test\"}"); PowerMockito.when(response.getHeaders()).thenReturn(map); - PowerMockito.when(DmaapClientUtil.getResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"), - Base64.encodeAsString("username:password"))).thenReturn(response); + PowerMockito.when(DmaapClientUtil.postResponsewtBasicAuth(DmaapClientUtil.getTarget("/path"), + Base64.encodeAsString("username:password"), new String("{\"test\":\"test\"}").getBytes(), "application/json")).thenReturn(response); mrBaseClient.postWithResponse("/path", new String("{\"test\":\"test\"}").getBytes(), "application/json", "username", "password", "HTTPAUTH"); diff --git a/version.properties b/version.properties index 7809677..ccd6e4a 100644 --- a/version.properties +++ b/version.properties @@ -27,7 +27,7 @@ major=1 minor=1 -patch=5 +patch=6 base_version=${major}.${minor}.${patch} |