-
-
Notifications
You must be signed in to change notification settings - Fork 433
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
[17.0][IMP] auth_saml: only write value that changes #726
Open
vincent-hatakeyama
wants to merge
1
commit into
OCA:17.0
Choose a base branch
from
xcgd:feature/17.0/auth-saml/write-only-necessary-fields
base: 17.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
## 16.0.1.0.0 | ||
## 17.0.1.1.0 | ||
|
||
Initial migration for 16.0. | ||
When using attribute mapping, only write value that changes. | ||
No writing the value systematically avoids getting security mail on login/email | ||
when there is no real change. | ||
|
||
## 17.0.1.0.0 | ||
|
||
Initial migration for 17.0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,24 +133,25 @@ def test__compute_sp_metadata_url__provider_has_sp_baseurl(self): | |
self.assertEqual(self.saml_provider.sp_metadata_url, expected_url) | ||
self.saml_provider.sp_baseurl = temp | ||
|
||
def test__hook_validate_auth_response(self): | ||
# Create a fake response with attributes | ||
fake_response = DummyResponse(200, "fake_data") | ||
fake_response.set_identity( | ||
{"email": "[email protected]", "first_name": "New", "last_name": "User"} | ||
) | ||
|
||
# Add attribute mappings to the provider | ||
def _add_mapping_to_provider(self): | ||
"""Add mapping to the provider""" | ||
self.saml_provider.attribute_mapping_ids = [ | ||
(0, 0, {"attribute_name": "email", "field_name": "login"}), | ||
(0, 0, {"attribute_name": "first_name", "field_name": "name"}), | ||
(0, 0, {"attribute_name": "mail", "field_name": "login"}), | ||
(0, 0, {"attribute_name": "givenName", "field_name": "name"}), | ||
( | ||
0, | ||
0, | ||
{"attribute_name": "nick_name", "field_name": "name"}, | ||
), # This attribute is not in attrs | ||
] | ||
|
||
def test__hook_validate_auth_response(self): | ||
# Create a fake response with attributes | ||
fake_response = DummyResponse(200, "fake_data") | ||
fake_response.set_identity( | ||
{"mail": "[email protected]", "givenName": "New", "last_name": "User"} | ||
) | ||
self._add_mapping_to_provider() | ||
# Call the method | ||
result = self.saml_provider._hook_validate_auth_response( | ||
fake_response, "[email protected]" | ||
|
@@ -261,6 +262,17 @@ def test_login_with_saml(self): | |
# User should now be able to log in with the token | ||
self.authenticate(user="[email protected]", password=token) | ||
|
||
def test_login_with_saml_mapping_attributes(self): | ||
"""Test login with SAML on a provider with mapping attributes""" | ||
self.assertEqual(self.user.name, "User") | ||
self.assertEqual(self.user.login, "[email protected]") | ||
self._add_mapping_to_provider() | ||
self.test_login_with_saml() | ||
# Changed due to mapping and FakeIDP returning another value | ||
self.assertEqual(self.user.name, "Test") | ||
# Not changed | ||
self.assertEqual(self.user.login, "[email protected]") | ||
|
||
def test_disallow_user_password_when_changing_ir_config_parameter(self): | ||
"""Test that disabling users from having both a password and SAML ids remove | ||
users password.""" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it granted that
value
will be compatible w/ the field type? Eg: what if you have a boolean field and you compareFalse
with0
?