Skip to content

Commit

Permalink
Fix issue with using localhost for TestingBot tunnel (#217)
Browse files Browse the repository at this point in the history
* Fix issue with using localhost for TestingBot tunnel

Fixes: #216
  • Loading branch information
BeyondEvil committed Feb 8, 2019
1 parent d8766b3 commit fe25750
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Release Notes
-------------------

* ``pytest-selenium`` now requires pytest 3.6 or later.
* Fixed `issue <https://github.com/pytest-dev/pytest-selenium/issues/216>`_ with TestingBot local tunnel.

1.15.1 (2019-01-07)
-------------------
Expand Down
10 changes: 5 additions & 5 deletions pytest_selenium/drivers/testingbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import pytest

from py.xml import html
import requests

from hashlib import md5
from py.xml import html
from pytest_selenium.drivers.cloud import Provider

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

@property
def executor(self):
return "https://{0.host}:{0.port}/wd/hub".format(self)
return "{1}://{0.host}:{0.port}/wd/hub".format(
self, "http" if self.host == "localhost" else "https"
)

@property
def key(self):
Expand Down Expand Up @@ -118,8 +120,6 @@ def _video_html(video_url, session):


def get_auth_url(url, provider, session_id):
from hashlib import md5

key = "{0.key}:{0.secret}:{1}".format(provider, session_id)
token = md5(key.encode("utf-8")).hexdigest()
return "{}?auth={}".format(url, token)
2 changes: 2 additions & 0 deletions testing/test_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import pytest
import sys

pytestmark = pytest.mark.nondestructive


@pytest.mark.skipif(sys.platform != "win32", reason="Edge only runs on Windows")
@pytest.mark.edge
def test_launch(testdir, httpserver):
httpserver.serve_content(content="<h1>Success!</h1>")
Expand Down
13 changes: 11 additions & 2 deletions testing/test_testingbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from functools import partial
import os

import pytest

from functools import partial
from pytest_selenium.drivers.testingbot import TestingBot, HOST, PORT

pytestmark = [pytest.mark.skip_selenium, pytest.mark.nondestructive]


Expand Down Expand Up @@ -88,3 +89,11 @@ def test_invalid_host(failure, monkeypatch, tmpdir):
"Name or service not known",
]
assert any(message in out for message in messages)


@pytest.mark.parametrize(
("protocol", "host", "port"), [("http", "localhost", "4445"), ("https", HOST, PORT)]
)
def test_executor_url(protocol, host, port):
tb = TestingBot(host, port)
assert tb.executor == "{}://{}:{}/wd/hub".format(protocol, host, port)

0 comments on commit fe25750

Please sign in to comment.