Skip to content

Commit e2c963f

Browse files
fix(auth): Correct path used for SSO errors (#16315)
The route for sentry-organization-auth-settings was still located in the old settings path, this route is used for a redirect in the auth.helper module when there is a problem configuring SSO. This just corrects the redirect so it goes back to settings instead of 404ing.
1 parent ebe82a6 commit e2c963f

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

src/sentry/web/urls.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,11 @@
448448
react_page_view,
449449
name="sentry-organization-member-settings",
450450
),
451+
url(
452+
r"^(?P<organization_slug>[\w_-]+)/auth/$",
453+
react_page_view,
454+
name="sentry-organization-auth-settings",
455+
),
451456
url(r"^", react_page_view),
452457
]
453458
),
@@ -509,11 +514,6 @@
509514
react_page_view,
510515
name="sentry-organization-api-key-settings",
511516
),
512-
url(
513-
r"^(?P<organization_slug>[\w_-]+)/auth/$",
514-
react_page_view,
515-
name="sentry-organization-auth-settings",
516-
),
517517
url(
518518
r"^(?P<organization_slug>[\w_-]+)/auth/configure/$",
519519
OrganizationAuthSettingsView.as_view(),

tests/sentry/web/frontend/test_organization_auth_settings.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.db import models
55
from mock import patch
66

7+
from sentry.auth.exceptions import IdentityNotValid
78
from sentry.models import (
89
AuditLogEntry,
910
AuditLogEntryEvent,
@@ -94,7 +95,7 @@ def assert_require_2fa_disabled(self, user, organization, logger):
9495
"Require 2fa disabled during sso setup", extra={"organization_id": organization.id}
9596
)
9697

97-
def assert_basic_flow(self, user, organization):
98+
def assert_basic_flow(self, user, organization, expect_error=False):
9899
configure_path = reverse(
99100
"sentry-organization-auth-provider-settings", args=[organization.slug]
100101
)
@@ -107,7 +108,13 @@ def assert_basic_flow(self, user, organization):
107108
path = reverse("sentry-auth-sso")
108109
resp = self.client.post(path, {"email": user.email})
109110

110-
self.assertRedirects(resp, configure_path)
111+
settings_path = reverse("sentry-organization-auth-settings", args=[organization.slug])
112+
113+
if expect_error:
114+
self.assertRedirects(resp, settings_path)
115+
return
116+
else:
117+
self.assertRedirects(resp, configure_path)
111118

112119
auth_provider = AuthProvider.objects.get(organization=organization, provider="dummy")
113120
auth_identity = AuthIdentity.objects.get(auth_provider=auth_provider)
@@ -160,6 +167,17 @@ def test_basic_flow(self, logger):
160167
).exists()
161168
assert not logger.info.called
162169

170+
@patch("sentry.auth.helper.logger")
171+
@patch("sentry.auth.providers.dummy.DummyProvider.build_identity")
172+
def test_basic_flow_error(self, build_identity, logger):
173+
build_identity.side_effect = IdentityNotValid()
174+
175+
user = self.create_user("[email protected]")
176+
organization = self.create_organization(name="foo", owner=user)
177+
178+
self.login_as(user)
179+
self.assert_basic_flow(user, organization, expect_error=True)
180+
163181
@patch("sentry.auth.helper.logger")
164182
def test_basic_flow__disable_require_2fa(self, logger):
165183
user = self.create_user("[email protected]")

0 commit comments

Comments
 (0)