From 9de85caeb2d3396a41938e6c9b4facc1d385eb06 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 9 May 2024 09:07:54 +0200 Subject: [PATCH] Fix OAI POST --- app/__init__.py | 3 ++- app/tests/test_app.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/__init__.py b/app/__init__.py index 6e2175c10..68e8330c2 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -66,7 +66,7 @@ def create_app(oidc_blueprint=None): else: key = None cred = DBCredentials(settings.db_url, key) - CSRFProtect(app) + csrf = CSRFProtect(app) infra = Infrastructures(settings.db_url) im = InfrastructureManager(settings.imUrl, settings.imTimeout) ssh_key = SSHKey(settings.db_url) @@ -1494,6 +1494,7 @@ def manage_vault_info(): return redirect(url_for('manage_creds')) @app.route('/oai', methods=['GET', 'POST']) + @csrf.exempt def oai_pmh(): if not settings.oaipmh_repo_name: return make_response("OAI-PMH not enabled.", 404, {'Content-Type': 'text/plain'}) diff --git a/app/tests/test_app.py b/app/tests/test_app.py index 73e28b783..7cc5bbc3c 100644 --- a/app/tests/test_app.py +++ b/app/tests/test_app.py @@ -761,6 +761,10 @@ def test_oai(self): self.assertEqual(root.find(".//oaipmh:granularity", namespace).text, "YYYY-MM-DD") self.assertEqual(root.find(".//oaipmh:adminEmail", namespace).text, "support@example.com") + # Test Identify + res = self.client.post('/oai?verb=Identify') + self.assertEqual(200, res.status_code) + # Test GetRecord tosca_id = "https://github.com/grycap/tosca/blob/main/templates/simple-node-disk.yml" res = self.client.get('/oai?verb=GetRecord&metadataPrefix=oai_dc&identifier=%s' % tosca_id)