Skip to content

Commit 105455e

Browse files
Merge pull request #114 from telekom/fix/remove-ftpproxy
Removed FTP proxy settings from default proxy
2 parents 4119df2 + 6d05d47 commit 105455e

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

core-interop/src/main/java/eu/tsystems/mms/tic/testframework/utils/ProxyUtils.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
* under the License.
2020
*
2121
*/
22-
package eu.tsystems.mms.tic.testframework.utils;
22+
package eu.tsystems.mms.tic.testframework.utils;
2323

2424
import java.io.UnsupportedEncodingException;
2525
import java.net.MalformedURLException;
2626
import java.net.URL;
2727
import java.net.URLEncoder;
28+
2829
import org.slf4j.Logger;
2930
import org.slf4j.LoggerFactory;
3031

@@ -35,6 +36,7 @@ public class ProxyUtils {
3536
/**
3637
* Will return proxy url like http://{http.proxyUser}:{http.proxyPassword}@{http.proxyHost}:{http.proxyPort}
3738
* based on the System's proxy settings ea. from the proxysettings.properties file
39+
*
3840
* @return null If there is no URL configured
3941
*/
4042
public static URL getSystemHttpProxyUrl() {
@@ -44,6 +46,7 @@ public static URL getSystemHttpProxyUrl() {
4446
/**
4547
* Will return proxy url like http://{https.proxyUser}:{https.proxyPassword}@{https.proxyHost}:{https.proxyPort}
4648
* based on the System's proxy settings ea. from the proxysettings.properties file
49+
*
4750
* @return null If there is no URL configured
4851
*/
4952
public static URL getSystemHttpsProxyUrl() {
@@ -73,7 +76,7 @@ private static String getSpecificProxyTypeString(final String proxyType) {
7376
* ProxyType can be "http" or "https" according to java env properties proxy.httpHost or proxy.httpsHost
7477
*
7578
* @param proxyType {@link String} http or https
76-
* @param prefix {@link String} Prefix for URL Scheme
79+
* @param prefix {@link String} Prefix for URL Scheme
7780
* @return URL
7881
*/
7982
private static URL getSpecificProxyTypeUrlWithPrefix(final String proxyType, final String prefix) {
@@ -84,16 +87,16 @@ private static URL getSpecificProxyTypeUrlWithPrefix(final String proxyType, fin
8487
try {
8588

8689
final String user = System.getProperty(proxyType + ".proxyUser");
87-
if (StringUtils.isNotBlank(user)) {
90+
if (org.apache.commons.lang3.StringUtils.isNotEmpty(user)) {
8891
proxyUrlString += URLEncoder.encode(user, urlEncoding);
8992
}
9093

9194
final String password = System.getProperty(proxyType + ".proxyPassword");
92-
if (StringUtils.isNotBlank(password)) {
95+
if (org.apache.commons.lang3.StringUtils.isNotEmpty(password)) {
9396
proxyUrlString += ":" + URLEncoder.encode(password, urlEncoding);
9497
}
9598

96-
if (StringUtils.isNotBlank(user)) {
99+
if (org.apache.commons.lang3.StringUtils.isNotEmpty(user)) {
97100
proxyUrlString += "@";
98101
}
99102

docs/src/docs/browsercaps/proxy-setup.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ public abstract class AbstractTest extends TesterraTest {
4545
}
4646
}
4747
----
48+
49+
NOTE: `WebDriverProxyUtils.getDefaultHttpProxy()` only returns the proxy configuration for HTTP, HTTPS and non-proxy connections.

driver-ui/src/main/java/eu/tsystems/mms/tic/testframework/webdrivermanager/WebDriverProxyUtils.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
import eu.tsystems.mms.tic.testframework.report.utils.ExecutionContextController;
2828
import eu.tsystems.mms.tic.testframework.utils.ProxyUtils;
2929
import eu.tsystems.mms.tic.testframework.utils.StringUtils;
30+
3031
import java.net.URL;
32+
3133
import org.openqa.selenium.Proxy;
3234

3335
public class WebDriverProxyUtils {
@@ -96,7 +98,6 @@ public Proxy createHttpProxyFromUrl(URL url) {
9698
String proxyString = toProxyString(url);
9799
Proxy proxy = new Proxy();
98100
proxy.setHttpProxy(proxyString);
99-
proxy.setFtpProxy(proxyString);
100101
proxy.setSslProxy(proxyString);
101102
return proxy;
102103
}
@@ -115,7 +116,9 @@ public Proxy getDefaultSocksProxy() {
115116
*/
116117
public Proxy getDefaultHttpProxy() {
117118
URL systemProxyUrl = ProxyUtils.getSystemHttpsProxyUrl();
118-
if (systemProxyUrl == null) systemProxyUrl = ProxyUtils.getSystemHttpProxyUrl();
119+
if (systemProxyUrl == null) {
120+
systemProxyUrl = ProxyUtils.getSystemHttpProxyUrl();
121+
}
119122
Proxy proxy = createHttpProxyFromUrl(systemProxyUrl);
120123
proxy.setNoProxy(PropertyManager.getProperty("https.nonProxyHosts"));
121124
return proxy;

integration-tests/src/test/java/eu/tsystems/mms/tic/testframework/test/utils/ProxyUtilsTest.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@
1919
* under the License.
2020
*
2121
*/
22-
package eu.tsystems.mms.tic.testframework.test.utils;
22+
package eu.tsystems.mms.tic.testframework.test.utils;
2323

2424
import eu.tsystems.mms.tic.testframework.testing.TesterraTest;
2525
import eu.tsystems.mms.tic.testframework.utils.ProxyUtils;
2626
import eu.tsystems.mms.tic.testframework.webdrivermanager.WebDriverProxyUtils;
27-
import java.net.MalformedURLException;
28-
import java.net.URL;
2927
import org.openqa.selenium.Proxy;
3028
import org.testng.Assert;
3129
import org.testng.annotations.AfterClass;
3230
import org.testng.annotations.BeforeClass;
3331
import org.testng.annotations.Test;
3432

33+
import java.net.MalformedURLException;
34+
import java.net.URL;
35+
3536
/**
3637
* Tests class for {@link ProxyUtils} and {@link WebDriverProxyUtils}
3738
* <p>
@@ -131,8 +132,19 @@ public void test05_createProxyFromUrl() throws MalformedURLException {
131132
WebDriverProxyUtils utils = new WebDriverProxyUtils();
132133
String proxyString = "http://proxyUser:secretPassword@my-proxy:3128";
133134
Proxy proxy = utils.createSocksProxyFromUrl(new URL(proxyString));
134-
Assert.assertEquals(proxy.getHttpProxy(),"my-proxy:3128");
135-
Assert.assertEquals(proxy.getSocksUsername(),"proxyUser");
135+
Assert.assertEquals(proxy.getHttpProxy(), "my-proxy:3128");
136+
Assert.assertEquals(proxy.getSocksUsername(), "proxyUser");
136137
Assert.assertEquals(proxy.getSocksPassword(), "secretPassword");
137138
}
139+
140+
@Test
141+
public void test06_createDefaultProxyFromUrl() {
142+
WebDriverProxyUtils utils = new WebDriverProxyUtils();
143+
Proxy proxy = utils.getDefaultHttpProxy();
144+
145+
Assert.assertEquals(proxy.getHttpProxy(), PROXY_HOST_HTTPS + ":" + PROXY_PORT_HTTPS);
146+
Assert.assertEquals(proxy.getSslProxy(), PROXY_HOST_HTTPS + ":" + PROXY_PORT_HTTPS);
147+
Assert.assertNull(proxy.getFtpProxy());
148+
Assert.assertNull(proxy.getSocksProxy());
149+
}
138150
}

0 commit comments

Comments
 (0)