This is an automated email from the ASF dual-hosted git repository. pmouawad pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jmeter.git
The following commit(s) were added to refs/heads/master by this push: new f0869b6 Bug 65002 - HTTP(S) Test Script recorder creates an invalid Basic authentication URL f0869b6 is described below commit f0869b6aef4ed865a9373f3ae2261d34a9c4b75c Author: pmouawad <p.moua...@ubik-ingenierie.com> AuthorDate: Thu Dec 17 20:29:53 2020 +0100 Bug 65002 - HTTP(S) Test Script recorder creates an invalid Basic authentication URL --- .../jmeter/protocol/http/proxy/ProxyControl.java | 21 ++++++++++++--------- xdocs/changes.xml | 2 ++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/ProxyControl.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/ProxyControl.java index 9055db4..16686c7 100644 --- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/ProxyControl.java +++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/ProxyControl.java @@ -24,7 +24,6 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; -import java.net.MalformedURLException; import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; import java.security.KeyStore; @@ -636,7 +635,7 @@ public class ProxyControl extends GenericController implements NonTestElement { sampler.setFollowRedirects(samplerFollowRedirects); sampler.setUseKeepAlive(useKeepAlive); sampler.setImageParser(samplerDownloadImages); - Authorization authorization = createAuthorization(testElements, sampler); + Authorization authorization = createAuthorization(testElements, sampler, result); if (authorization != null) { setAuthorization(authorization, myTarget); } @@ -669,9 +668,10 @@ public class ProxyControl extends GenericController implements NonTestElement { * * @param testElements {@link TestElement}[] * @param sampler {@link HTTPSamplerBase} + * @param result {@link HTTPSampleResult} * @return {@link Authorization} */ - private Authorization createAuthorization(final TestElement[] testElements, HTTPSamplerBase sampler) { + private Authorization createAuthorization(final TestElement[] testElements, HTTPSamplerBase sampler, SampleResult result) { Header authHeader; Authorization authorization = null; // Iterate over subconfig elements searching for HeaderManager @@ -710,12 +710,7 @@ public class ProxyControl extends GenericController implements NonTestElement { } authCredentialsBase64 = authHeaderContent[1]; authorization=new Authorization(); - try { - authorization.setURL(sampler.getUrl().toExternalForm()); - } catch (MalformedURLException e) { - log.error("Error filling url on authorization, message: {}", e.getMessage(), e); - authorization.setURL("${AUTH_BASE_URL}");//$NON-NLS-1$ - } + authorization.setURL(computeAuthUrl(result.getUrlAsString())); authorization.setMechanism(mechanism); if(BASIC_AUTH.equals(authType)) { String authCred = new String(Base64.decodeBase64(authCredentialsBase64), StandardCharsets.UTF_8); @@ -746,6 +741,14 @@ public class ProxyControl extends GenericController implements NonTestElement { return authorization; } + private String computeAuthUrl(String url) { + int index = url.lastIndexOf('/'); + if (index >=0) { + return url.substring(0, index+1); + } + return url; + } + public void stopProxy() { if (server != null) { server.stopServer(); diff --git a/xdocs/changes.xml b/xdocs/changes.xml index a044536..f77317a 100644 --- a/xdocs/changes.xml +++ b/xdocs/changes.xml @@ -136,6 +136,7 @@ Summary <h3>HTTP Samplers and Test Script Recorder</h3> <ul> <li><bug>64955</bug>Keystore password not reset on reload</li> + <li><bug>65002</bug>HTTP(S) Test Script recorder creates an invalid Basic authentication URL. Contributed by Ubik Load Pack (https://ubikloadpack.com)</li> </ul> <h3>Other Samplers</h3> @@ -188,6 +189,7 @@ Summary <ul> <li>Ori Marko (orimarko at gmail.com)</li> <li>罗寅卓 (luo_isaiah at qq.com)</li> + <li><a href="https://ubikloadpack.com" >Ubik Load Pack</a></li> </ul> <p>We also thank bug reporters who helped us improve JMeter.</p> <ul>