Skip to content

Fix issue with using localhost for TestingBot tunnel #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 8, 2019
Merged
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
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)