diff options
author | Jim Hahn <jrh3@att.com> | 2018-04-21 01:07:34 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2018-04-23 10:47:33 -0400 |
commit | 49bccdce3e434e2e05d0f36ab5e4f2163184825b (patch) | |
tree | 2e2c27fad59671bb6fe0df23fba8688b7a090f14 /controlloop/common/model-impl/rest/src/test/java | |
parent | d548b61bd5e657a4e2c47fb98da8c28e0a69cf42 (diff) |
Send credentials to AAI
Per this link: http://www.baeldung.com/httpclient-4-basic-authentication
apache HttpClient does not send the credentials by default,
but instead waits for the server to issue a challenge before
sending them. Modified RESTManager to construct and send the
Authorization header always instead of waiting for the
challenge.
Remove unused imports.
Also add Authorization header for POST request.
Change error message to match original error message when
username is null.
Preempt sonar issue.
Allow null user name, which indicates that the Authorization header
should not be sent. Note: this only impacts the RESTManager class;
invoking classes (e.g., AaiManager) still enforce that the user name
exists in the properties.
Fix license dates in modified test code.
Change-Id: I3cb26e76562db746939631437775727809553390
Issue-ID: POLICY-754
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/model-impl/rest/src/test/java')
-rwxr-xr-x | controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java | 12 | ||||
-rwxr-xr-x | controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java | 9 |
2 files changed, 13 insertions, 8 deletions
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 0bf1da8d5..a2252a046 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 @@ -1,8 +1,8 @@ -/*- +/* * ============LICENSE_START======================================================= * rest * ================================================================================ - * + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,10 +34,14 @@ public class TestGet { mgr.get(null, "user", null, null); } - @Test(expected = IllegalArgumentException.class) + @Test public void testUsernameNull() { RESTManager mgr = new RESTManager(); - mgr.get("nothing", null, null, null); + + Pair<Integer, String> result = mgr.get("http://www.example.org", null, null, null); + assertEquals((Integer)200, result.a); + assertTrue(result.b != null); + assertTrue(result.b.length() > 0); } @Test 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 1cdde22e8..de44dec6b 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 @@ -1,8 +1,8 @@ -/*- +/* * ============LICENSE_START======================================================= * rest * ================================================================================ - * + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,10 +27,11 @@ import org.onap.policy.rest.RESTManager.Pair; public class TestPost { - @Test(expected = IllegalArgumentException.class) + @Test public void testUsernameNull() { RESTManager mgr = new RESTManager(); - mgr.post("nothing", null, null, null, null, null); + Pair<Integer, String> result = mgr.post("http://www.example.org", null, null, null, null, null); + assertEquals(null, result); } @Test |