Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OAI POST #543

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'})
Expand Down
4 changes: 4 additions & 0 deletions app/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "[email protected]")

# 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)
Expand Down