Skip to content

Commit ca0f448

Browse files
committed
Fix issue with using localhost for TestingBot tunnel
Fixes: #216
1 parent d8766b3 commit ca0f448

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

pytest_selenium/drivers/testingbot.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
import pytest
6-
7-
from py.xml import html
86
import requests
97

8+
from hashlib import md5
9+
from py.xml import html
1010
from pytest_selenium.drivers.cloud import Provider
1111

1212
HOST = "hub.testingbot.com"
@@ -29,7 +29,9 @@ def auth(self):
2929

3030
@property
3131
def executor(self):
32-
return "https://{0.host}:{0.port}/wd/hub".format(self)
32+
return "{1}://{0.host}:{0.port}/wd/hub".format(
33+
self, "http" if self.host == "localhost" else "https"
34+
)
3335

3436
@property
3537
def key(self):
@@ -118,8 +120,6 @@ def _video_html(video_url, session):
118120

119121

120122
def get_auth_url(url, provider, session_id):
121-
from hashlib import md5
122-
123123
key = "{0.key}:{0.secret}:{1}".format(provider, session_id)
124124
token = md5(key.encode("utf-8")).hexdigest()
125125
return "{}?auth={}".format(url, token)

testing/test_edge.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
import pytest
6+
import sys
67

78
pytestmark = pytest.mark.nondestructive
89

910

11+
@pytest.mark.skipif(sys.platform != "win32", reason="Edge only runs on Windows")
1012
@pytest.mark.edge
1113
def test_launch(testdir, httpserver):
1214
httpserver.serve_content(content="<h1>Success!</h1>")

testing/test_testingbot.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
from functools import partial
65
import os
7-
86
import pytest
97

8+
from functools import partial
9+
from pytest_selenium.drivers.testingbot import TestingBot, HOST, PORT
10+
1011
pytestmark = [pytest.mark.skip_selenium, pytest.mark.nondestructive]
1112

1213

@@ -88,3 +89,11 @@ def test_invalid_host(failure, monkeypatch, tmpdir):
8889
"Name or service not known",
8990
]
9091
assert any(message in out for message in messages)
92+
93+
94+
@pytest.mark.parametrize(
95+
("protocol", "host", "port"), [("http", "localhost", "4445"), ("https", HOST, PORT)]
96+
)
97+
def test_executor_url(protocol, host, port):
98+
tb = TestingBot(host, port)
99+
assert tb.executor == "{}://{}:{}/wd/hub".format(protocol, host, port)

0 commit comments

Comments
 (0)