-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(auth): Correct path used for SSO errors #16315
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
Merged
evanpurkhiser
merged 1 commit into
master
from
evanpurkhiser/fixauth-correct-path-used-for-sso-errors
Jan 9, 2020
Merged
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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
from django.db import models | ||
from mock import patch | ||
|
||
from sentry.auth.exceptions import IdentityNotValid | ||
from sentry.models import ( | ||
AuditLogEntry, | ||
AuditLogEntryEvent, | ||
|
@@ -94,7 +95,7 @@ def assert_require_2fa_disabled(self, user, organization, logger): | |
"Require 2fa disabled during sso setup", extra={"organization_id": organization.id} | ||
) | ||
|
||
def assert_basic_flow(self, user, organization): | ||
def assert_basic_flow(self, user, organization, expect_error=False): | ||
configure_path = reverse( | ||
"sentry-organization-auth-provider-settings", args=[organization.slug] | ||
) | ||
|
@@ -107,7 +108,13 @@ def assert_basic_flow(self, user, organization): | |
path = reverse("sentry-auth-sso") | ||
resp = self.client.post(path, {"email": user.email}) | ||
|
||
self.assertRedirects(resp, configure_path) | ||
settings_path = reverse("sentry-organization-auth-settings", args=[organization.slug]) | ||
|
||
if expect_error: | ||
self.assertRedirects(resp, settings_path) | ||
return | ||
else: | ||
self.assertRedirects(resp, configure_path) | ||
|
||
auth_provider = AuthProvider.objects.get(organization=organization, provider="dummy") | ||
auth_identity = AuthIdentity.objects.get(auth_provider=auth_provider) | ||
|
@@ -160,6 +167,17 @@ def test_basic_flow(self, logger): | |
).exists() | ||
assert not logger.info.called | ||
|
||
@patch("sentry.auth.helper.logger") | ||
@patch("sentry.auth.providers.dummy.DummyProvider.build_identity") | ||
def test_basic_flow_error(self, build_identity, logger): | ||
build_identity.side_effect = IdentityNotValid() | ||
|
||
user = self.create_user("[email protected]") | ||
organization = self.create_organization(name="foo", owner=user) | ||
|
||
self.login_as(user) | ||
self.assert_basic_flow(user, organization, expect_error=True) | ||
|
||
@patch("sentry.auth.helper.logger") | ||
def test_basic_flow__disable_require_2fa(self, logger): | ||
user = self.create_user("[email protected]") | ||
|
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.
Shouldn't this live in the new auth home in settings as well?
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.
No this is the non-react page for auth settings, too much work to move this right now