From 794d3bd2fdefba3d7807b2345628b6032ba38877 Mon Sep 17 00:00:00 2001 From: Kevin O'Gorman Date: Tue, 18 Jun 2019 15:04:23 -0700 Subject: [PATCH] add functional test for /metadata endpoint --- securedrop/tests/functional/source_navigation_steps.py | 8 ++++++++ securedrop/tests/functional/test_source_metadata.py | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 securedrop/tests/functional/test_source_metadata.py diff --git a/securedrop/tests/functional/source_navigation_steps.py b/securedrop/tests/functional/source_navigation_steps.py index 96677d8aef..e921beecb4 100644 --- a/securedrop/tests/functional/source_navigation_steps.py +++ b/securedrop/tests/functional/source_navigation_steps.py @@ -1,5 +1,6 @@ import tempfile import time +import json from selenium.webdriver.common.action_chains import ActionChains @@ -22,6 +23,13 @@ def _source_visits_source_homepage(self): self.driver.get(self.source_location) assert self._is_on_source_homepage() + def _source_checks_instance_metadata(self): + self.driver.get(self.source_location + "/metadata") + j = json.loads(self.driver.find_element_by_tag_name("body").text) + assert j["server_os"] == "16.04" + assert j["sd_version"] == self.source_app.jinja_env.globals['version'] + assert j["gpg_fpr"] != "" + def _source_clicks_submit_documents_on_homepage(self): # First move the cursor to a known position in case it happens to # be hovering over one of the buttons we are testing below. diff --git a/securedrop/tests/functional/test_source_metadata.py b/securedrop/tests/functional/test_source_metadata.py new file mode 100644 index 0000000000..8a14791f66 --- /dev/null +++ b/securedrop/tests/functional/test_source_metadata.py @@ -0,0 +1,10 @@ +from . import source_navigation_steps +from . import functional_test + + +class TestInstanceMetadata( + functional_test.FunctionalTest, + source_navigation_steps.SourceNavigationStepsMixin): + + def test_instance_metadata(self): + self._source_checks_instance_metadata()