From 92e39162b05ac6d83bb043b61393a6ce59b75ea2 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Tue, 21 Feb 2017 11:24:01 +0100 Subject: [PATCH] Fix test_submit_build_auth_error test --- tests/test_views/client_secrets.json | 13 +++++++++++++ tests/test_views/test_views.py | 23 +++++++++++++---------- 2 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 tests/test_views/client_secrets.json diff --git a/tests/test_views/client_secrets.json b/tests/test_views/client_secrets.json new file mode 100644 index 00000000..8647ed86 --- /dev/null +++ b/tests/test_views/client_secrets.json @@ -0,0 +1,13 @@ +{ + "web": { + "auth_uri": "https://id.stg.fedoraproject.org/openidc/Authorization", + "client_id": "mbs-authorizer", + "client_secret": "notsecret", + "redirect_uris": [ + "http://localhost:13747/" + ], + "token_uri": "https://id.stg.fedoraproject.org/openidc/Token", + "token_introspection_uri": "https://id.stg.fedoraproject.org/openidc/TokenInfo", + "userinfo_uri": "https://id.stg.fedoraproject.org/openidc/UserInfo" + } +} diff --git a/tests/test_views/test_views.py b/tests/test_views/test_views.py index 2970e214..53a741b2 100644 --- a/tests/test_views/test_views.py +++ b/tests/test_views/test_views.py @@ -264,16 +264,19 @@ class TestViews(unittest.TestCase): self.assertEquals(data['state_name'], 'wait') def test_submit_build_auth_error(self): - rv = self.client.post('/module-build-service/1/module-builds/', data=json.dumps( - {'scmurl': 'git://pkgs.stg.fedoraproject.org/modules/' - 'testmodule.git?#48931b90de214d9d13feefbd35246a81b6cb8d49'})) - data = json.loads(rv.data) - self.assertEquals( - data['message'], - "No 'authorization' header found." - ) - self.assertEquals(data['status'], 401) - self.assertEquals(data['error'], 'Unauthorized') + base_dir = path.abspath(path.dirname(__file__)) + client_secrets = path.join(base_dir, "client_secrets.json") + with patch.dict('module_build_service.app.config', {'OIDC_CLIENT_SECRETS': client_secrets}): + rv = self.client.post('/module-build-service/1/module-builds/', data=json.dumps( + {'scmurl': 'git://pkgs.stg.fedoraproject.org/modules/' + 'testmodule.git?#48931b90de214d9d13feefbd35246a81b6cb8d49'})) + data = json.loads(rv.data) + self.assertEquals( + data['message'], + "No 'authorization' header found." + ) + self.assertEquals(data['status'], 401) + self.assertEquals(data['error'], 'Unauthorized') @patch('module_build_service.auth.get_user', return_value=user) def test_submit_build_scm_url_error(self, mocked_get_user):