From 3dc08cb9e6222486dcaadd50e61cad26d3200289 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Wed, 12 Aug 2015 16:41:38 -0400 Subject: [PATCH] 6934: Move integration tests into separate dir. Now, "python setup.py --test-suite integration_tests" will run integration tests, and "python setup.py" won't -- regardless of whether you are root, and what your pam config looks like. --- sdk/pam/Dockerfile | 2 +- sdk/pam/integration_tests/__init__.py | 0 sdk/pam/integration_tests/test_pam.py | 26 +++++++++++++++++++++++++ sdk/pam/tests/test_integration.py | 28 --------------------------- 4 files changed, 27 insertions(+), 29 deletions(-) create mode 100644 sdk/pam/integration_tests/__init__.py create mode 100644 sdk/pam/integration_tests/test_pam.py delete mode 100644 sdk/pam/tests/test_integration.py diff --git a/sdk/pam/Dockerfile b/sdk/pam/Dockerfile index 24b50ab4e8..5cee5cc754 100644 --- a/sdk/pam/Dockerfile +++ b/sdk/pam/Dockerfile @@ -44,7 +44,7 @@ RUN useradd -ms /bin/bash active # Test with python (SIGSEGV during tests) #ADD . /pam #WORKDIR /pam -#CMD rsyslogd & tail -F /var/log/auth.log & python setup.py test +#CMD rsyslogd & tail -F /var/log/auth.log & python setup.py test --test-suite integration_tests # Test with perl (SIGSEGV when program exits) RUN apt-get install -qy libauthen-pam-perl diff --git a/sdk/pam/integration_tests/__init__.py b/sdk/pam/integration_tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/sdk/pam/integration_tests/test_pam.py b/sdk/pam/integration_tests/test_pam.py new file mode 100644 index 0000000000..cfc915c890 --- /dev/null +++ b/sdk/pam/integration_tests/test_pam.py @@ -0,0 +1,26 @@ +"""These tests assume we are running (in a docker container) with +arvados_pam configured and a test API server running. +""" +import pam +import unittest + +# From services/api/test/fixtures/api_client_authorizations.yml +# because that file is not available during integration tests: +ACTIVE_TOKEN = '3kg6k6lzmp9kj5cpkcoxie963cmvjahbt2fod9zru30k1jqdmi' +SPECTATOR_TOKEN = 'zw2f4gwx8hw8cjre7yp6v1zylhrhn3m5gvjq73rtpwhmknrybu' + +class IntegrationTest(unittest.TestCase): + def setUp(self): + self.p = pam.pam() + + def test_allow(self): + self.assertTrue(self.p.authenticate('active', ACTIVE_TOKEN, service='login')) + + def test_deny_bad_token(self): + self.assertFalse(self.p.authenticate('active', 'thisisaverybadtoken', service='login')) + + def test_deny_empty_token(self): + self.assertFalse(self.p.authenticate('active', '', service='login')) + + def test_deny_permission(self): + self.assertFalse(self.p.authenticate('spectator', SPECTATOR_TOKEN, service='login')) diff --git a/sdk/pam/tests/test_integration.py b/sdk/pam/tests/test_integration.py deleted file mode 100644 index 53ef0eacbf..0000000000 --- a/sdk/pam/tests/test_integration.py +++ /dev/null @@ -1,28 +0,0 @@ -import os -if os.path.exists('/usr/share/pam-configs/arvados') and os.getuid() == 0: - """These tests assume we are running (in a docker container) with - arvados_pam configured and a test API server running. - """ - import pam - import unittest - - # From services/api/test/fixtures/api_client_authorizations.yml - # because that file is not available during integration tests: - ACTIVE_TOKEN = '3kg6k6lzmp9kj5cpkcoxie963cmvjahbt2fod9zru30k1jqdmi' - SPECTATOR_TOKEN = 'zw2f4gwx8hw8cjre7yp6v1zylhrhn3m5gvjq73rtpwhmknrybu' - - class IntegrationTest(unittest.TestCase): - def setUp(self): - self.p = pam.pam() - - def test_allow(self): - self.assertTrue(self.p.authenticate('active', ACTIVE_TOKEN, service='login')) - - def test_deny_bad_token(self): - self.assertFalse(self.p.authenticate('active', 'thisisaverybadtoken', service='login')) - - def test_deny_empty_token(self): - self.assertFalse(self.p.authenticate('active', '', service='login')) - - def test_deny_permission(self): - self.assertFalse(self.p.authenticate('spectator', SPECTATOR_TOKEN, service='login')) -- 2.30.2