From 9479b65d25b2665a5c34493730f0e711257293f2 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 12 Jan 2016 23:21:52 +0100 Subject: [PATCH] bdd: Add first SSL test. --- tests/integration/features/prompts.feature | 9 +++++++++ tests/integration/features/test_prompts.py | 12 ++++++++++++ tests/integration/quteprocess.py | 6 +++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/tests/integration/features/prompts.feature b/tests/integration/features/prompts.feature index 5b103667a..b6a69f536 100644 --- a/tests/integration/features/prompts.feature +++ b/tests/integration/features/prompts.feature @@ -62,3 +62,12 @@ Feature: Prompts And I run :hint And I run :follow-hint a Then the javascript message "Prompt reply: null" should be logged + + # SSL + + Scenario: SSL error with ssl-strict = false + When I set network -> ssl-strict to false + And I load a SSL page + And I wait until the SSL page finished loading + Then the error "SSL error: The certificate is self-signed, and untrusted" should be shown + And the page should contain the plaintext "Hello World via SSL!" diff --git a/tests/integration/features/test_prompts.py b/tests/integration/features/test_prompts.py index 3cfef48c8..dbb38d1e5 100644 --- a/tests/integration/features/test_prompts.py +++ b/tests/integration/features/test_prompts.py @@ -21,6 +21,18 @@ import pytest_bdd as bdd bdd.scenarios('prompts.feature') +@bdd.when("I load a SSL page") +def load_ssl_page(quteproc, ssl_server): + quteproc.open_path('/', port=ssl_server.port, https=True) + # We don't call wait_for_load_finished here as we can get an SSL question. + + +@bdd.when("I wait until the SSL page finished loading") +def load_ssl_page(quteproc, ssl_server): + quteproc.wait_for_load_finished('/', port=ssl_server.port, https=True, + load_status='warn') + + @bdd.when("I click the button") def click_button(quteproc): quteproc.send_cmd(':hint') diff --git a/tests/integration/quteprocess.py b/tests/integration/quteprocess.py index 011a69cec..469f32b8a 100644 --- a/tests/integration/quteprocess.py +++ b/tests/integration/quteprocess.py @@ -289,7 +289,7 @@ class QuteProc(testprocess.Process): line.expected = True def wait_for_load_finished(self, path, *, port=None, https=False, - timeout=None): + timeout=None, load_status='success'): """Wait until any tab has finished loading.""" if timeout is None: if 'CI' in os.environ: @@ -303,9 +303,9 @@ class QuteProc(testprocess.Process): url = utils.elide(QUrl(url).toDisplayString(QUrl.EncodeUnicode), 100) pattern = re.compile( r"(load status for : LoadStatus\.success|fetch: " + r"tab_id=\d+ url='{url}'>: LoadStatus\.{load_status}|fetch: " r"PyQt5\.QtCore\.QUrl\('{url}'\) -> .*)".format( - url=re.escape(url))) + load_status=re.escape(load_status), url=re.escape(url))) self.wait_for(message=pattern, timeout=timeout) def get_session(self):