portPool) {
- portPool.forEach(p -> this.portPool.put(p, Boolean.FALSE));
- }
-
- /**
- * Starts a local {@link BrowserUpRemoteProxyServer} on a free port, that will be allocated in a threadsafe way.
- *
- * @param proxyServer {@link BrowserUpRemoteProxyServer}
- * @return BrowserUpRemoteProxyServer
- * @throws BrowserUpNoFreePortException When no port is free..
- */
- public BrowserUpProxyServer startServer(BrowserUpProxyServer proxyServer) throws BrowserUpNoFreePortException {
-
- final int allocatedPort = allocateFreePort();
- if (allocatedPort == -1) {
- // NO FREE PORT BUT THERE SHOULD BE ONE FREE..
- throw new BrowserUpNoFreePortException("Could not allocated pool in port: " + portPool.toString());
- }
-
- proxyServer.start(allocatedPort);
- registeredProxies.put(allocatedPort, proxyServer);
-
- return proxyServer;
- }
-
- /**
- * Stop the given instance and free port
- *
- * @param proxyServer {@link BrowserUpRemoteProxyServer}
- */
- public void stopServer(BrowserUpProxyServer proxyServer) {
-
- int port = proxyServer.getPort();
- proxyServer.stop();
-
- this.registeredProxies.remove(port);
- this.portPool.put(port, Boolean.FALSE);
- }
-
- /**
- * Stops all proxies.
- */
- public void stopAllServer() {
-
- for (final Integer port : registeredProxies.keySet()) {
- registeredProxies.get(port).stop();
- portPool.put(port, Boolean.TRUE);
- }
-
- registeredProxies.clear();
- }
-
- private synchronized int allocateFreePort() throws BrowserUpNoFreePortException {
-
- if (!portPool.containsValue(Boolean.FALSE)) {
- throw new BrowserUpNoFreePortException("Could not allocated pool in port: " + portPool.toString());
- }
-
- for (Integer port : portPool.keySet()) {
- if (!portPool.get(port)) {
- portPool.put(port, Boolean.TRUE);
- return port;
- }
- }
-
- return -1;
- }
-
-}
diff --git a/bup/src/main/java/eu/tsystems/mms/tic/testerra/bup/BrowserUpNoFreePortException.java b/bup/src/main/java/eu/tsystems/mms/tic/testerra/bup/BrowserUpNoFreePortException.java
deleted file mode 100644
index 5d9ac4cf4..000000000
--- a/bup/src/main/java/eu/tsystems/mms/tic/testerra/bup/BrowserUpNoFreePortException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Testerra
- *
- * (C) 2020, Eric Kubenka, T-Systems Multimedia Solutions GmbH, Deutsche Telekom AG
- *
- * Deutsche Telekom AG and all other contributors /
- * copyright owners license this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this
- * file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package eu.tsystems.mms.tic.testerra.bup;
-
-/**
- * Thrown when no free port could be allocated for {@link BrowserUpLocalProxyManager}
- *
- * Date: 26.05.2020
- * Time: 12:01
- *
- * @author Eric Kubenka
- */
-public class BrowserUpNoFreePortException extends Exception {
-
- public BrowserUpNoFreePortException(String msg) {
- super(msg);
- }
-
-}
diff --git a/bup/src/main/java/eu/tsystems/mms/tic/testerra/bup/BrowserUpRemoteProxyManager.java b/bup/src/main/java/eu/tsystems/mms/tic/testerra/bup/BrowserUpRemoteProxyManager.java
deleted file mode 100644
index 2d31b0d81..000000000
--- a/bup/src/main/java/eu/tsystems/mms/tic/testerra/bup/BrowserUpRemoteProxyManager.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * Testerra
- *
- * (C) 2020, Eric Kubenka, T-Systems Multimedia Solutions GmbH, Deutsche Telekom AG
- *
- * Deutsche Telekom AG and all other contributors /
- * copyright owners license this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this
- * file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package eu.tsystems.mms.tic.testerra.bup;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonPrimitive;
-import eu.tsystems.mms.tic.testframework.logging.Loggable;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.HttpClients;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * HTTP API Client for https://github.com/browserup/browserup-proxy#rest-api
- *
- * Date: 25.05.2020
- * Time: 10:12
- *
- * @author Eric Kubenka
- */
-public class BrowserUpRemoteProxyManager implements Loggable {
-
- private final URL baseUrl;
-
- /**
- * Create REST client for browser mob proxy.
- *
- * @param apiUrl {@link URL} API endpoint.
- */
- public BrowserUpRemoteProxyManager(final URL apiUrl) {
-
- this.baseUrl = apiUrl;
- }
-
- /**
- * Calls GET /proxy
- *
- * @return List of ports already running an instance.
- */
- public List getProxies() {
-
- final List portsInUse = new ArrayList<>();
-
- // prepare url
- final URIBuilder getStartedProxyServersUriBuilder = url().setPath("/proxy");
-
- final URI uri = buildUri(getStartedProxyServersUriBuilder, "Error parsing URL for GET /proxy for BrowserUp proxy server.");
- final HttpGet httpGet = new HttpGet(uri);
- final String jsonResponse = sendRequestAndConvertResponseToString(httpGet);
-
- // json string conversion to array.
- final JsonElement jsonElement = JsonParser.parseString(jsonResponse);
- final JsonArray portArray = jsonElement.getAsJsonObject().getAsJsonArray("proxyList");
-
- // fill ports
- for (final JsonElement element : portArray) {
- final int actualPort = element.getAsJsonObject().get("port").getAsInt();
- portsInUse.add(actualPort);
- }
-
- return portsInUse;
- }
-
- /**
- * Calls POST /proxy with parameters
- *
- * @return BrowserUpRemoteProxyServer object.
- * @deprecated Use {@link #startServer(BrowserUpRemoteProxyServer)} instead
- */
- public BrowserUpRemoteProxyServer startServer() {
- BrowserUpRemoteProxyServer browserUpRemoteProxyServer = new BrowserUpRemoteProxyServer();
- startServer(browserUpRemoteProxyServer);
- return browserUpRemoteProxyServer;
- }
-
- /**
- * Calls POST /proxy with parameters and desired port, upstream proxy and other configurational data
- *
- * @param proxyServer {@link BrowserUpRemoteProxyServer}
- * @return BrowserUpRemoteProxyServer
- */
- public void startServer(BrowserUpRemoteProxyServer proxyServer) {
-
- final URIBuilder startServerUriBuilder = url().setPath("/proxy");
-
- if (proxyServer.getPort() != null) {
-
- // Check if port already in use...
- if (this.isRunning(proxyServer)) {
- log().info("Remote proxy session already running on this port.");
- }
-
- // Set port to start proxyserver on.
- startServerUriBuilder.setParameter("port", String.valueOf(proxyServer.getPort()));
- }
-
- // Always trust them.
- startServerUriBuilder.setParameter("trustAllServers", "true");
-
- // Set bind address
- proxyServer.getBindAddress().filter(StringUtils::isNotBlank).ifPresent(s -> {
- startServerUriBuilder.setParameter("bindAddress", s);
- });
-
- // Set upstream proxy.
- proxyServer.getUpstreamProxy().ifPresent(url -> {
- startServerUriBuilder.setParameter("httpProxy", String.format("%s:%d", url.getHost(), url.getPort()));
- if (url.getHost().equalsIgnoreCase("https")) {
- startServerUriBuilder.setParameter("proxyHTTPS", "true");
- }
-
- String userInfo = url.getUserInfo();
- if (StringUtils.isNotBlank(userInfo)) {
- String[] parts = userInfo.split(":");
- if (parts.length > 0) {
- startServerUriBuilder.setParameter("proxyUsername", parts[0]);
-
- if (parts.length > 1) {
- startServerUriBuilder.setParameter("proxyPassword", parts[1]);
- }
- }
- }
-
- // Set non proxy exceptions for upstream proxy
- proxyServer.getUpstreamNonProxy().filter(StringUtils::isNotBlank).ifPresent(s -> {
- startServerUriBuilder.setParameter("httpNonProxyHosts", s);
- });
- });
-
- final URI uri = buildUri(startServerUriBuilder, "Error parsing URL for POST /proxy for BrowserUp proxy server.");
- final HttpPost httpPost = new HttpPost(uri);
- final String jsonResponse = sendRequestAndConvertResponseToString(httpPost);
-
- final JsonElement jsonElement = JsonParser.parseString(jsonResponse);
- final int port = jsonElement.getAsJsonObject().get("port").getAsInt();
- proxyServer.setPort(port);
- }
-
- /**
- * Calls DELETE /proxy/[port] of proxy to stop.
- *
- * @param proxyServer {@link BrowserUpRemoteProxyServer}
- * @return true, when successfully stopped.
- */
- public boolean stopServer(BrowserUpRemoteProxyServer proxyServer) {
-
- final URIBuilder deleteProxyServerUriBuilder = url().setPath("/proxy/" + proxyServer.getPort());
-
- final URI uri = buildUri(deleteProxyServerUriBuilder, "Error parsing URL for DELETE /proxy/[port] BrowserUp proxy server.");
- final HttpDelete httpDelete = new HttpDelete(uri);
- final String jsonResponse = sendRequestAndConvertResponseToString(httpDelete);
- return jsonResponse != null && jsonResponse.equals("");
- }
-
- /**
- * Determines if {@link BrowserUpRemoteProxyServer} on port is already running
- *
- * @param proxyServer {@link BrowserUpRemoteProxyServer}
- * @return true, when port in use.
- */
- public boolean isRunning(final BrowserUpRemoteProxyServer proxyServer) {
-
- final List proxies = this.getProxies();
- return proxies.contains(proxyServer.getPort());
- }
-
- /**
- * Calls POST /proxy/[port]/auth/basic/[domain] with parameter
- *
- * @param proxyServer
- * @param domain
- * @param username
- * @param password
- */
- public boolean setBasicAuth(final BrowserUpRemoteProxyServer proxyServer, final String domain, final String username, final String password) {
-
- final URIBuilder basicAuthUriBuilder = url().setPath("/proxy/" + proxyServer.getPort() + "/auth/basic/" + domain);
-
- log().info("Adding Basic Auth for " + username + ":*****@" + domain);
- final JsonObject authObject = new JsonObject();
- authObject.add("username", new JsonPrimitive(username));
- authObject.add("password", new JsonPrimitive(password));
-
- final URI uri = buildUri(basicAuthUriBuilder, "Error parsing URL for POST /proxy/[port]/auth/basic/[domain] BrowserUp proxy server.");
- final HttpPost httpPost = new HttpPost(uri);
-
- final StringEntity postPayloadEntity = new StringEntity(authObject.toString(), ContentType.create("text/plain", "UTF-8"));
- httpPost.setEntity(postPayloadEntity);
- final String jsonResponse = sendRequestAndConvertResponseToString(httpPost);
-
- return jsonResponse != null && jsonResponse.equals("");
- }
-
- /**
- * Calls POST /proxy/[port]/headers with parameter.
- * Sets header for all outgoing requests.
- *
- * @param proxyServer {@link BrowserUpRemoteProxyServer}
- * @param key {@link String}
- * @param value {@link String}
- * @implNote can only be called after a BMP already started.
- */
- public boolean addHeader(final BrowserUpRemoteProxyServer proxyServer, final String key, final String value) {
-
- final URIBuilder setHeaderUriBuilder = url().setPath("/proxy/" + proxyServer.getPort() + "/headers");
-
- final JsonObject jsonHeaderMap = new JsonObject();
- jsonHeaderMap.add(key, new JsonPrimitive(value));
-
- final URI uri = buildUri(setHeaderUriBuilder, "Error parsing URL for POST /proxy/[port]/headers BrowserUp proxy server.");
- final HttpPost httpPost = new HttpPost(uri);
-
- final StringEntity postPayloadEntity = new StringEntity(jsonHeaderMap.toString(), ContentType.create("text/plain", "UTF-8"));
- httpPost.setEntity(postPayloadEntity);
- final String jsonResponse = sendRequestAndConvertResponseToString(httpPost);
-
- return jsonResponse != null && jsonResponse.equals("");
- }
-
- /**
- * Calls PUT /proxy/[port]/har with parameters
- * Start capturing the network traffic
- *
- * @param proxyServer {@link BrowserUpRemoteProxyServer} proxyserver to start capturing on
- * @param isCaptureHeaders Enables capture of headers.
- * @param isCaptureContent Enables capture of content
- * @param initialPageRef Set page reference for first page, defaults to "Page 1"
- */
- public boolean startCapture(BrowserUpRemoteProxyServer proxyServer, String initialPageRef, boolean isCaptureHeaders, boolean isCaptureContent) {
-
- final URIBuilder startCaptureUriBuilder = url().setPath("/proxy/" + proxyServer.getPort() + "/har");
-
- if (isCaptureHeaders) {
- startCaptureUriBuilder.setParameter("captureHeaders", "true");
- }
-
- if (isCaptureContent) {
- startCaptureUriBuilder.setParameter("captureContent", "true");
- }
-
- if (StringUtils.isNotBlank(initialPageRef)) {
- startCaptureUriBuilder.setParameter("initialPageRef ", initialPageRef);
- }
-
- final URI uri = buildUri(startCaptureUriBuilder, "Error parsing URL for PUT /proxy/[port]/har BrowserUp proxy server.");
- final HttpPut httpPut = new HttpPut(uri);
- final String jsonResponse = sendRequestAndConvertResponseToString(httpPut);
- return jsonResponse != null && jsonResponse.equals("");
- }
-
- /**
- * Calls GET /proxy/[port]/har
- * Stop capturing and returns captured hars.
- *
- * @return Captured traffic in JsonFormat (serialized Har)
- */
- public JsonElement stopCapture(BrowserUpRemoteProxyServer proxyServer) {
-
- final URIBuilder captureUriBuilder = url().setPath("/proxy/" + proxyServer.getPort() + "/har");
-
- final URI uri = buildUri(captureUriBuilder, "Error parsing URL for GET /proxy/[port]/har BrowserUp proxy server.");
- final HttpGet httpGet = new HttpGet(uri);
- final String jsonResponse = sendRequestAndConvertResponseToString(httpGet);
- return JsonParser.parseString(jsonResponse);
- }
-
- /**
- * Calls PUT /proxy/[port]/har/pageRef with parameters.
- * Starts a new page in recording.
- * Please ensure you called {@link #startCapture(BrowserUpRemoteProxyServer, String, boolean, boolean)} before.
- *
- * @param proxyServer {@link BrowserUpRemoteProxyServer}
- * @param pageRef {@link String} pageRef
- */
- public boolean addNewPage(final BrowserUpRemoteProxyServer proxyServer, final String pageRef) {
-
- final URIBuilder pageRefUriBuilder = url().setPath("/proxy/" + proxyServer.getPort() + "/har/pageRef");
-
- if (StringUtils.isNotBlank(pageRef)) {
- pageRefUriBuilder.setParameter("pageRef", pageRef);
- }
-
- final URI uri = buildUri(pageRefUriBuilder, "Error parsing URL for PUT /proxy/[port]/har/pageRef BrowserUp proxy server.");
- final HttpPut httpPut = new HttpPut(uri);
- final String jsonResponse = sendRequestAndConvertResponseToString(httpPut);
- return jsonResponse != null && jsonResponse.equals("");
- }
-
- /**
- * Calls POST /proxy/[port]/hosts
- *
- * @param hostnameIpMap Map
- */
- public boolean setHostMapping(BrowserUpRemoteProxyServer proxyServer, Map hostnameIpMap) {
-
- final URIBuilder hostUriBuilder = url().setPath("/proxy/" + proxyServer.getPort() + "/hosts");
-
- final JsonObject jsonHostnameIpMap = new JsonObject();
- for (final String hostname : hostnameIpMap.keySet()) {
- final String ip = hostnameIpMap.get(hostname);
- jsonHostnameIpMap.addProperty(hostname, ip);
- }
-
- final URI uri = buildUri(hostUriBuilder, "Error parsing URL for POST /proxy/[port]/har BrowserUp proxy server.");
- final HttpPost httpPost = new HttpPost(uri);
-
- final StringEntity postPayloadEntity = new StringEntity(jsonHostnameIpMap.toString(), ContentType.create("text/plain", "UTF-8"));
- httpPost.setEntity(postPayloadEntity);
-
- final String jsonResponse = sendRequestAndConvertResponseToString(httpPost);
- return jsonResponse != null && jsonResponse.equals("");
- }
-
- private URI buildUri(URIBuilder uriBuilder, String errorMessage) {
- try {
- return uriBuilder.build();
- } catch (URISyntaxException e) {
- throw new BrowserUpHttpApiException(errorMessage, e);
- }
- }
-
- private String sendRequestAndConvertResponseToString(HttpUriRequest httpRequest) {
-
- HttpResponse response;
-
- try {
- // response conversion
- final HttpClient httpClient = HttpClients.createDefault();
- response = httpClient.execute(httpRequest);
- } catch (IOException e) {
- throw new BrowserUpHttpApiException(
- String.format("Error executing %s for URL %s against HTTP API of BrowserUp proxy server.",
- httpRequest.getClass().getSimpleName(),
- httpRequest.getURI().toString()),
- e);
- }
-
- if (response.getStatusLine().getStatusCode() != 200 && response.getStatusLine().getStatusCode() != 204) {
- throw new BrowserUpHttpApiException(
- String.format("Error executing %s for URL %s against HTTP API of BrowserUp proxy server. Response code was: %s",
- httpRequest.getClass().getSimpleName(),
- httpRequest.getURI().toString(),
- response.getStatusLine().getStatusCode()));
- }
-
- try {
-
- final HttpEntity entity = response.getEntity();
- final StringWriter writer = new StringWriter();
-
- if (entity != null) {
- try (final InputStream inputStream = entity.getContent()) {
- IOUtils.copy(inputStream, writer, Charset.defaultCharset());
- }
- }
-
- // json string conversion to array.
- return writer.toString();
- } catch (IOException e) {
- throw new BrowserUpHttpApiException(
- String.format("Error converting response %s for URL %s from BrowserUp proxy server.",
- httpRequest.getClass().getSimpleName(),
- httpRequest.getURI().toString()),
- e);
- }
- }
-
- private URIBuilder url() {
-
- final URIBuilder uriBuilder = new URIBuilder();
- uriBuilder.setScheme(this.baseUrl.getProtocol());
- uriBuilder.setHost(this.baseUrl.getHost());
- uriBuilder.setPort(this.baseUrl.getPort());
-
- return uriBuilder;
- }
-}
diff --git a/bup/src/main/java/eu/tsystems/mms/tic/testerra/bup/BrowserUpRemoteProxyServer.java b/bup/src/main/java/eu/tsystems/mms/tic/testerra/bup/BrowserUpRemoteProxyServer.java
deleted file mode 100644
index 48471eead..000000000
--- a/bup/src/main/java/eu/tsystems/mms/tic/testerra/bup/BrowserUpRemoteProxyServer.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Testerra
- *
- * (C) 2020, Eric Kubenka, T-Systems Multimedia Solutions GmbH, Deutsche Telekom AG
- *
- * Deutsche Telekom AG and all other contributors /
- * copyright owners license this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this
- * file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package eu.tsystems.mms.tic.testerra.bup;
-
-import java.net.URL;
-import java.util.Optional;
-
-/**
- * Date: 25.05.2020
- * Time: 11:58
- *
- * @author Eric Kubenka
- */
-public class BrowserUpRemoteProxyServer {
-
- private Integer port;
- private URL upstreamProxy;
- private String upstreamNonProxy;
- private String bindAddress;
-
- public Integer getPort() {
- return port;
- }
-
- public void setPort(Integer port) {
- this.port = port;
- }
-
- public Optional getUpstreamProxy() {
- return Optional.ofNullable(upstreamProxy);
- }
-
- /**
- * Sets the URL for the upstream/chained proxy.
- * Uses the user info for upstream proxy credentials.
- * @param upstreamProxy
- */
- public void setUpstreamProxy(URL upstreamProxy) {
- this.upstreamProxy = upstreamProxy;
- }
-
- public Optional getUpstreamNonProxy() {
- return Optional.ofNullable(upstreamNonProxy);
- }
-
- public void setUpstreamNonProxy(String upstreamNonProxy) {
- this.upstreamNonProxy = upstreamNonProxy;
- }
-
- public Optional getBindAddress() {
- return Optional.ofNullable(bindAddress);
- }
-
- public void setBindAddress(String bindAddress) {
- this.bindAddress = bindAddress;
- }
-}
diff --git a/bup/src/test/java/eu/tsystems/mms/tic/testerra/bup/playground/BupRemoteProxyManagerPlaygroundTest.java b/bup/src/test/java/eu/tsystems/mms/tic/testerra/bup/playground/BupRemoteProxyManagerPlaygroundTest.java
deleted file mode 100644
index ae0d65b03..000000000
--- a/bup/src/test/java/eu/tsystems/mms/tic/testerra/bup/playground/BupRemoteProxyManagerPlaygroundTest.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Testerra
- *
- * (C) 2020, Eric Kubenka, T-Systems Multimedia Solutions GmbH, Deutsche Telekom AG
- *
- * Deutsche Telekom AG and all other contributors /
- * copyright owners license this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this
- * file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package eu.tsystems.mms.tic.testerra.bup.playground;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import eu.tsystems.mms.tic.testerra.bup.BrowserUpRemoteProxyManager;
-import eu.tsystems.mms.tic.testerra.bup.BrowserUpRemoteProxyServer;
-import eu.tsystems.mms.tic.testframework.testing.TesterraTest;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-/**
- * Tests for {@link BrowserUpRemoteProxyManager}
- *
- * Date:25.05.2020
- * Time:10:43
- *
- * @author Eric Kubenka
- */
-
-public class BupRemoteProxyManagerPlaygroundTest extends TesterraTest {
-
- private static final String LOCAL_PROXY_FOR_TEST = "http://localhost:8080";
-
- @AfterMethod()
- public void tearDownAllProxies() throws MalformedURLException {
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- for (final Integer proxyPort : browserUpRemoteProxyManager.getProxies()) {
- final BrowserUpRemoteProxyServer bupToStop = new BrowserUpRemoteProxyServer();
- bupToStop.setPort(proxyPort);
- browserUpRemoteProxyManager.stopServer(bupToStop);
- }
- }
-
- @Test
- public void testT01_GetCurrentProxyServersWhenNoProxyIsRunning() throws MalformedURLException {
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final List servers = browserUpRemoteProxyManager.getProxies();
- Assert.assertEquals(servers.size(), 0);
- }
-
- @Test
- public void testT02_StartProxyServerOnRandomPortAndVerifyRunning() throws IOException {
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final BrowserUpRemoteProxyServer browserUpRemoteProxyServer = browserUpRemoteProxyManager.startServer();
- Assert.assertNotNull(browserUpRemoteProxyServer, "BrowserUp Proxy started.");
- Assert.assertEquals(browserUpRemoteProxyServer.getPort().intValue(), 8081, "Created proxy on first free port.");
-
- final boolean running = browserUpRemoteProxyManager.isRunning(browserUpRemoteProxyServer);
- Assert.assertTrue(running, "BrowserUp Proxy is running.");
- }
-
- @Test
- public void testT03_StartProxyServerOnDesiredPortAndVerifyRunning() throws IOException {
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- BrowserUpRemoteProxyServer bup1 = new BrowserUpRemoteProxyServer();
- bup1.setPort(8088);
-
- browserUpRemoteProxyManager.startServer(bup1);
- Assert.assertNotNull(bup1, "Proxy object generated.");
-
- Assert.assertEquals(bup1.getPort().intValue(), 8088, "Port equals desired.");
-
- final boolean running = browserUpRemoteProxyManager.isRunning(bup1);
- Assert.assertTrue(running, "BrowserUp Proxy is running.");
- }
-
- @Test
- public void testT04_StopProxyServer() throws IOException {
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final BrowserUpRemoteProxyServer bup1 = browserUpRemoteProxyManager.startServer();
- Assert.assertNotNull(bup1, "BrowserUp Proxy Session 1 started");
-
-
- final BrowserUpRemoteProxyServer bup2 = browserUpRemoteProxyManager.startServer();
- Assert.assertNotNull(bup2, "BrowserUp Proxy Session 2 started");
-
- Assert.assertNotEquals(bup1.getPort(), bup2.getPort(), "Ports dont match.");
-
- browserUpRemoteProxyManager.stopServer(bup2);
- Assert.assertTrue(browserUpRemoteProxyManager.isRunning(bup1), "BrowserUp Proxy Session 1 running.");
- Assert.assertFalse(browserUpRemoteProxyManager.isRunning(bup2), "BrowserUp Proxy Session 2 running.");
- }
-
- @Test
- public void testT05_AddHeader() throws MalformedURLException {
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final BrowserUpRemoteProxyServer bup1 = browserUpRemoteProxyManager.startServer();
- Assert.assertNotNull(bup1, "BrowserUp Proxy Session 1 started");
- Assert.assertTrue(browserUpRemoteProxyManager.addHeader(bup1, "foo", "bar"), "Headers set");
- }
-
- @Test
- public void testT06_Capture() throws MalformedURLException {
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final BrowserUpRemoteProxyServer bup1 = browserUpRemoteProxyManager.startServer();
-
- // create capture
- browserUpRemoteProxyManager.startCapture(bup1, null, false, false);
-
- // stop capture
- final JsonObject jsonHarResponse = (JsonObject) browserUpRemoteProxyManager.stopCapture(bup1);
- final JsonObject jsonLog = jsonHarResponse.getAsJsonObject("log");
- final JsonArray jsonPages = jsonLog.getAsJsonArray("pages");
-
- Assert.assertEquals(jsonPages.size(), 1, "Pages created on har.");
- }
-
- @Test
- public void testT07_AddHostMapping() throws MalformedURLException {
-
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final BrowserUpRemoteProxyServer bup1 = browserUpRemoteProxyManager.startServer();
-
- final HashMap hostNameMap = new HashMap<>();
- hostNameMap.put("example.com", "127.0.0.1");
- boolean b = browserUpRemoteProxyManager.setHostMapping(bup1, hostNameMap);
-
- Assert.assertTrue(b, "Host Mapping set.");
- }
-
- @Test
- public void testT08_IsProxyRunningExpectedFalse() throws IOException {
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- BrowserUpRemoteProxyServer browserUpRemoteProxyServer = new BrowserUpRemoteProxyServer();
- browserUpRemoteProxyServer.setPort(8081);
-
- final boolean running = browserUpRemoteProxyManager.isRunning(browserUpRemoteProxyServer);
- Assert.assertFalse(running, "BrowserUp Session running on port 8081");
- }
-
- @Test
- public void testT09_AddNewPageWhileCapturing() throws MalformedURLException {
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final BrowserUpRemoteProxyServer bup1 = browserUpRemoteProxyManager.startServer();
-
- // create capture
- browserUpRemoteProxyManager.startCapture(bup1, null, false, false);
-
- boolean b = browserUpRemoteProxyManager.addNewPage(bup1, "Page 2");
- Assert.assertTrue(b, "New HAR page created.");
-
- final JsonObject jsonHarResponse = (JsonObject) browserUpRemoteProxyManager.stopCapture(bup1);
- final JsonObject jsonLog = jsonHarResponse.getAsJsonObject("log");
- final JsonArray jsonPages = jsonLog.getAsJsonArray("pages");
-
- Assert.assertEquals(jsonPages.size(), 2, "Pages created on har.");
- }
-
- @Test
- public void testT10_AddBasicAuth() throws MalformedURLException {
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final BrowserUpRemoteProxyServer bup1 = browserUpRemoteProxyManager.startServer();
-
- boolean b = browserUpRemoteProxyManager.setBasicAuth(bup1, "example.com", "test", "test");
- Assert.assertTrue(b, "Basic auth set.");
- }
-
- @Test
- public void testT11_AddUpstreamProxy() throws MalformedURLException {
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
-
- BrowserUpRemoteProxyServer bup1 = new BrowserUpRemoteProxyServer();
- bup1.setUpstreamProxy(new URL("http://proxy.example:8080"));
-
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
- bup1 = browserUpRemoteProxyManager.startServer();
-
- }
-
-}
diff --git a/bup/src/test/java/eu/tsystems/mms/tic/testerra/bup/test/BupLocalProxyManagerTest.java b/bup/src/test/java/eu/tsystems/mms/tic/testerra/bup/test/BupLocalProxyManagerTest.java
deleted file mode 100644
index d0d8b3d7c..000000000
--- a/bup/src/test/java/eu/tsystems/mms/tic/testerra/bup/test/BupLocalProxyManagerTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Testerra
- *
- * (C) 2020, Eric Kubenka, T-Systems Multimedia Solutions GmbH, Deutsche Telekom AG
- *
- * Deutsche Telekom AG and all other contributors /
- * copyright owners license this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this
- * file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package eu.tsystems.mms.tic.testerra.bup.test;
-
-import com.browserup.bup.BrowserUpProxyServer;
-import eu.tsystems.mms.tic.testerra.bup.BrowserUpLocalProxyManager;
-import eu.tsystems.mms.tic.testerra.bup.BrowserUpNoFreePortException;
-import eu.tsystems.mms.tic.testframework.testing.TesterraTest;
-import java.util.ArrayList;
-import java.util.List;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- * test for {@link BrowserUpLocalProxyManager}
- * Date: 26.05.2020
- * Time: 11:36
- *
- * @author Eric Kubenka
- */
-public class BupLocalProxyManagerTest extends TesterraTest {
-
- private static List ports = new ArrayList<>();
- private static BrowserUpLocalProxyManager bupLocalManager;
-
- @BeforeMethod
- public void setUpPortPool() {
-
- ports.add(8090);
- ports.add(8091);
- ports.add(8092);
- ports.add(8093);
- ports.add(8094);
- ports.add(8095);
-
- bupLocalManager = new BrowserUpLocalProxyManager(ports);
- }
-
- @AfterMethod
- public void tearDownProxies() {
-
- bupLocalManager.stopAllServer();
- }
-
- @Test
- public void testT01_StartProxyOnFreePort() throws BrowserUpNoFreePortException {
-
- BrowserUpProxyServer browserUpProxyServer = new BrowserUpProxyServer();
- browserUpProxyServer = bupLocalManager.startServer(browserUpProxyServer);
-
- int port = browserUpProxyServer.getPort();
- Assert.assertTrue(ports.contains(port), "Port of range was used.");
- }
-
- @Test
- public void testT02_StartMultipleProxies() throws BrowserUpNoFreePortException {
-
- BrowserUpProxyServer bup1 = new BrowserUpProxyServer();
- BrowserUpProxyServer bup2 = new BrowserUpProxyServer();
- bup1 = bupLocalManager.startServer(bup1);
- bup2 = bupLocalManager.startServer(bup2);
-
- Assert.assertTrue(ports.contains(bup1.getPort()), "Port of range was used.");
- Assert.assertTrue(ports.contains(bup2.getPort()), "Port of range was used.");
-
- Assert.assertNotEquals(bup1.getPort(), bup2.getPort(), "Start on different ports.");
- }
-
- @Test(expectedExceptions = {BrowserUpNoFreePortException.class})
- public void testT03_StartProxiesUntilPoolEmpty() throws BrowserUpNoFreePortException {
-
- // fill complete port range.
- for (int i = 0; i < ports.size(); i++) {
- bupLocalManager.startServer(new BrowserUpProxyServer());
- }
-
- // add one more --> exception
- bupLocalManager.startServer(new BrowserUpProxyServer());
- }
-
- @Test
- public void testT04_StartAndStopServer() throws BrowserUpNoFreePortException {
-
- BrowserUpProxyServer bup1 = new BrowserUpProxyServer();
- bup1 = bupLocalManager.startServer(bup1);
-
- Assert.assertTrue(ports.contains(bup1.getPort()), "Port of range was used.");
- Assert.assertTrue(bup1.isStarted(), "Proxy started");
- Assert.assertFalse(bup1.isStopped(), "Proxy stopped");
-
- bupLocalManager.stopServer(bup1);
- Assert.assertTrue(bup1.isStopped(), "Proxy stopped");
-
- BrowserUpProxyServer bup2 = new BrowserUpProxyServer();
- bup2 = bupLocalManager.startServer(bup2);
-
- Assert.assertEquals(bup2.getPort(), bup1.getPort(), "Ports reused.");
- }
-
-}
diff --git a/bup/src/test/java/eu/tsystems/mms/tic/testerra/bup/test/BupRemoteProxyManagerTest.java b/bup/src/test/java/eu/tsystems/mms/tic/testerra/bup/test/BupRemoteProxyManagerTest.java
deleted file mode 100644
index 6e11360fe..000000000
--- a/bup/src/test/java/eu/tsystems/mms/tic/testerra/bup/test/BupRemoteProxyManagerTest.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * Testerra
- *
- * (C) 2020, Eric Kubenka, T-Systems Multimedia Solutions GmbH, Deutsche Telekom AG
- *
- * Deutsche Telekom AG and all other contributors /
- * copyright owners license this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this
- * file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package eu.tsystems.mms.tic.testerra.bup.test;
-
-import com.github.tomakehurst.wiremock.WireMockServer;
-import com.github.tomakehurst.wiremock.client.WireMock;
-import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
-import com.github.tomakehurst.wiremock.stubbing.StubMapping;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import eu.tsystems.mms.tic.testerra.bup.BrowserUpRemoteProxyManager;
-import eu.tsystems.mms.tic.testerra.bup.BrowserUpRemoteProxyServer;
-import eu.tsystems.mms.tic.testframework.testing.TesterraTest;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.List;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.binaryEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.removeStub;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
-/**
- * Tests for {@link BrowserUpRemoteProxyManager}
- *
- * Date:25.05.2020
- * Time:10:43
- *
- * @author Eric Kubenka
- */
-
-public class BupRemoteProxyManagerTest extends TesterraTest {
-
- private static final int WIREMOCK_SERVER_PORT = 81;
- private static final String WIREMOCK_SERVER_HOST = "localhost";
-
- private static final String LOCAL_PROXY_FOR_TEST = "http://" + WIREMOCK_SERVER_HOST + ":" + WIREMOCK_SERVER_PORT;
-
- private static WireMockServer WIREMOCK_SERVER = null;
-
- private enum Response {
-
- GET_PROXY_EMPTY("{\"proxyList\":[]}"),
- GET_PROXY_8081("{\"proxyList\":[{\"port\":8081}]}"),
- GET_PROXY_8088("{\"proxyList\":[{\"port\":8088}]}"),
- POST_PROXY_8081("{\"port\":8081}"),
- POST_PROXY_8088("{\"port\":8088}"),
- DELETE_PROXY_8088(""),
- PUT_HAR_8081(""),
- POST_HOSTS_8081(""),
- GET_HAR_8081("{\"log\":{\"version\":\"1.1\",\"creator\":{\"name\":\"BrowserUp Proxy\",\"version\":\"${project.version}\"},\"pages\":[{\"startedDateTime\":\"2020-05-26T10:46:40.901+0200\",\"id\":\"Page 0\",\"title\":\"Page 0\",\"pageTimings\":{\"onContentLoad\":-1,\"onLoad\":-1}}],\"entries\":[]}}"),
- GET_HAR_8081_TWO_PAGES("{\"log\":{\"version\":\"1.1\",\"creator\":{\"name\":\"BrowserUp Proxy\",\"version\":\"${project.version}\"},\"pages\":[{\"startedDateTime\":\"2020-05-26T10:56:30.077+0200\",\"id\":\"Page 0\",\"title\":\"Page 0\",\"pageTimings\":{\"onContentLoad\":-1,\"onLoad\":9}},{\"startedDateTime\":\"2020-05-26T10:56:30.088+0200\",\"id\":\"Page 2\",\"title\":\"Page 2\",\"pageTimings\":{\"onContentLoad\":-1,\"onLoad\":-1}}],\"entries\":[]}}"),
- POST_HEADERS_8081(""),
- PUT_HAR_PAGEREF_8081(""),
- POST_AUTH_BASIC_8081("");
-
- final String response;
-
- Response(String response) {
- this.response = response;
- }
-
- public String getResponse() {
- return response;
- }
- }
-
- @BeforeMethod
- private void setupWireMockServer() {
-
- WireMock.configureFor(WIREMOCK_SERVER_HOST, WIREMOCK_SERVER_PORT);
- WIREMOCK_SERVER = new WireMockServer(new WireMockConfiguration().port(WIREMOCK_SERVER_PORT));
- WIREMOCK_SERVER.start();
- }
-
- @AfterMethod()
- public void tearDownWireMockServer() {
-
- WireMock.reset();
- WIREMOCK_SERVER.stop();
- }
-
- @Test
- public void testT01_GetCurrentProxyServersWhenNoProxyIsRunning() throws MalformedURLException {
-
- stubFor(get(urlEqualTo("/proxy"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.GET_PROXY_EMPTY.getResponse())));
-
- // ### Test Start ###
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final List servers = browserUpRemoteProxyManager.getProxies();
- Assert.assertEquals(servers.size(), 0, "Servers empty after start");
- }
-
- @Test
- public void testT02_StartProxyServerOnRandomPortAndVerifyRunning() throws IOException {
-
- stubFor(post(urlMatching("/proxy\\?.*"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.POST_PROXY_8081.getResponse())));
-
- stubFor(get(urlEqualTo("/proxy"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.GET_PROXY_8081.getResponse())));
-
- // ### Test Start ###
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final BrowserUpRemoteProxyServer browserUpRemoteProxyServer = browserUpRemoteProxyManager.startServer();
- Assert.assertNotNull(browserUpRemoteProxyServer, "BrowserUp Proxy started.");
- Assert.assertEquals(browserUpRemoteProxyServer.getPort().intValue(), 8081, "Created proxy on first free port.");
-
- final boolean running = browserUpRemoteProxyManager.isRunning(browserUpRemoteProxyServer);
- Assert.assertTrue(running, "BrowserUp Proxy is running.");
- }
-
- @Test
- public void testT03_StartProxyServerOnDesiredPortAndVerifyRunning() throws IOException {
-
- stubFor(post(urlMatching("/proxy\\?port=8088.*"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.POST_PROXY_8088.getResponse())));
-
- final StubMapping emptyListStub = stubFor(get(urlEqualTo("/proxy"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.GET_PROXY_EMPTY.getResponse())));
-
- // ### Test Start ###
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- BrowserUpRemoteProxyServer browserUpRemoteProxyServer = new BrowserUpRemoteProxyServer();
- browserUpRemoteProxyServer.setPort(8088);
- browserUpRemoteProxyManager.startServer(browserUpRemoteProxyServer);
- Assert.assertNotNull(browserUpRemoteProxyServer, "Proxy object generated.");
-
- Assert.assertEquals(browserUpRemoteProxyServer.getPort().intValue(), 8088, "Port equals desired.");
-
- // ### Change stubbing ###
- removeStub(emptyListStub);
- stubFor(get(urlEqualTo("/proxy"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.GET_PROXY_8088.getResponse())));
-
- final boolean running = browserUpRemoteProxyManager.isRunning(browserUpRemoteProxyServer);
- Assert.assertTrue(running, "BrowserUp Proxy is running.");
- }
-
- @Test
- public void testT03a_StartProxyServerWithExtendedOptionsAndVerifyRunning() throws IOException {
-
- stubFor(post(urlMatching("/proxy\\?port=8088.*"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.POST_PROXY_8088.getResponse())));
-
- final StubMapping emptyListStub = stubFor(get(urlEqualTo("/proxy"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.GET_PROXY_EMPTY.getResponse())));
-
- // ### Test Start ###
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- BrowserUpRemoteProxyServer browserUpRemoteProxyServer = new BrowserUpRemoteProxyServer();
- browserUpRemoteProxyServer.setPort(8088);
- // Set other options for proxy server
- // Unfortunately, BrowsreUP proxy REST API does not allow to verify such settings.
- browserUpRemoteProxyServer.setBindAddress("192.168.100.1");
- browserUpRemoteProxyServer.setUpstreamProxy(new URL("http://proxy.company.example.org:8080"));
- browserUpRemoteProxyServer.setUpstreamNonProxy(".internal.example.org|.mystuff.example.org");
- browserUpRemoteProxyManager.startServer(browserUpRemoteProxyServer);
- Assert.assertNotNull(browserUpRemoteProxyServer, "Proxy object generated.");
-
- Assert.assertEquals(browserUpRemoteProxyServer.getPort().intValue(), 8088, "Port equals desired.");
-
- // ### Change stubbing ###
- removeStub(emptyListStub);
- stubFor(get(urlEqualTo("/proxy"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.GET_PROXY_8088.getResponse())));
-
- final boolean running = browserUpRemoteProxyManager.isRunning(browserUpRemoteProxyServer);
- Assert.assertTrue(running, "BrowserUp Proxy is running.");
- }
-
- @Test
- public void testT04_StopProxyServer() throws IOException {
-
- stubFor(delete(urlEqualTo("/proxy/8088"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.DELETE_PROXY_8088.getResponse())));
-
- // ### Test Start ###
- BrowserUpRemoteProxyServer browserUpRemoteProxyServer = new BrowserUpRemoteProxyServer();
- browserUpRemoteProxyServer.setPort(8088);
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
- browserUpRemoteProxyManager.stopServer(browserUpRemoteProxyServer);
- }
-
- @Test
- public void testT05_AddHeader() throws MalformedURLException {
-
- byte[] bytes = "{\"foo\":\"bar\"}".getBytes(Charset.defaultCharset());
-
- stubFor(post(urlEqualTo("/proxy/8081/headers"))
- .withRequestBody(binaryEqualTo(bytes))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.POST_HEADERS_8081.getResponse())));
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final BrowserUpRemoteProxyServer bup1 = new BrowserUpRemoteProxyServer();
- bup1.setPort(8081);
-
- Assert.assertTrue(browserUpRemoteProxyManager.addHeader(bup1, "foo", "bar"), "Headers set");
- }
-
- @Test
- public void testT06_Capture() throws MalformedURLException {
-
- final BrowserUpRemoteProxyServer bup1 = new BrowserUpRemoteProxyServer();
- bup1.setPort(8081);
-
- stubFor(put(urlEqualTo("/proxy/8081/har"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.PUT_HAR_8081.getResponse())));
-
- stubFor(get(urlEqualTo("/proxy/8081/har"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.GET_HAR_8081.getResponse())));
-
-
- // create capture
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
- browserUpRemoteProxyManager.startCapture(bup1, null, false, false);
-
- // stop capture
- final JsonObject jsonHarResponse = (JsonObject) browserUpRemoteProxyManager.stopCapture(bup1);
- final JsonObject jsonLog = jsonHarResponse.getAsJsonObject("log");
- final JsonArray jsonPages = jsonLog.getAsJsonArray("pages");
-
- Assert.assertEquals(jsonPages.size(), 1, "Pages created on har.");
- }
-
- @Test
- public void testT07_AddHostMapping() throws MalformedURLException {
-
- final String expectedContent = "{\"example.com\":\"127.0.0.1\"}";
-
- stubFor(post(urlEqualTo("/proxy/8081/hosts"))
- .withRequestBody(binaryEqualTo(expectedContent.getBytes()))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.POST_HOSTS_8081.getResponse())));
-
-
- final BrowserUpRemoteProxyServer bup1 = new BrowserUpRemoteProxyServer();
- bup1.setPort(8081);
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final HashMap hostNameMap = new HashMap<>();
- hostNameMap.put("example.com", "127.0.0.1");
-
- boolean b = browserUpRemoteProxyManager.setHostMapping(bup1, hostNameMap);
- Assert.assertTrue(b, "Host Mapping set.");
- }
-
- @Test
- public void testT08_IsProxyRunningExpectedFalse() throws IOException {
-
- stubFor(get(urlEqualTo("/proxy"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.GET_PROXY_8088.getResponse())));
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- BrowserUpRemoteProxyServer browserUpRemoteProxyServer = new BrowserUpRemoteProxyServer();
- browserUpRemoteProxyServer.setPort(8081);
-
- final boolean running = browserUpRemoteProxyManager.isRunning(browserUpRemoteProxyServer);
- Assert.assertFalse(running, "BrowserUp Session running on port 8081");
- }
-
- @Test
- public void testT09_AddNewPageWhileCapturing() throws MalformedURLException {
-
- stubFor(put(urlEqualTo("/proxy/8081/har/pageRef?pageRef=Page+2"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.PUT_HAR_PAGEREF_8081.getResponse())));
-
- stubFor(get(urlEqualTo("/proxy/8081/har"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.GET_HAR_8081_TWO_PAGES.getResponse())));
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- BrowserUpRemoteProxyServer bup1 = new BrowserUpRemoteProxyServer();
- bup1.setPort(8081);
-
- boolean b = browserUpRemoteProxyManager.addNewPage(bup1, "Page 2");
- Assert.assertTrue(b, "New HAR page created.");
-
- final JsonObject jsonHarResponse = (JsonObject) browserUpRemoteProxyManager.stopCapture(bup1);
- final JsonObject jsonLog = jsonHarResponse.getAsJsonObject("log");
- final JsonArray jsonPages = jsonLog.getAsJsonArray("pages");
-
- Assert.assertEquals(jsonPages.size(), 2, "Pages created on har.");
- }
-
- @Test
- public void testT10_AddBasicAuth() throws MalformedURLException {
-
- final String expectedContent = "{\"username\":\"test\",\"password\":\"test\"}";
-
- stubFor(post(urlEqualTo("/proxy/8081/auth/basic/example.com"))
- .withRequestBody(binaryEqualTo(expectedContent.getBytes()))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.POST_HOSTS_8081.getResponse())));
-
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- final BrowserUpRemoteProxyServer bup1 = new BrowserUpRemoteProxyServer();
- bup1.setPort(8081);
-
- boolean b = browserUpRemoteProxyManager.setBasicAuth(bup1, "example.com", "test", "test");
- Assert.assertTrue(b, "Basic auth set.");
- }
-
- @Test
- public void testT11_AddUpstreamProxy() throws MalformedURLException {
-
- stubFor(post(urlMatching("/proxy.*httpProxy=proxy.example%3A8080"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/json")
- .withBody(Response.POST_PROXY_8081.getResponse())));
-
- BrowserUpRemoteProxyServer bup1 = new BrowserUpRemoteProxyServer();
- bup1.setUpstreamProxy(new URL("http://proxy.example:8080"));
-
- final URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
- final BrowserUpRemoteProxyManager browserUpRemoteProxyManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
- browserUpRemoteProxyManager.startServer(bup1);
- }
-
-}
diff --git a/bup/src/test/resources/playground.xml b/bup/src/test/resources/playground.xml
deleted file mode 100644
index ea748ad65..000000000
--- a/bup/src/test/resources/playground.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/bup/src/test/resources/test.xml b/bup/src/test/resources/test.xml
deleted file mode 100644
index a66167a26..000000000
--- a/bup/src/test/resources/test.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/src/docs/modules.adoc b/docs/src/docs/modules.adoc
index 2e9dc35ca..555ad3fc4 100644
--- a/docs/src/docs/modules.adoc
+++ b/docs/src/docs/modules.adoc
@@ -1,6 +1,5 @@
= Modules
-include::modules/browser-up-proxy.adoc[leveloffset=+1]
include::modules/layout-check.adoc[leveloffset=+1]
include::modules/localization.adoc[leveloffset=+1]
include::modules/mail-connector.adoc[leveloffset=+1]
diff --git a/docs/src/docs/modules/browser-up-proxy.adoc b/docs/src/docs/modules/browser-up-proxy.adoc
deleted file mode 100644
index 05c745005..000000000
--- a/docs/src/docs/modules/browser-up-proxy.adoc
+++ /dev/null
@@ -1,217 +0,0 @@
-= BrowserUp Proxy
-
-https://github.com/browserup/browserup-proxy[BrowserUp Proxy (BUP)] is a simple HTTP proxy utility developed by https://browserup.com[browserup.com].
-It offers functionality to track, manipulate and modify HTTP requests and responses, as well as capture HTTP traffic for analysis.
-
-Testerra offers a simple integration to spin multiple local proxy servers or manage remote proxy servers via HTTP API.
-
-== Project setup
-
-.build.gradle
-[source,groovy,role="primary",subs="attributes"]
-----
-compile 'io.testerra:bup:{revnumber}'
-----
-
-.pom.xml
-[source,xml,role="secondary",subs="attributes+"]
-----
-
-
- io.testerra
- bup
- {revnumber}
-
-
-----
-
-== External Proxy Server
-
-Best practice for using a Testerra with an external proxy, is to use a dedicated BrowserUp Instance. To start these instance, please have a further read on the BrowserUp documentation.
-
-To handle remote a BrowserUp proxy instance Testerra provides a simple REST client (see also https://github.com/browserup/browserup-proxy#rest-api).
-
-[source,java]
-----
-import eu.tsystems.mms.tic.testerra.bup.BrowserUpRemoteProxyManager;
-import eu.tsystems.mms.tic.testerra.bup.BrowserUpRemoteProxyServer;
-import eu.tsystems.mms.tic.testframework.testing.TesterraTest;
-import org.openqa.selenium.Proxy;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeSuite;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-public class AbstractTest extends TesterraTest {
-
- private static BrowserUpRemoteProxyServer bupProxy = new BrowserUpRemoteProxyServer();
-
- @BeforeSuite
- public void setupProxy() throws MalformedURLException {
- URL apiUrl = new URL("http://localhost:8080");
- BrowserUpRemoteProxyManager bupManager = new BrowserUpRemoteProxyManager(apiUrl);
- bupManager.startServer(bupProxy);
-
- /* Additional Proxy setup here */
- String bmpProxyAddress = String.format("%s:%d", apiUrl.getHost(), bupProxy.getPort());
-
- // For selenium usage.
- Proxy proxy = new Proxy();
- proxy.setHttpProxy(bmpProxyAddress).setSslProxy(bmpProxyAddress);
-
- WebDriverManager.setGlobalExtraCapability(CapabilityType.PROXY, proxy);
- }
-
- @AfterSuite
- public void tearDownProxy() throws MalformedURLException {
-
- URL apiBaseUrl = new URL("http://localhost:8080");
- BrowserUpRemoteProxyManager bupManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
- for (Integer proxyPort : bupManager.getProxies()) {
- BrowserUpRemoteProxyServer bupToStop = new BrowserUpRemoteProxyServer();
- bupToStop.setPort(proxyPort);
- bupManager.stopServer(bupToStop);
- }
- }
-}
-----
-
-BrowserUp creates a new proxy server at the next free port beginning with port 8081 (BrowserUp default).
-
-If you need a dedicated port, use `startServer(BrowserUpRemoteProxyServer proxyServer)` method the following way.
-
-[source,java]
-----
-BrowserUpRemoteProxyServer browserUpRemoteProxyServer = new BrowserUpRemoteProxyServer();
-browserUpRemoteProxyServer.setPort(8088);
-
-bupManager.startServer(browserUpRemoteProxyServer);
-----
-
-If the port already used, the `BrowserUpRemoteProxyManager` will do nothing, and just return the given config-object of type `BrowserUpRemoteProxyServer`.
-
-=== Basic Auth
-
-If your SUT is protected by HTTP basic auth, you can set up these credentials as following.
-
-[source,java]
-----
-URL baseUrl = WEB_DRIVER_MANAGER.getConfig().getBaseUrl().get();
-String basicAuthUser;
-String basicAuthPassword;
-
-URL apiBaseUrl = new URL(LOCAL_PROXY_FOR_TEST);
-BrowserUpRemoteProxyManager bupManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-BrowserUpRemoteProxyServer bup1 = new BrowserUpRemoteProxyServer();
-bupManager.startServer(bup1);
-
-bupManager.setBasicAuth(bup1, baseUrl.getHost(), basicAuthUser, basicAuthPassword);
-----
-
-=== Upstream proxy
-
-If you need to use a proxy to reach your SUT, you can set up BrowserUp proxy instance to use an upstream proxy.
-
-[source,java]
-----
-BrowserUpRemoteProxyServer bup1 = new BrowserUpRemoteProxyServer();
-bup1.setUpstreamProxy(ProxyUtils.getSystemHttpProxyUrl());
-
-// Setup non-proxy for your upstream proxy, if needed
-bup1.setUpstreamNonProxy(".internal.example.org|.mystuff.example.org");
-
-BrowserUpRemoteProxyManager bupManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-bupManager.startServer(bup1);
-----
-
-NOTE: User info like `username:password` is supported in your upstream proxy URL.
-
-=== Setup bind address
-
-If running BrowserUp Proxy in a multi-homed environment, you can specify a desired server bind address.
-
-[source,java]
-----
-BrowserUpRemoteProxyServer bup1 = new BrowserUpRemoteProxyServer();
-
-// Setup a bind address, default is '0.0.0.0'
-bup1.setBindAddress("192.168.100.1");
-
-BrowserUpRemoteProxyManager bupManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-bupManager.startServer(bup1);
-----
-
-=== Other features
-
-[source,java]
-----
-/*
- Check if proxy alread runs on port...
- */
-BrowserUpRemoteProxyManager bupManager = new BrowserUpRemoteProxyManager(apiBaseUrl);
-
-BrowserUpRemoteProxyServer bup1 = new BrowserUpRemoteProxyServer();
-bup1.setPort(8088);
-
-bupManager.startServer(bup1);
-boolean isRunning = bupManager.isRunning(bup1);
-
-/*
- Maps specific host names to another host names or IP adresses
- */
-bupManager.setHostMapping(BrowserUpRemoteProxyServer proxyServer, Map hostMap);
-
-/*
- Capture the traffic and return it as a JsonElement
- You can choose, if you want to capture only the headers, the content or both via the boolean flags.
- */
-bupManager.startCapture(
- BrowserUpRemoteProxyServer proxyServer,
- String initialPageRef,
- boolean isCaptureHeaders,
- boolean isCaptureContent
-);
-JsonElement stopCapture(BrowserUpRemoteProxyServer proxyServer);
-
-/*
- Adds additional key-value pairs to the headers.
-*/
-bupManager.addHeader(BrowserUpRemoteProxyServer proxyServer, String key, String value);
-----
-
-== Local browser instances
-
-If you want to quickly spin up a proxy isntance on your local system while testing, you can use the `BrowserUpLocalProxyManager`.
-
-[source,java]
-----
-List portPool = new ArrayList<>();
-ports.add(8090);
-ports.add(8091);
-ports.add(8092);
-ports.add(8093);
-ports.add(8094);
-ports.add(8095);
-
-BrowserUpLocalProxyManager bupLocalManager = new BrowserUpLocalProxyManager(ports);
-
-// Start instance
-BrowserUpProxyServer browserUpProxyServer = new BrowserUpProxyServer();
-bupLocalManager.startServer(browserUpProxyServer);
-
-// assert that a port of given port pool was used.
-Assert.assertTrue(portPool.contains(port), "Port of range was used.");
-
-// assert proxy is started.
-Assert.assertTrue(bup1.isStarted(), "Proxy started");
-
-----
-
-The local proxy manager works with a defined port pool, which has to be declared on instantiation of the manager class.
-This port pool will be used to spin up multiple proxy servers for a multi threading test execution.
-
-The port pool has to be declared by yourself, respectively your code, because, only you can know which ports are currently free to use on your local test execution machine.
-
-To use upstream proxies, add headers or do other things on the local proxy server, please take a closer look on https://github.com/browserup/browserup-proxy[BrowserUp] documentation.
diff --git a/license3rdparty/bup.md b/license3rdparty/bup.md
deleted file mode 100644
index f879b7abf..000000000
--- a/license3rdparty/bup.md
+++ /dev/null
@@ -1,37 +0,0 @@
-
-#bup
-##Dependency License Report
-_2024-03-05 07:59:00 MEZ_
-## Apache 2.0
-
-**1** **Group:** `com.google.code.gson` **Name:** `gson` **Version:** `2.8.8`
-> - **Manifest Project URL**: [https://github.com/google/gson/gson](https://github.com/google/gson/gson)
-> - **Manifest License**: "Apache 2.0";link="https://www.apache.org/licenses/LICENSE-2.0.txt" (Not Packaged)
-> - **POM License**: Apache 2.0 - [https://www.apache.org/licenses/LICENSE-2.0.txt](https://www.apache.org/licenses/LICENSE-2.0.txt)
-
-## Apache License, Version 2.0
-
-**2** **Group:** `org.apache.httpcomponents` **Name:** `httpclient` **Version:** `4.5.13`
-> - **POM Project URL**: [http://hc.apache.org/httpcomponents-client](http://hc.apache.org/httpcomponents-client)
-> - **POM License**: Apache License, Version 2.0 - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt)
-> - **Embedded license files**: [httpclient-4.5.13.jar/META-INF/LICENSE](httpclient-4.5.13.jar/META-INF/LICENSE)
- - [httpclient-4.5.13.jar/META-INF/NOTICE](httpclient-4.5.13.jar/META-INF/NOTICE)
-
-**3** **Group:** `org.apache.httpcomponents` **Name:** `httpcore` **Version:** `4.4.14`
-> - **POM Project URL**: [http://hc.apache.org/httpcomponents-core-ga](http://hc.apache.org/httpcomponents-core-ga)
-> - **POM License**: Apache License, Version 2.0 - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt)
-> - **Embedded license files**: [httpcore-4.4.14.jar/META-INF/LICENSE](httpcore-4.4.14.jar/META-INF/LICENSE)
- - [httpcore-4.4.14.jar/META-INF/NOTICE](httpcore-4.4.14.jar/META-INF/NOTICE)
-
-## The Apache Software License, Version 2.0
-
-**4** **Group:** `com.browserup` **Name:** `browserup-proxy-core` **Version:** `2.1.2`
-> - **POM Project URL**: [https://github.com/browserup/browserup-proxy](https://github.com/browserup/browserup-proxy)
-> - **POM License**: The Apache Software License, Version 2.0 - [http://www.apache.org/licenses/LICENSE-2.0.txt](http://www.apache.org/licenses/LICENSE-2.0.txt)
-
-**5** **Group:** `com.github.tomakehurst` **Name:** `wiremock-jre8` **Version:** `2.26.3`
-> - **POM Project URL**: [http://wiremock.org](http://wiremock.org)
-> - **POM License**: The Apache Software License, Version 2.0 - [http://www.apache.org/license/LICENSE-2.0.txt](http://www.apache.org/license/LICENSE-2.0.txt)
-> - **Embedded license files**: [wiremock-jre8-2.26.3.jar/assets/swagger-ui/swagger-ui-dist/README.md](wiremock-jre8-2.26.3.jar/assets/swagger-ui/swagger-ui-dist/README.md)
-
-
diff --git a/settings.gradle b/settings.gradle
index 70c1c95cf..e4d819aa7 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -6,7 +6,6 @@ include 'driver-ui-desktop'
include 'mail-connector'
include 'integration-tests'
include 'docs'
-include 'bup'
include 'report-model'
include 'report-ng'
include 'report-ng:app'