Skip to content

Commit

Permalink
Merge pull request #69 from collective/cekk_fix_identity_props
Browse files Browse the repository at this point in the history
Better handle values from identity data
  • Loading branch information
jensens committed Apr 12, 2023
2 parents d3d5244 + 4a00b2d commit a767e8c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## 1.1.3 (unreleased)


- Nothing changed yet.
- Better handle values from identity data. @cekk


## 1.1.2 (2023-03-15)
Expand Down
20 changes: 20 additions & 0 deletions src/pas/plugins/authomatic/tests/test_useridentities.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,25 @@ def test_provider_specific_user_attributes(self):
self.assertEqual(sheet.getProperty("email"), "andrewpipkin@foobar.com")
self.assertEqual(sheet.getProperty("customdomain"), "foobar.com")

def test_read_attribute_from_provider_data_if_default_is_none(self):
PNAME = "mockhub"
user = self._make_authomatic_user(
provider_name=PNAME, data={"email": "jdoe@foobar.com"}
)
user.email = None
authomatic_result = MockResult(
user=user,
provider=MockResult(name=PNAME),
)
uis = make_user("mustermann")
uis.handle_result(authomatic_result)

# mock cfg
with mock.patch("pas.plugins.authomatic.useridentities.authomatic_cfg") as acfg:
cfg = self._make_cfg(PNAME)
acfg.return_value = cfg
sheet = uis.propertysheet
self.assertEqual(sheet.getProperty("email"), "jdoe@foobar.com")

def test_credentials(self):
pass
2 changes: 1 addition & 1 deletion src/pas/plugins/authomatic/useridentities.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def propertysheet(self):
for akey, pkey in cfg.get("propertymap", {}).items():
# Always search first on the user attributes, then on the raw
# data this guaratees we do not break existing configurations
ainfo = identity.get(akey, identity["data"].get(akey, None))
ainfo = identity.get(akey, None) or identity["data"].get(akey, None)
if ainfo is None:
continue
if isinstance(pkey, dict):
Expand Down

0 comments on commit a767e8c

Please sign in to comment.