Skip to content

Commit

Permalink
refactor(robot-proxy): renaming executorProxyHost to executorBrowserP…
Browse files Browse the repository at this point in the history
…roxyHost
  • Loading branch information
lucashimpens committed Feb 13, 2025
1 parent c3ed04a commit 7532435
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public AnswerList<RobotExecutor> readByVariousByCriteria(List<String> robot, Str
public Answer create(RobotExecutor object) {
MessageEvent msg = null;
StringBuilder query = new StringBuilder();
query.append("INSERT INTO robotexecutor (`robot`, `executor`, `isactive`, `rank`, `host`, `port`, `host_user`, `host_password`, `deviceudid`, `devicename`, `deviceport`, `isdevicelockunlock`, `ExecutorProxyServiceHost`, `ExecutorProxyServicePort`, `executorproxyhost`, `executorproxyport`, `executorproxytype`, `description`, `usrcreated`) ");
query.append("INSERT INTO robotexecutor (`robot`, `executor`, `isactive`, `rank`, `host`, `port`, `host_user`, `host_password`, `deviceudid`, `devicename`, `deviceport`, `isdevicelockunlock`, `ExecutorProxyServiceHost`, `ExecutorProxyServicePort`, `ExecutorBrowserProxyHost`, `executorproxyport`, `executorproxytype`, `description`, `usrcreated`) ");
query.append("VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");

// Debug message on SQL.
Expand Down Expand Up @@ -303,7 +303,7 @@ public Answer create(RobotExecutor object) {
} else {
preStat.setNull(i++, Types.INTEGER);
}
preStat.setString(i++, object.getExecutorProxyHost());
preStat.setString(i++, object.getExecutorBrowserProxyHost());
if (object.getExecutorProxyPort() != null) {
preStat.setInt(i++, object.getExecutorProxyPort());
} else {
Expand Down Expand Up @@ -367,7 +367,7 @@ public Answer delete(RobotExecutor object) {
@Override
public Answer update(String robot, String executor, RobotExecutor object) {
MessageEvent msg = null;
final String query = "UPDATE robotexecutor SET `robot` = ?, `executor` = ?, description = ?, isactive = ?, `rank` = ?, `host` = ?, `port` = ?, `host_user` = ?, `host_password` = ?, `deviceudid` = ?, `devicename` = ?, `deviceport` = ?, `isdevicelockunlock` = ?, `ExecutorProxyServiceHost` = ?, `ExecutorProxyServicePort` = ?, `executorproxyhost` = ?, `executorproxyport` = ?, `executorproxytype` = ?, "
final String query = "UPDATE robotexecutor SET `robot` = ?, `executor` = ?, description = ?, isactive = ?, `rank` = ?, `host` = ?, `port` = ?, `host_user` = ?, `host_password` = ?, `deviceudid` = ?, `devicename` = ?, `deviceport` = ?, `isdevicelockunlock` = ?, `ExecutorProxyServiceHost` = ?, `ExecutorProxyServicePort` = ?, `ExecutorBrowserProxyHost` = ?, `executorproxyport` = ?, `executorproxytype` = ?, "
+ "dateModif = NOW(), usrModif= ? WHERE `robot` = ? and `executor` = ?";

// Debug message on SQL.
Expand Down Expand Up @@ -403,7 +403,7 @@ public Answer update(String robot, String executor, RobotExecutor object) {
} else {
preStat.setNull(i++, Types.INTEGER);
}
preStat.setString(i++, object.getExecutorProxyHost());
preStat.setString(i++, object.getExecutorBrowserProxyHost());
if (object.getExecutorProxyPort() != null) {
preStat.setInt(i++, object.getExecutorProxyPort());
} else {
Expand Down Expand Up @@ -474,7 +474,7 @@ public RobotExecutor loadFromResultSet(ResultSet rs) throws SQLException {
boolean isDevicelockunlock = rs.getBoolean("rbe.isdevicelockunlock");
String executorProxyServiceHost = rs.getString("rbe.ExecutorProxyServiceHost");
Integer executorProxyServicePort = rs.getInt("rbe.ExecutorProxyServicePort");
String executorProxyHost = rs.getString("rbe.executorproxyhost");
String executorBrowserProxyHost = rs.getString("rbe.ExecutorBrowserProxyHost");
Integer executorProxyPort = rs.getInt("rbe.executorproxyport");
String executorProxyType = rs.getString("rbe.executorproxytype");
if(deviceport == 0) {
Expand All @@ -489,7 +489,7 @@ public RobotExecutor loadFromResultSet(ResultSet rs) throws SQLException {

//TODO remove when working in test with mockito and autowired
factoryRobotExecutor = new FactoryRobotExecutor();
return factoryRobotExecutor.create(id, robot, executor, isActive, rank, host, port, host_user, host_password, nodeProxyPort, deviceudid, devicename, deviceport, isDevicelockunlock, executorProxyServiceHost, executorProxyServicePort, executorProxyHost, executorProxyPort, executorProxyType, description, usrCreated, dateCreated, usrModif, dateModif);
return factoryRobotExecutor.create(id, robot, executor, isActive, rank, host, port, host_user, host_password, nodeProxyPort, deviceudid, devicename, deviceport, isDevicelockunlock, executorProxyServiceHost, executorProxyServicePort, executorBrowserProxyHost, executorProxyPort, executorProxyType, description, usrCreated, dateCreated, usrModif, dateModif);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class RobotExecutor {
private String executorProxyType;
private String executorProxyServiceHost;
private Integer executorProxyServicePort;
private String executorProxyHost;
private String executorBrowserProxyHost;
private Integer executorProxyPort;
private String UsrCreated;
private Timestamp DateCreated;
Expand All @@ -64,7 +64,7 @@ public class RobotExecutor {
* Static PROXY TYPE String.
*/
public static final String PROXY_TYPE_NONE = "NONE"; // No Proxy. Browser will connect directly on Internet
public static final String PROXY_TYPE_MANUAL = "MANUAL"; // A Manual proxy is configured on executorProxyHost and executorProxyPort
public static final String PROXY_TYPE_MANUAL = "MANUAL"; // A Manual proxy is configured on executorBrowserProxyHost and executorProxyPort
public static final String PROXY_TYPE_NETWORKTRAFFIC = "NETWORKTRAFFIC"; // Proxy will be configured to Cerberus robot proxy component --> Network traffic features will be activated.

public Integer getNodeProxyPort() {
Expand Down Expand Up @@ -231,12 +231,12 @@ public void setExecutorProxyServicePort(Integer executorProxyServicePort) {
this.executorProxyServicePort = executorProxyServicePort;
}

public String getExecutorProxyHost() {
return executorProxyHost;
public String getExecutorBrowserProxyHost() {
return executorBrowserProxyHost;
}

public void setExecutorProxyHost(String executorProxyHost) {
this.executorProxyHost = executorProxyHost;
public void setExecutorBrowserProxyHost(String executorBrowserProxyHost) {
this.executorBrowserProxyHost = executorBrowserProxyHost;
}

public Integer getExecutorProxyPort() {
Expand Down Expand Up @@ -371,7 +371,7 @@ public boolean equals(Object obj) {
if ((this.executorProxyServicePort == null) ? (other.executorProxyServicePort != null) : !this.executorProxyServicePort.equals(other.executorProxyServicePort)) {
return false;
}
if ((this.executorProxyHost == null) ? (other.executorProxyHost != null) : !this.executorProxyHost.equals(other.executorProxyHost)) {
if ((this.executorBrowserProxyHost == null) ? (other.executorBrowserProxyHost != null) : !this.executorBrowserProxyHost.equals(other.executorBrowserProxyHost)) {
return false;
}
if ((this.executorProxyPort == null) ? (other.executorProxyPort != null) : !this.executorProxyPort.equals(other.executorProxyPort)) {
Expand Down Expand Up @@ -401,7 +401,7 @@ public JSONObject toJson(boolean secured) {
result.put("isDeviceLockUnlock", this.isDeviceLockUnlock());
result.put("executorProxyServiceHost", this.getExecutorProxyServiceHost());
result.put("executorProxyServicePort", this.getExecutorProxyServicePort());
result.put("executorProxyHost", this.getExecutorProxyHost());
result.put("executorBrowserProxyHost", this.getExecutorBrowserProxyHost());
result.put("executorProxyPort", this.getExecutorProxyPort());
result.put("executorProxyType", this.getExecutorProxyType());
result.put("executor", this.getExecutor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public interface IFactoryRobotExecutor {
* @param isDeviceLockUnlock
* @param executorProxyServiceHost
* @param executorProxyServicePort
* @param executorProxyHost
* @param executorBrowserProxyHost
* @param executorProxyPort
* @param deviceUdid
* @param UsrCreated
Expand All @@ -57,6 +57,6 @@ public interface IFactoryRobotExecutor {
*/
RobotExecutor create(Integer ID, String robot, String executor, boolean isActive,
Integer rank, String host, String port, String hostUser, String hostPassword, Integer nodeProxyPort, String deviceUdid,
String deviceName, Integer devicePort, boolean isDeviceLockUnlock, String executorProxyServiceHost, Integer executorProxyServicePort, String executorProxyHost, Integer executorProxyPort, String executorProxyType,
String deviceName, Integer devicePort, boolean isDeviceLockUnlock, String executorProxyServiceHost, Integer executorProxyServicePort, String executorBrowserProxyHost, Integer executorProxyPort, String executorProxyType,
String description, String UsrCreated, Timestamp DateCreated, String UsrModif, Timestamp DateModif);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class FactoryRobotExecutor implements IFactoryRobotExecutor {

@Override
public RobotExecutor create(Integer ID, String robot, String executor, boolean isActive, Integer rank, String host, String port, String hostUser, String hostPassword,
Integer nodeProxyPort, String deviceUdid, String deviceName, Integer devicePort, boolean isDeviceLockUnlock, String executorProxyServiceHost, Integer executorProxyServicePort, String executorProxyHost, Integer executorProxyPort, String executorProxyType, String description,
Integer nodeProxyPort, String deviceUdid, String deviceName, Integer devicePort, boolean isDeviceLockUnlock, String executorProxyServiceHost, Integer executorProxyServicePort, String executorBrowserProxyHost, Integer executorProxyPort, String executorProxyType, String description,
String UsrCreated, Timestamp DateCreated, String UsrModif, Timestamp DateModif) {
RobotExecutor newRobot = new RobotExecutor();
newRobot.setID(ID);
Expand All @@ -50,7 +50,7 @@ public RobotExecutor create(Integer ID, String robot, String executor, boolean i
newRobot.setIsDeviceLockUnlock(isDeviceLockUnlock);
newRobot.setExecutorProxyServiceHost(executorProxyServiceHost);
newRobot.setExecutorProxyServicePort(executorProxyServicePort);
newRobot.setExecutorProxyHost(executorProxyHost);
newRobot.setExecutorBrowserProxyHost(executorBrowserProxyHost);
newRobot.setExecutorProxyType(executorProxyType);
newRobot.setExecutorProxyPort(executorProxyPort);
newRobot.setDescription(description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,11 +798,11 @@ public ArrayList<String> getSqlDocumentation() {
b.append(",('robotexecutor','executorProxyServicePort','','fr','Port du service de proxy','Port d\\'écoute du service Cerberus robot-proxy.',NULL)");
b.append(",('robotexecutor','executorProxyServiceHost','','fa','میزبان سرویس پراکسی', 'میزبان سرویس پروکسی ربات Cerberus. اگر خالی باشد، میزبان مجری استفاده خواهد شد.',NULL)");
b.append(",('robotexecutor','executorProxyServicePort','','en','Proxy service port', 'Port of the robot-proxy service.',NULL)");
b.append(",('robotexecutor','executorProxyHost','','fr','Nom d\\'hote du proxy pour le navigateur', 'Nom d\\'hote qui sera donné au navigateur pour acceder au service de proxy. Si vide, le nom d\\'hote du service robot-proxy sera utilisé.',NULL)");
b.append(",('robotexecutor','executorBrowserProxyHost','','fr','Nom d\\'hote du proxy pour le navigateur', 'Nom d\\'hote qui sera donné au navigateur pour acceder au service de proxy. Si vide, le nom d\\'hote du service robot-proxy sera utilisé.',NULL)");
b.append(",('robotexecutor','executorProxyServicePort','','fa','درگاه سرویس پروکسی', 'درگاه سرویس ربات پروکسی.',NULL)");
b.append(",('robotexecutor','executorProxyHost','','en','Browser Proxy Host', 'Host that will be given to the browser in order to connect to the proxy service. If empty, the host of robot-proxy service will be used.',NULL)");
b.append(",('robotexecutor','executorBrowserProxyHost','','en','Browser Proxy Host', 'Host that will be given to the browser in order to connect to the proxy service. If empty, the host of robot-proxy service will be used.',NULL)");
b.append(",('robotexecutor','executorProxyPort','','fr','Port du proxy pour le navigateur','Port qui sera utilisé par le navigateur pour acceder au proxy. Si 0, il sera determiné aléatoirement.',NULL)");
b.append(",('robotexecutor','executorProxyHost','','fa','میزبان پروکسی مرورگر', 'میزبانی که برای اتصال به سرویس پروکسی به مرورگر داده می شود. اگر خالی باشد، میزبان سرویس ربات پروکسی استفاده خواهد شد.',NULL)");
b.append(",('robotexecutor','executorBrowserProxyHost','','fa','میزبان پروکسی مرورگر', 'میزبانی که برای اتصال به سرویس پروکسی به مرورگر داده می شود. اگر خالی باشد، میزبان سرویس ربات پروکسی استفاده خواهد شد.',NULL)");
b.append(",('robotexecutor','executorProxyPort','','en','Browser Proxy Port','Port that will be used by the browser in order to connect to the proxy service. If 0, port will be determined randomly.',NULL)");
b.append(",('robotexecutor','executorProxyPort','','fa','درگاه پروکسی مرورگر','درگاهی که مرورگر برای اتصال به سرویس پروکسی از آن استفاده می کند. اگر 0 باشد، پورت به صورت تصادفی تعیین می شود.',NULL)");
b.append(",('robotexecutor','executorProxyType','','fr','Type de Proxy', 'Activer / Désactiver l\\'utilisation du proxy. L\\'utilisation du proxy permet de collecter des statistique et de controler le trafic réseau engendré par le navigateur.',NULL)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,8 @@ private MutableCapabilities setCapabilityBrowser(MutableCapabilities capabilitie
// OperaOptions optionsOP = new OperaOptions();
// if (tCExecution.getRobotExecutorObj() != null && "Y".equals(tCExecution.getRobotExecutorObj().getExecutorProxyActive())) {
// Proxy proxy = new Proxy();
// proxy.setHttpProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());
// proxy.setSslProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());
// proxy.setHttpProxy(tCExecution.getRobotExecutorObj().getExecutorBrowserProxyHost() + ":" + tCExecution.getRemoteProxyPort());
// proxy.setSslProxy(tCExecution.getRobotExecutorObj().getExecutorBrowserProxyHost() + ":" + tCExecution.getRemoteProxyPort());
// optionsOP.setProxy(proxy);
// }
// optionsOP.setCapability("browser", "opera");
Expand All @@ -986,8 +986,8 @@ private MutableCapabilities setCapabilityBrowser(MutableCapabilities capabilitie
case "android":
// if (tCExecution.getRobotExecutorObj() != null && "Y".equals(tCExecution.getRobotExecutorObj().getExecutorProxyActive())) { #FIXME SELENIUM Might have been deleted in rebase
// Proxy proxy = new Proxy();
// proxy.setHttpProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());
// proxy.setSslProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());
// proxy.setHttpProxy(tCExecution.getRobotExecutorObj().getExecutorBrowserProxyHost() + ":" + tCExecution.getRemoteProxyPort());
// proxy.setSslProxy(tCExecution.getRobotExecutorObj().getExecutorBrowserProxyHost() + ":" + tCExecution.getRemoteProxyPort());
// }
// capabilities = DesiredCapabilities.android(); //#FIXME SELENIUM #APPIUM
break;
Expand Down Expand Up @@ -1029,18 +1029,18 @@ private Proxy getProxyFromExecutor(RobotExecutor executor, Integer remoteProxyPo

if (executor != null && RobotExecutor.PROXY_TYPE_NETWORKTRAFFIC.equals(executor.getExecutorProxyType())) {
Proxy proxy = new Proxy();
proxy.setHttpProxy(executor.getExecutorProxyHost() + ":" + remoteProxyPort);
proxy.setSslProxy(executor.getExecutorProxyHost() + ":" + remoteProxyPort);
proxy.setHttpProxy(executor.getExecutorBrowserProxyHost() + ":" + remoteProxyPort);
proxy.setSslProxy(executor.getExecutorBrowserProxyHost() + ":" + remoteProxyPort);
proxy.setNoProxy("");
proxy.setProxyType(Proxy.ProxyType.MANUAL);
LOG.debug("Setting Chrome proxy with Cerberus Robot Proxy Service to : {}", proxy);
return proxy;
}
if (executor != null && RobotExecutor.PROXY_TYPE_MANUAL.equals(executor.getExecutorProxyType())
&& executor.getExecutorProxyPort() != 0 && StringUtil.isNotEmptyOrNull(executor.getExecutorProxyHost())) {
&& executor.getExecutorProxyPort() != 0 && StringUtil.isNotEmptyOrNull(executor.getExecutorBrowserProxyHost())) {
Proxy proxy = new Proxy();
proxy.setHttpProxy(executor.getExecutorProxyHost() + ":" + executor.getExecutorProxyPort());
proxy.setSslProxy(executor.getExecutorProxyHost() + ":" + executor.getExecutorProxyPort());
proxy.setHttpProxy(executor.getExecutorBrowserProxyHost() + ":" + executor.getExecutorProxyPort());
proxy.setSslProxy(executor.getExecutorBrowserProxyHost() + ":" + executor.getExecutorProxyPort());
proxy.setNoProxy("");
proxy.setProxyType(Proxy.ProxyType.MANUAL);
LOG.debug("Setting Chrome proxy to : {}", proxy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,7 @@ private MessageEvent doActionSetNetworkTrafficContent(TestCaseExecution exe, Tes
MessageEvent message;
try {
// Check that robot has executor activated
if (!RobotExecutor.PROXY_TYPE_NETWORKTRAFFIC.equalsIgnoreCase(exe.getRobotExecutorObj().getExecutorProxyType()) || StringUtil.isEmptyOrNull(exe.getRobotExecutorObj().getExecutorProxyHost())) {
if (!RobotExecutor.PROXY_TYPE_NETWORKTRAFFIC.equalsIgnoreCase(exe.getRobotExecutorObj().getExecutorProxyType()) || StringUtil.isEmptyOrNull(exe.getRobotExecutorObj().getExecutorBrowserProxyHost())) {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SETNETWORKTRAFFICCONTENT_ROBOTEXECUTORPROXYNOTACTIVATED);
message.setDescription(message.getDescription().replace("%ROBOT%", exe.getRobotExecutorObj().getRobot()).replace("%EXECUTOR%", exe.getRobotExecutorObj().getExecutor()));
return message;
Expand Down Expand Up @@ -2003,7 +2003,7 @@ private MessageEvent doActionIndexNetworkTraffic(TestCaseExecution exe, TestCase
MessageEvent message;
try {
// Check that robot has executor activated
if (!RobotExecutor.PROXY_TYPE_NETWORKTRAFFIC.equalsIgnoreCase(exe.getRobotExecutorObj().getExecutorProxyType()) || StringUtil.isEmptyOrNull(exe.getRobotExecutorObj().getExecutorProxyHost())) {
if (!RobotExecutor.PROXY_TYPE_NETWORKTRAFFIC.equalsIgnoreCase(exe.getRobotExecutorObj().getExecutorProxyType()) || StringUtil.isEmptyOrNull(exe.getRobotExecutorObj().getExecutorBrowserProxyHost())) {
message = new MessageEvent(MessageEventEnum.ACTION_FAILED_INDEXNETWORKTRAFFIC_ROBOTEXECUTORPROXYNOTACTIVATED);
message.setDescription(message.getDescription().replace("%ROBOT%", exe.getRobotExecutorObj().getRobot()).replace("%EXECUTOR%", exe.getRobotExecutorObj().getExecutor()));
return message;
Expand Down
Loading

0 comments on commit 7532435

Please sign in to comment.