Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.

Commit f27ada1

Browse files
author
Hannu Kamarainen
committed
CSCMETAX-394: [FIX] Uncomment the part that does the actual cleaning... In tests, search for known sensitive values instead of field names
1 parent bb654a6 commit f27ada1

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/metax_api/api/oaipmh/base/metax_oai_server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def _get_metadata_for_record(self, record, metadata_prefix):
208208
# strip sensitive fields from research_dataset. note: the modified research_dataset
209209
# is placed back into the record's research_dataset -field. meaning, an accidental call
210210
# of record.save() would overwrite the original data
211-
# record.research_dataset = CRS.strip_catalog_record(record.research_dataset)
211+
record.research_dataset = CRS.strip_catalog_record(record.research_dataset)
212212

213213
if metadata_prefix == 'oai_dc':
214214
meta = self._get_oai_dc_metadata(record)

src/metax_api/tests/api/oaipmh/minimal_api.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -236,21 +236,23 @@ def test_sensitive_fields_are_removed(self):
236236
"""
237237
Ensure some sensitive fields are never present in output of OAI-PMH apis
238238
"""
239+
sensitive_field_values = [ '[email protected]', '999-123-123', '999-456-456' ]
239240

240241
def _check_fields(content):
241242
"""
242-
Verify sensitive fields are not in the content
243+
Verify sensitive fields values are not in the content. Checking for field value, instead
244+
of field name, since the field names might be different in Datacite etc other formats.
243245
"""
244-
for sensitive_field in ['email', 'telephone', 'phone']:
245-
self.assertEqual(sensitive_field not in str(content), True,
246-
'field %s should have been stripped' % sensitive_field)
246+
for sensitive_field_value in sensitive_field_values:
247+
self.assertEqual(sensitive_field_value not in str(content), True,
248+
'field %s should have been stripped' % sensitive_field_value)
247249

248250
# setup some records to have sensitive fields
249251
for cr in CatalogRecord.objects.filter(pk__in=(1, 2, 3)):
250252
cr.research_dataset['curator'][0].update({
251-
'email': '[email protected]',
252-
'phone': '123124',
253-
'telephone': '123124',
253+
'email': sensitive_field_values[0],
254+
'phone': sensitive_field_values[1],
255+
'telephone': sensitive_field_values[2],
254256
})
255257
cr.force_save()
256258

0 commit comments

Comments
 (0)