Repository: brooklyn-server
Updated Branches:
  refs/heads/master 24fa6fe62 -> 880f842e6


Allow all certs in TestHttpCall


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/4af2f431
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/4af2f431
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/4af2f431

Branch: refs/heads/master
Commit: 4af2f4319a48e5b520d21a92d90a7b19756e8794
Parents: 24fa6fe
Author: Duncan Godwin <duncan.god...@cloudsoftcorp.com>
Authored: Mon Nov 21 12:13:04 2016 +0000
Committer: Duncan Godwin <duncan.god...@cloudsoftcorp.com>
Committed: Mon Nov 21 12:13:04 2016 +0000

----------------------------------------------------------------------
 .../org/apache/brooklyn/test/framework/TestHttpCall.java    | 2 ++
 .../apache/brooklyn/test/framework/TestHttpCallImpl.java    | 9 +++++----
 2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4af2f431/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
----------------------------------------------------------------------
diff --git 
a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
 
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
index c549fbd..31dac5d 100644
--- 
a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
+++ 
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
@@ -51,6 +51,8 @@ public interface TestHttpCall extends BaseTest {
             .defaultValue(HttpMethod.GET)
             .build();
 
+    ConfigKey<Boolean> TRUST_ALL = 
ConfigKeys.newBooleanConfigKey("trustAll","Trust all certificates used to sign 
this request",true);
+
     ConfigKey<Map<String, String>> TARGET_HEADERS = ConfigKeys.builder(new 
TypeToken<Map<String, String>>() {})
             .name("headers")
             .description("Headers to add to the request")

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4af2f431/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
----------------------------------------------------------------------
diff --git 
a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
 
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
index 11a3244..a825c8e 100644
--- 
a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
+++ 
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
@@ -65,11 +65,12 @@ public class TestHttpCallImpl extends 
TargetableTestComponentImpl implements Tes
             final List<Map<String, Object>> assertions = getAssertions(this, 
ASSERTIONS);
             final Duration timeout = getConfig(TIMEOUT);
             final HttpAssertionTarget target = 
getRequiredConfig(ASSERTION_TARGET);
+            final boolean trustAll = getRequiredConfig(TRUST_ALL);
             if (!getChildren().isEmpty()) {
                 throw new RuntimeException(String.format("The entity [%s] 
cannot have child entities", getClass().getName()));
             }
             
-            doRequestAndCheckAssertions(ImmutableMap.of("timeout", timeout), 
assertions, target, method, url, headers, body);
+            doRequestAndCheckAssertions(ImmutableMap.of("timeout", timeout), 
assertions, target, method, url, headers, trustAll, body);
             setUpAndRunState(true, Lifecycle.RUNNING);
 
         } catch (Throwable t) {
@@ -84,7 +85,7 @@ public class TestHttpCallImpl extends 
TargetableTestComponentImpl implements Tes
     }
 
     private void doRequestAndCheckAssertions(Map<String, Duration> flags, 
List<Map<String, Object>> assertions,
-                                             HttpAssertionTarget target, final 
HttpMethod method, final String url, final Map<String, String> headers, final 
String body) {
+                                             HttpAssertionTarget target, final 
HttpMethod method, final String url, final Map<String, String> headers, final 
boolean trustAll, final String body) {
         switch (target) {
             case body:
                 Supplier<String> getBody = new Supplier<String>() {
@@ -92,7 +93,7 @@ public class TestHttpCallImpl extends 
TargetableTestComponentImpl implements Tes
                     public String get() {
                         try {
                             final HttpRequestBase httpMethod = 
createHttpMethod(method, url, headers, body);
-                            return 
HttpTool.execAndConsume(HttpTool.httpClientBuilder().build(), 
httpMethod).getContentAsString();
+                            return 
HttpTool.execAndConsume(HttpTool.httpClientBuilder().trustAll(trustAll).build(),
 httpMethod).getContentAsString();
                         } catch (Exception e) {
                             LOG.info("HTTP call to [{}] failed due to [{}]", 
url, e.getMessage());
                             throw Exceptions.propagate(e);
@@ -108,7 +109,7 @@ public class TestHttpCallImpl extends 
TargetableTestComponentImpl implements Tes
                     public Integer get() {
                         try {
                             final HttpRequestBase httpMethod = 
createHttpMethod(method, url, headers, body);
-                            final Maybe<HttpResponse> response = 
HttpTool.execAndConsume(HttpTool.httpClientBuilder().build(), 
httpMethod).getResponse();
+                            final Maybe<HttpResponse> response = 
HttpTool.execAndConsume(HttpTool.httpClientBuilder().trustAll(trustAll).build(),
 httpMethod).getResponse();
                             if (response.isPresentAndNonNull()) {
                                 return 
response.get().getStatusLine().getStatusCode();
                             } else {

Reply via email to