aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/rest
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-05-24 13:24:12 -0400
committerJim Hahn <jrh3@att.com>2018-05-24 13:24:12 -0400
commit9cbca383a8fdd1c079f35ceecb8787a70a15c585 (patch)
tree5262862435f77b1d738a0f1f71ddd62c4bee52b0 /controlloop/common/model-impl/rest
parentc7cfbcb4dbd13a2e4595ab5b7a0558fb6a66879a (diff)
Don't build credentials if user name is emptyv1.2.32.0.0-ONAPbeijing2.0.0-ONAP
Modified code to skip building credentials if user name is empty, in addition to case where user name is null. Change-Id: I5b53d4f97263df98cfe082f44a4e6af64b1e488b Issue-ID: POLICY-868 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/model-impl/rest')
-rw-r--r--controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java2
-rwxr-xr-xcontrolloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java10
-rwxr-xr-xcontrolloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java7
3 files changed, 18 insertions, 1 deletions
diff --git a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
index 6b8b6f09a..52ce13ef9 100644
--- a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
+++ b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
@@ -146,7 +146,7 @@ public class RESTManager {
}
private String makeAuthHeader(String username, String password) {
- if (username == null) {
+ if (username == null || username.isEmpty()) {
return null;
}
diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java
index a2252a046..a8301810c 100755
--- a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java
+++ b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java
@@ -45,6 +45,16 @@ public class TestGet {
}
@Test
+ public void testUsernameEmpty() {
+ RESTManager mgr = new RESTManager();
+
+ Pair<Integer, String> result = mgr.get("http://www.example.org", "", null, null);
+ assertEquals((Integer)200, result.a);
+ assertTrue(result.b != null);
+ assertTrue(result.b.length() > 0);
+ }
+
+ @Test
public void testUrlExampleOrg() {
RESTManager mgr = new RESTManager();
diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java
index de44dec6b..58ba5d247 100755
--- a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java
+++ b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java
@@ -35,6 +35,13 @@ public class TestPost {
}
@Test
+ public void testUsernameEmpty() {
+ RESTManager mgr = new RESTManager();
+ Pair<Integer, String> result = mgr.post("http://www.example.org", "", null, null, null, null);
+ assertEquals(null, result);
+ }
+
+ @Test
public void testBodyNull() {
RESTManager mgr = new RESTManager();
Pair<Integer, String> result = mgr.post("http://www.example.org", "user", null, null, null, null);