Skip to content

Commit 39d7d78

Browse files
author
Rebecka Gulliksson
committed
Don't add empty values (because of missing attribute mappings) in DataConverter.to_internal_filter.
1 parent 6520d31 commit 39d7d78

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/satosa/internal_data.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@ def to_internal_filter(self, external_type, external_keys, case_insensitive=Fals
6969
"""
7070
internal_keys = set()
7171
for external_key in external_keys:
72-
internal_keys.add(
73-
self.external2internal_attribute_name_mapping[external_type].get(external_key,
74-
case_insensitive))
72+
internal_key = self.external2internal_attribute_name_mapping[external_type].get(
73+
external_key,
74+
case_insensitive)
75+
76+
if internal_key:
77+
internal_keys.add(internal_key)
7578

7679
return internal_keys
7780

tests/satosa/test_internal_data.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,24 @@ def test_to_internal_profile_missing_attribute_mapping(self):
232232
assert "mail" not in internal_repr # no mapping for the 'mail' attribute in the 'bar' profile
233233
assert internal_repr["id"] == ["uid"]
234234

235+
def test_to_internal_filter_profile_missing_attribute_mapping(self):
236+
mapping = {
237+
"attributes": {
238+
"mail": {
239+
"foo": ["email"],
240+
},
241+
"id": {
242+
"foo": ["id"],
243+
"bar": ["uid"],
244+
}
245+
},
246+
}
247+
248+
converter = DataConverter(mapping)
249+
filter = converter.to_internal_filter("bar", ["email", "uid"])
250+
assert Counter(filter) == Counter(["id"])
251+
252+
235253
@pytest.mark.parametrize("attribute_value", [
236254
{"email": "test@example.com"},
237255
{"email": ["test@example.com"]}

0 commit comments

Comments
 (0)