Skip to content

Commit

Permalink
Fix test for user profile in sd-app
Browse files Browse the repository at this point in the history
QUBES_GPG_DOMAIN will be conditionally set based on the running VM in order to support template consolidation. See freedomofpress/securedrop-client#1141
  • Loading branch information
emkll committed Oct 14, 2020
1 parent 56c86b1 commit f65b62c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ def setUp(self):

def test_decrypt_sd_user_profile(self):
contents = self._get_file_contents("/etc/profile.d/sd-app-qubes-gpg-domain.sh")
expected_content = 'export QUBES_GPG_DOMAIN="sd-gpg"\n'
expected_content = 'if [ "$(qubesdb-read /name)" = "sd-app" ]; then export QUBES_GPG_DOMAIN="sd-gpg"; fi\n' # noqa: E501
self.assertEqual(contents, expected_content)

def test_gpg_env_var(self):
cmd = 'echo "$QUBES_GPG_DOMAIN"'
contents = self._run(cmd)
expected_content = "sd-gpg"
self.assertEqual(contents, expected_content)

def test_open_in_dvm_desktop(self):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_log_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def setUp(self):
def test_sd_log_package_installed(self):
self.assertTrue(self._package_is_installed("securedrop-log"))

def test_gpg_env_var_absent(self):
cmd = 'echo "$QUBES_GPG_DOMAIN"'
contents = self._run(cmd)
expected_content = ""
self.assertEqual(contents, expected_content)

def test_sd_log_redis_is_installed(self):
self.assertTrue(self._package_is_installed("redis"))
self.assertTrue(self._package_is_installed("redis-server"))
Expand Down
6 changes: 6 additions & 0 deletions tests/test_proxy_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def test_mime_types(self):
actual_app = self._run("xdg-mime query default {}".format(mime_type))
self.assertEqual(actual_app, expected_app)

def test_gpg_env_var_absent(self):
cmd = 'echo "$QUBES_GPG_DOMAIN"'
contents = self._run(cmd)
expected_content = ""
self.assertEqual(contents, expected_content)


def load_tests(loader, tests, pattern):
suite = unittest.TestLoader().loadTestsFromTestCase(SD_Proxy_Tests)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_sd_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def test_open_in_dvm_desktop(self):
for line in expected_contents:
self.assertTrue(line in contents)

def test_gpg_env_var_absent(self):
cmd = 'echo "$QUBES_GPG_DOMAIN"'
contents = self._run(cmd)
expected_content = ""
self.assertEqual(contents, expected_content)


def load_tests(loader, tests, pattern):
suite = unittest.TestLoader().loadTestsFromTestCase(SD_Devices_Tests)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_sd_whonix.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def test_whonix_torrc(self):
"Whonix GW torrc contains duplicate %include lines",
)

def test_gpg_env_var_absent(self):
cmd = 'echo "$QUBES_GPG_DOMAIN"'
contents = self._run(cmd)
expected_content = ""
self.assertEqual(contents, expected_content)


def load_tests(loader, tests, pattern):
suite = unittest.TestLoader().loadTestsFromTestCase(SD_Whonix_Tests)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def test_mime_types(self):
actual_app = self._run("xdg-mime query default {}".format(mime_type))
self.assertEqual(actual_app, expected_app)

def test_gpg_env_var_absent(self):
cmd = 'echo "$QUBES_GPG_DOMAIN"'
contents = self._run(cmd)
expected_content = ""
self.assertEqual(contents, expected_content)


def load_tests(loader, tests, pattern):
suite = unittest.TestLoader().loadTestsFromTestCase(SD_Viewer_Tests)
Expand Down

0 comments on commit f65b62c

Please sign in to comment.