From 6185dd756eb94ade04b9c01139a6a71ba090fa60 Mon Sep 17 00:00:00 2001 From: Kuniteru Asami Date: Sat, 31 Jul 2021 23:50:02 +0900 Subject: [PATCH] Fixed a bug when using proxy & debugging issue #6 --- plugins/functions/pom.xml | 2 +- .../java/jp/co/pnop/jmeter/functions/AzAdAccessToken.java | 6 +++++- .../src/main/java/jp/co/pnop/jmeter/functions/common.java | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/functions/pom.xml b/plugins/functions/pom.xml index 5e99225..1503b09 100644 --- a/plugins/functions/pom.xml +++ b/plugins/functions/pom.xml @@ -6,7 +6,7 @@ jp.co.pnop jmeter-plugins-functions-azure - 0.4.1 + 0.4.2 Custom JMeter functions for Azure Custom JMeter functions for Azure diff --git a/plugins/functions/src/main/java/jp/co/pnop/jmeter/functions/AzAdAccessToken.java b/plugins/functions/src/main/java/jp/co/pnop/jmeter/functions/AzAdAccessToken.java index 7017db7..9bac52a 100644 --- a/plugins/functions/src/main/java/jp/co/pnop/jmeter/functions/AzAdAccessToken.java +++ b/plugins/functions/src/main/java/jp/co/pnop/jmeter/functions/AzAdAccessToken.java @@ -153,10 +153,10 @@ public synchronized String execute(SampleResult previousResult, Sampler currentS accessToken = node.get("access_token").textValue(); addVariableValue(accessToken, values, NAME_OF_VAL); } else { + log.info("Warn calling {} Azure AD request, Response status: {}, Response body {}", KEY, status, responseMessage); String errorDescription = node.get("error_description").textValue(); log.warn("Warn calling {} Azure AD request, {}: {}", KEY, response.getStatusLine().toString(), errorDescription); - log.info(responseMessage); } } catch (IllegalArgumentException e) { log.error( @@ -168,6 +168,10 @@ public synchronized String execute(SampleResult previousResult, Sampler currentS log.error("Error calling {}, ", KEY, e); } catch (IOException e) { log.error("Error calling {}, ", KEY, e); + } catch (Exception e) { + log.error( + "Error calling {} function with Tenant ID {}, grant_type {}, client_id {}, username {}, scope {}, resource {}, aadVersion {}, aadUri {}, ", + KEY, tenantId, grantType, clientId, username, scope, resource, aadVersion, aadUri, e); } return accessToken; diff --git a/plugins/functions/src/main/java/jp/co/pnop/jmeter/functions/common.java b/plugins/functions/src/main/java/jp/co/pnop/jmeter/functions/common.java index 14528f4..b72403e 100644 --- a/plugins/functions/src/main/java/jp/co/pnop/jmeter/functions/common.java +++ b/plugins/functions/src/main/java/jp/co/pnop/jmeter/functions/common.java @@ -23,7 +23,6 @@ public class common { public static HttpClientBuilder setProxy(String host) { HttpClientBuilder httpclientbuilder = HttpClientBuilder.create(); - String targetHost = "login.microsoftonline.com"; String proxyHost = JMeterUtils.getPropDefault("https.proxyHost", "").trim(); int proxyPort = Integer.parseInt(JMeterUtils.getPropDefault("https.proxyPort", "3128").trim()); @@ -43,7 +42,7 @@ public static HttpClientBuilder setProxy(String host) { } NON_PROXY_HOST_SUFFIX_SIZE = nonProxyHostSuffix.size(); - if (proxyHost.length() > 0 && !nonProxyHostFull.contains(targetHost) && !isPartialMatch(targetHost)) { + if (proxyHost.length() > 0 && !nonProxyHostFull.contains(host) && !isPartialMatch(host)) { HttpHost proxy = new HttpHost(proxyHost, proxyPort); DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); httpclientbuilder = httpclientbuilder.setRoutePlanner(routePlanner);