Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public void Connect()
string proxyUri = new ProxyFinder().GetProxy(string.Format("http://{0}:{1}", this.host, this.port), this.host);
if (proxyUri != null)
{
logger.Info("Using proxy in DriverWebSocketClient: '{0}'.", proxyUri);
wsClient.SetProxy(proxyUri, null, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@ You should have received a copy of the GNU General Public License
#if !UNITY_EDITOR && UNITY_ANDROID
using System;
using UnityEngine;
using AltTester.AltTesterSDK.Driver.Logging;

namespace AltTester.AltTesterSDK.Driver.Proxy
{
public class AndroidProxyFinder : IProxyFinder
{
private static readonly NLog.Logger logger = DriverLogManager.Instance.GetCurrentClassLogger();

public string GetProxy(string uri, string host)
{
logger.Info("AndroidProxyFinder.GetProxy called with uri: {0}, host: {1}", uri, host);
return CallJavaGetProxy(uri);
}

private string CallJavaGetProxy(string uri)
{
logger.Info("Calling Java method to get proxy for uri in AndroidProxyFinder: {0}", uri);
using (var JavaClass = new AndroidJavaClass("com.alttester.utils.AltProxyFinder")) {
return JavaClass.CallStatic<string>("getProxy", uri);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ You should have received a copy of the GNU General Public License
*/

using System;
using AltWebSocketSharp;
using AltTester.AltTesterSDK.Driver.Logging;

namespace AltTester.AltTesterSDK.Driver.Proxy
{
public class DotnetProxyFinder : IProxyFinder
{
private static readonly NLog.Logger logger = DriverLogManager.Instance.GetCurrentClassLogger();
public string GetProxy(string uri, string host)
{
logger.Info("DotnetProxyFinder.GetProxy called with uri: {0}, host: {1}", uri, host);
var Proxy = System.Net.WebRequest.GetSystemWebProxy() as System.Net.WebProxy;
if (Proxy != null && Proxy.Address != null)
{
Expand All @@ -33,7 +37,7 @@ public string GetProxy(string uri, string host)
return proxyUri;
}
}

logger.Info("No proxy found for in DotnetProxyFinder uri: {0} and host: {1}", uri, host);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ You should have received a copy of the GNU General Public License

using System;
using System.Linq;
using AltTester.AltTesterSDK.Driver.Logging;

namespace AltTester.AltTesterSDK.Driver.Proxy
{
public class EnvironmentProxyFinder : IProxyFinder
{
private static readonly NLog.Logger logger = DriverLogManager.Instance.GetCurrentClassLogger();
public string GetProxy(string uri, string host)
{
// TODO: Check HTTPS_PROXY if we use wss
Expand All @@ -38,15 +40,17 @@ public string GetProxy(string uri, string host)

if (!string.IsNullOrEmpty(exceptions))
{
logger.Info("NO_PROXY environment variable found in EnvironmentProxyFinder: {0}", exceptions);
var exceptionsList = exceptions.Split(';').ToList<string>();

if (exceptionsList.Contains(proxyUrl))
{
logger.Info("Proxy {0} is in NO_PROXY list, skipping in EnvironmentProxyFinder.", proxyUrl);
return null;
}
}
}

logger.Info("Using proxy in EnvironmentProxyFinder: {0} for uri: {1} and host: {2}", proxyUrl, uri, host);
return proxyUrl;
}

Expand Down
6 changes: 5 additions & 1 deletion Assets/AltTester/Runtime/AltDriver/Proxy/IOSProxyFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
using System.Runtime.InteropServices;
using System.Globalization;
using UnityEngine;
using AltTester.AltTesterSDK.Driver.Logging;

namespace AltTester.AltTesterSDK.Driver.Proxy
{
Expand All @@ -28,15 +29,18 @@ public class IOSProxyFinder : IProxyFinder
[DllImport("__Internal")]
private static extern string _getProxy(string uri, string host);

private static readonly NLog.Logger logger = DriverLogManager.Instance.GetCurrentClassLogger();

public string GetProxy(string uri, string host)
{
var result = _getProxy(uri, host);

if (string.IsNullOrEmpty(result))
{
logger.Info("No proxy found in IOSProxyFinder for uri: {0} and host: {1}", uri, host);
return null;
}

logger.Info("Using proxy in IOSProxyFinder: {0} for uri: {1} and host: {2}", result, uri, host);
return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation
import JavaScriptCore

@objc public class AltProxyFinder: NSObject {

@objc public static let shared = AltProxyFinder()

@objc public func swiftGetProxy(_ destinationUrl: String, destinationHost: String) -> String {
Expand Down Expand Up @@ -31,8 +32,10 @@ import JavaScriptCore
// Workaround for BrowserStack with Forced Local mode.
// An issue arises where, instead of receiving the expected PAC file, an error page is returned,
// parsing which would lead to a crash in the application.
NSLog("PAC content")
pacContent = pacContent.trimmingCharacters(in: .whitespacesAndNewlines)
if (pacContent.starts(with:"<!DOCTYPE html>")) {
NSLog("Received an error page instead of PAC file. Please check the PAC URL: \(pacUrl)")
return
}

Expand All @@ -48,37 +51,40 @@ import JavaScriptCore
if (host == "null" || port == 0) {
return
}

NSLog("PAC Proxy Host: \(host), Port: \(port)")
proxyUrl = "http://" + host + ":" + String(port)
}
}
}
} else if let error = error {
// Handle Error
NSLog("Error fetching PAC file: \(error.localizedDescription)")
}
}

task.resume()
semaphore.wait()

NSLog("PAC Proxy URL: \(proxyUrl)")
return proxyUrl
}

if let httpSEnable = systemProxySettings["HTTPSEnable"] as? Int, httpSEnable == 1,
destinationUrl.starts(with: "https") {
if let host = systemProxySettings["HTTPSProxy"] as? String,
let port = systemProxySettings["HTTPSPort"] as? Int {
NSLog("HTTPS Proxy Host in AltProxyFinder: \(host), Port: \(port)")
return "https://\(host):\(port)"
}
}

if let httpEnable = systemProxySettings["HTTPEnable"] as? Int, httpEnable == 1 {
if let host = systemProxySettings["HTTPProxy"] as? String,
let port = systemProxySettings["HTTPPort"] as? Int {
NSLog("HTTP Proxy Host in AltProxyFinder: \(host), Port: \(port)")
return "http://\(host):\(port)"
}
}

NSLog("No proxy found for the given URL in AltProxyFinder: \(destinationUrl)")
return ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
char* _getProxy(const char* uri, const char* host)
{
NSString *returnString = [[AltProxyFinder shared] swiftGetProxy:[NSString stringWithUTF8String:uri] destinationHost:[NSString stringWithUTF8String:host]];
NSLog(@"_getProxy: uri: %s, host: %s, returnString: %@", uri, host, returnString);
return cStringCopy([returnString UTF8String]);
}
}
9 changes: 7 additions & 2 deletions Assets/AltTester/Runtime/AltDriver/Proxy/ProxyFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ You should have received a copy of the GNU General Public License
*/

using System;
using AltTester.AltTesterSDK.Driver.Logging;

namespace AltTester.AltTesterSDK.Driver.Proxy
{
public class ProxyFinder : IProxyFinder
{
private static readonly NLog.Logger logger = DriverLogManager.Instance.GetCurrentClassLogger();
public string GetProxy(string uri, string host)
{
#if !UNITY_EDITOR && UNITY_WEBGL
Expand All @@ -39,6 +41,7 @@ public string GetProxy(string uri, string host)
}
catch (Exception)
{
logger.Info("AndroidProxyFinder in ProxyFinder failed to get proxy for uri: {0}, host: {1}", uri, host);
}
#endif

Expand All @@ -50,9 +53,9 @@ public string GetProxy(string uri, string host)
}
catch (Exception)
{
logger.Info("IOSProxyFinder in ProxyFinder failed to get proxy for uri: {0}, host: {1}", uri, host);
}
#endif

if (ProxyUri == null)
{
try
Expand All @@ -62,6 +65,7 @@ public string GetProxy(string uri, string host)
}
catch (Exception)
{
logger.Info("EnvironmentProxyFinder in ProxyFinder failed to get proxy for uri: {0}, host: {1}", uri, host);
}
}

Expand All @@ -74,9 +78,10 @@ public string GetProxy(string uri, string host)
}
catch (Exception)
{
logger.Info("DotnetProxyFinder in ProxyFinder failed to get proxy for uri: {0}, host: {1}", uri, host);
}
}

logger.Info("Using proxy in ProxyFinder: {0} for uri: {1} and host: {2}", ProxyUri, uri, host);
return ProxyUri;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace AltTester.AltTesterUnitySDK.Communication
public class RuntimeWebSocketClient : IRuntimeWebSocketClient
{
private ClientWebSocket wsClient;

private static readonly NLog.Logger logger = ServerLogManager.Instance.GetCurrentClassLogger();
private readonly string host;
private readonly int port;
private readonly string appName;
Expand Down Expand Up @@ -69,6 +69,7 @@ public RuntimeWebSocketClient(string host, int port, string path, string appName
string proxyUri = new ProxyFinder().GetProxy(string.Format("http://{0}:{1}", host, port), host);
if (proxyUri != null)
{
logger.Info("Using proxy in RuntimeWebSocketClient: {0} for uri: {1} and host: {2}", proxyUri, uri, host);
wsClient.SetProxy(proxyUri, null, null);
}

Expand Down
1 change: 1 addition & 0 deletions Assets/AltTester/Runtime/UI/AltDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ public static async Task<HttpResponseMessage> Get(string url)
using (var client = new HttpClient())
{
client.Timeout = TimeSpan.FromMilliseconds(50000);
logger.Info("Sending GET from AltDialog request to: " + url);
return await client.GetAsync(url);
}
}
Expand Down
3 changes: 2 additions & 1 deletion Bindings~/python/tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def alt_driver(request, appium_driver, worker_id, current_device):
app_name=get_app_name(),
platform=platform,
platform_version=current_device["os_version"].split(".")[0],
timeout=180
timeout=180,
enable_logging=True
)
if alt_driver is None:
raise RuntimeError(
Expand Down