Skip to content

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/sentry/web/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,11 @@
react_page_view,
name="sentry-organization-member-settings",
),
url(
r"^(?P<organization_slug>[\w_-]+)/auth/$",
react_page_view,
name="sentry-organization-auth-settings",
),
url(r"^", react_page_view),
]
),
Expand Down Expand Up @@ -509,11 +514,6 @@
react_page_view,
name="sentry-organization-api-key-settings",
),
url(
r"^(?P<organization_slug>[\w_-]+)/auth/$",
react_page_view,
name="sentry-organization-auth-settings",
),
url(
Copy link
Member

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?

Copy link
Member Author

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

r"^(?P<organization_slug>[\w_-]+)/auth/configure/$",
OrganizationAuthSettingsView.as_view(),
Expand Down
22 changes: 20 additions & 2 deletions tests/sentry/web/frontend/test_organization_auth_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
)
Expand All @@ -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)
Expand Down Expand Up @@ -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]")
Expand Down