From ced2b82f8e6d5e7759d7669b2083f30e59637ecc Mon Sep 17 00:00:00 2001 From: Folker Bernitt Date: Mon, 24 Nov 2014 18:00:16 +0100 Subject: Added capability to read credentials from stdin. - See issue https://github.com/pixelated-project/pixelated-dispatcher/issues/40 --- service/test/unit/runserver_test.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'service/test/unit/runserver_test.py') diff --git a/service/test/unit/runserver_test.py b/service/test/unit/runserver_test.py index 51ee899c..801a60bf 100644 --- a/service/test/unit/runserver_test.py +++ b/service/test/unit/runserver_test.py @@ -59,6 +59,22 @@ class RunserverTest(unittest.TestCase): sys.argv = ['tmp/does_not_exist', '--dispatcher', fifo_path] pixelated.runserver.setup() + def test_that_organization_switch_reads_the_credentials_from_stdin(self): + data = json.dumps({'leap_provider_hostname': 'test_provider', 'user': 'test_user', 'password': 'test_password'}) + orig_stdin = sys.stdin + try: + sys.stdin = Mock() + when(sys.stdin).read().thenReturn(data) + + sys.argv = ['tmp/does_not_exist', '--dispatcher-stdin'] + pixelated.runserver.setup() + + self.assertEquals('test_provider', pixelated.runserver.app.config['LEAP_SERVER_NAME']) + self.assertEquals('test_user', pixelated.runserver.app.config['LEAP_USERNAME']) + self.assertEquals('test_password', pixelated.runserver.app.config['LEAP_PASSWORD']) + finally: + sys.stdin = orig_stdin + def test_start_services_provides_port(self): bind_address = '127.0.0.1' bind_port = 12345 -- cgit v1.2.3