Skip to content

Commit 8fe78d3

Browse files
committed
introduce mitmproxy dependency to prepare new dependency from cerberus-robot-proxy
1 parent aebc32d commit 8fe78d3

File tree

6 files changed

+19
-7
lines changed

6 files changed

+19
-7
lines changed

source/src/main/java/org/cerberus/core/api/dto/robot/RobotExecutorDTOV001.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public class RobotExecutorDTOV001 {
106106
private String hostPassword;
107107

108108
@JsonView({View.Public.GET.class, View.Public.POST.class, View.Public.PATCH.class, View.Public.PUT.class})
109-
@Schema(description = "Executor proxy type",example = "NONE",allowableValues = {"NONE", "MANUAL", "NETWORKTRAFFIC"})
109+
@Schema(description = "Executor proxy type",example = "NONE",allowableValues = {"NONE", "MANUAL", "NETWORKTRAFFIC", "MITMPROXY"})
110110
private String executorProxyType;
111111

112112
@JsonView({View.Public.GET.class, View.Public.POST.class, View.Public.PATCH.class, View.Public.PUT.class})

source/src/main/java/org/cerberus/core/crud/entity/RobotExecutor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public class RobotExecutor {
6767
public static final String PROXY_TYPE_NONE = "NONE"; // No Proxy. Browser will connect directly on Internet
6868
public static final String PROXY_TYPE_MANUAL = "MANUAL"; // A Manual proxy is configured on executorBrowserProxyHost and executorBrowserProxyPort
6969
public static final String PROXY_TYPE_NETWORKTRAFFIC = "NETWORKTRAFFIC"; // Proxy will be configured to Cerberus robot proxy component --> Network traffic features will be activated.
70+
public static final String PROXY_TYPE_MITMPROXY = "MITMPROXY";
7071

7172
public Integer getExecutorExtensionProxyPort() {
7273
return executorExtensionProxyPort;

source/src/main/java/org/cerberus/core/engine/execution/impl/RobotServerService.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,11 @@ public void startServer(TestCaseExecution execution) throws CerberusException {
257257
* Starting Cerberus Robot Proxy if it has been activated at
258258
* robot level.
259259
*/
260-
if (execution.getRobotExecutorObj() != null && RobotExecutor.PROXY_TYPE_NETWORKTRAFFIC.equals(execution.getRobotExecutorObj().getExecutorProxyType())) {
260+
if (execution.getRobotExecutorObj() != null && (
261+
RobotExecutor.PROXY_TYPE_NETWORKTRAFFIC.equals(execution.getRobotExecutorObj().getExecutorProxyType()) ||
262+
RobotExecutor.PROXY_TYPE_MITMPROXY.equals(execution.getRobotExecutorObj().getExecutorProxyType()))) {
261263
LOG.debug("Start Remote Cerberus Proxy");
262-
executorService.startRemoteProxy(execution);
264+
executorService.startRemoteProxy(execution, execution.getRobotExecutorObj().getExecutorProxyType());
263265
LOG.debug("Started Remote Cerberus Robot Proxy on port: {}", execution.getRemoteProxyPort());
264266
}
265267

@@ -616,9 +618,11 @@ public void startServerV2(TestCaseExecution execution) throws CerberusException
616618
* Starting Cerberus Executor Proxy if it has been activated at
617619
* robot level.
618620
*/
619-
if (execution.getRobotExecutorObj() != null && RobotExecutor.PROXY_TYPE_NETWORKTRAFFIC.equals(execution.getRobotExecutorObj().getExecutorProxyType())) {
621+
if (execution.getRobotExecutorObj() != null &&
622+
(RobotExecutor.PROXY_TYPE_NETWORKTRAFFIC.equals(execution.getRobotExecutorObj().getExecutorProxyType()) ||
623+
RobotExecutor.PROXY_TYPE_MITMPROXY.equals(execution.getRobotExecutorObj().getExecutorProxyType()))) {
620624
LOG.debug("Start Remote Proxy");
621-
executorService.startRemoteProxy(execution);
625+
executorService.startRemoteProxy(execution, execution.getRobotExecutorObj().getExecutorProxyType());
622626
LOG.debug("Started Remote Proxy on port: {}", execution.getRemoteProxyPort());
623627
}
624628

source/src/main/java/org/cerberus/core/service/robotproxy/IRobotProxyService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public interface IRobotProxyService {
3535
*
3636
* @param tce
3737
*/
38-
void startRemoteProxy(TestCaseExecution tce);
38+
void startRemoteProxy(TestCaseExecution tce, String proxyType);
3939

4040
/**
4141
*

source/src/main/java/org/cerberus/core/service/robotproxy/impl/RobotProxyService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,16 @@ public class RobotProxyService implements IRobotProxyService {
6363
private static final org.apache.logging.log4j.Logger LOG = org.apache.logging.log4j.LogManager.getLogger(RobotProxyService.class);
6464

6565
@Override
66-
public void startRemoteProxy(TestCaseExecution tce) {
66+
public void startRemoteProxy(TestCaseExecution tce, String proxyType) {
6767

6868
String url = "http://" + tce.getRobotExecutorObj().getExecutorProxyServiceHost() + ":" + tce.getRobotExecutorObj().getExecutorProxyServicePort()
6969
+ "/startProxy?timeout=" + String.valueOf(parameterService.getParameterIntegerByKey("cerberus_executorproxy_timeoutms", tce.getSystem(), 3600000));
7070
if (tce.getRobotExecutorObj().getExecutorBrowserProxyPort() != 0) {
7171
url += "&port=" + tce.getRobotExecutorObj().getExecutorBrowserProxyPort();
7272
}
73+
if (RobotExecutor.PROXY_TYPE_MITMPROXY.equals(proxyType)) {
74+
url += "&proxyType=mitmproxy";
75+
}
7376

7477
if (TestCaseExecution.ROBOTPROVIDER_BROWSERSTACK.equals(tce.getRobotProvider())) {
7578
url += "&bsLocalProxyActive=true";

source/src/main/resources/database.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6804,3 +6804,7 @@ INSERT INTO `invariant` (`idname`, `value`, `sort`, `description`)
68046804

68056805
-- 1932
68066806
ALTER TABLE appservice ADD ServiceRequestExtra1 MEDIUMTEXT NULL AFTER `ServiceRequest`;
6807+
6808+
-- 1933
6809+
INSERT INTO `invariant` (`idname`, `value`, `sort`, `description`)
6810+
VALUES ('PROXYTYPE', 'MITMPROXY', 400, 'Mitm Proxy with Network Traffic analysis and control.');

0 commit comments

Comments
 (0)