Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

urls: Add `/` to `_page` URLs to avoid redirects.

Aman Agrawal201a2bb9c836
diff --git a/corporate/tests/test_remote_billing.py b/corporate/tests/test_remote_billing.py
index d0a36e0a2dc..0cebedd8ced 100644
--- a/corporate/tests/test_remote_billing.py
+++ b/corporate/tests/test_remote_billing.py
@@ -83,7 +83,7 @@ class RemoteBillingAuthenticationTest(BouncerTestCase):
# TODO: The redirect URL will vary depending on the billing state of the user's
# realm/server when we implement proper logic for that. For now, we can simply
# hard-code an assert about the endpoint.
- self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/plans")
+ self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/plans/")
# Go to the URL we're redirected to after authentication and assert
# some basic expected content.
@@ -122,7 +122,7 @@ class RemoteBillingAuthenticationTest(BouncerTestCase):
# The user's realm should now be registered:
self.assertTrue(RemoteRealm.objects.filter(uuid=realm.uuid).exists())
- self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/plans")
+ self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/plans/")
result = self.client_get(result["Location"], subdomain="selfhosting")
self.assert_in_success_response(["Your remote user info:"], result)
@@ -142,7 +142,7 @@ class RemoteBillingAuthenticationTest(BouncerTestCase):
with time_machine.travel(now, tick=False):
result = self.execute_remote_billing_authentication_flow(desdemona)
- self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/plans")
+ self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/plans/")
final_url = result["Location"]
@@ -175,7 +175,7 @@ class RemoteBillingAuthenticationTest(BouncerTestCase):
# So let's test that and assert that we end up successfully re-authed on the /plans
# page.
result = self.execute_remote_billing_authentication_flow(desdemona, next_page="plans")
- self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/plans")
+ self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/plans/")
result = self.client_get(result["Location"], subdomain="selfhosting")
self.assert_in_success_response(["Your remote user info:"], result)
self.assert_in_success_response([desdemona.delivery_email], result)
@@ -191,11 +191,11 @@ class RemoteBillingAuthenticationTest(BouncerTestCase):
send_realms_only_to_push_bouncer()
# Straight-up access without authing at all:
- result = self.client_get(f"/realm/{realm.uuid!s}/plans", subdomain="selfhosting")
+ result = self.client_get(f"/realm/{realm.uuid!s}/plans/", subdomain="selfhosting")
self.assert_json_error(result, "User not authenticated", 401)
result = self.execute_remote_billing_authentication_flow(desdemona)
- self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/plans")
+ self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/plans/")
final_url = result["Location"]
@@ -244,7 +244,7 @@ class RemoteBillingAuthenticationTest(BouncerTestCase):
result = self.execute_remote_billing_authentication_flow(desdemona, "sponsorship")
- self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/sponsorship")
+ self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/sponsorship/")
# Go to the URL we're redirected to after authentication and assert
# some basic expected content.
@@ -264,7 +264,7 @@ class RemoteBillingAuthenticationTest(BouncerTestCase):
result = self.execute_remote_billing_authentication_flow(desdemona, "upgrade")
- self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/upgrade")
+ self.assertEqual(result["Location"], f"/realm/{realm.uuid!s}/upgrade/")
# Go to the URL we're redirected to after authentication and assert
# some basic expected content.
@@ -328,7 +328,7 @@ class LegacyServerLoginTest(BouncerTestCase):
)
self.assertEqual(result.status_code, 302)
- self.assertEqual(result["Location"], f"/server/{self.uuid}/upgrade")
+ self.assertEqual(result["Location"], f"/server/{self.uuid}/upgrade/")
# Verify the authed data that should have been stored in the session.
identity_dict = LegacyServerIdentityDict(
@@ -343,7 +343,7 @@ class LegacyServerLoginTest(BouncerTestCase):
result = self.client_get(f"/server/{self.uuid}/billing/", subdomain="selfhosting")
# The server has no plan, so the /billing page redirects to /upgrade
self.assertEqual(result.status_code, 302)
- self.assertEqual(result["Location"], f"/server/{self.uuid}/upgrade")
+ self.assertEqual(result["Location"], f"/server/{self.uuid}/upgrade/")
# Access on the upgrade page is granted, assert a basic string proving that.
result = self.client_get(result["Location"], subdomain="selfhosting")
@@ -371,7 +371,7 @@ class LegacyServerLoginTest(BouncerTestCase):
)
# We should be redirected to the page dictated by the next_page param.
self.assertEqual(result.status_code, 302)
- self.assertEqual(result["Location"], f"/server/{self.uuid}/sponsorship")
+ self.assertEqual(result["Location"], f"/server/{self.uuid}/sponsorship/")
result = self.client_get(result["Location"], subdomain="selfhosting")
# TODO Update the string when we have a complete sponsorship page for legacy servers.
@@ -422,7 +422,7 @@ class LegacyServerLoginTest(BouncerTestCase):
)
self.assertEqual(result.status_code, 302)
- self.assertEqual(result["Location"], f"/server/{self.uuid}/upgrade")
+ self.assertEqual(result["Location"], f"/server/{self.uuid}/upgrade/")
# Sanity check: access on the upgrade page is granted.
result = self.client_get(result["Location"], subdomain="selfhosting")
@@ -435,6 +435,6 @@ class LegacyServerLoginTest(BouncerTestCase):
now + datetime.timedelta(seconds=REMOTE_BILLING_SESSION_VALIDITY_SECONDS + 30),
tick=False,
):
- result = self.client_get(f"/server/{self.uuid}/upgrade", subdomain="selfhosting")
+ result = self.client_get(f"/server/{self.uuid}/upgrade/", subdomain="selfhosting")
self.assertEqual(result.status_code, 302)
self.assertEqual(result["Location"], "/serverlogin/?next_page=upgrade")
diff --git a/corporate/urls.py b/corporate/urls.py
index e5757a533d7..1acc3d713f1 100644
--- a/corporate/urls.py
+++ b/corporate/urls.py
@@ -184,12 +184,12 @@ urlpatterns = list(i18n_urlpatterns)
urlpatterns += [
path(
- "remote-billing-login/<signed_billing_access_token>", remote_server_billing_finalize_login
+ "remote-billing-login/<signed_billing_access_token>/", remote_server_billing_finalize_login
),
# Remote server billing endpoints.
- path("realm/<realm_uuid>/plans", remote_realm_plans_page, name="remote_realm_plans_page"),
+ path("realm/<realm_uuid>/plans/", remote_realm_plans_page, name="remote_realm_plans_page"),
path(
- "server/<server_uuid>/plans",
+ "server/<server_uuid>/plans/",
remote_server_plans_page,
name="remote_server_plans_page",
),
@@ -201,19 +201,21 @@ urlpatterns += [
remote_server_billing_page,
name="remote_server_billing_page",
),
- path("realm/<realm_uuid>/upgrade", remote_realm_upgrade_page, name="remote_realm_upgrade_page"),
path(
- "server/<server_uuid>/upgrade",
+ "realm/<realm_uuid>/upgrade/", remote_realm_upgrade_page, name="remote_realm_upgrade_page"
+ ),
+ path(
+ "server/<server_uuid>/upgrade/",
remote_server_upgrade_page,
name="remote_server_upgrade_page",
),
path(
- "realm/<realm_uuid>/sponsorship",
+ "realm/<realm_uuid>/sponsorship/",
remote_realm_sponsorship_page,
name="remote_realm_sponsorship_page",
),
path(
- "server/<server_uuid>/sponsorship",
+ "server/<server_uuid>/sponsorship/",
remote_server_sponsorship_page,
name="remote_server_sponsorship_page",
),
@@ -223,12 +225,12 @@ urlpatterns += [
name="remote_billing_legacy_server_login",
),
path(
- "realm/<realm_uuid>/billing/event_status",
+ "realm/<realm_uuid>/billing/event_status/",
remote_realm_event_status_page,
name="remote_realm_event_status_page",
),
path(
- "server/<server_uuid>/billing/event_status",
+ "server/<server_uuid>/billing/event_status/",
remote_server_event_status_page,
name="remote_server_event_status_page",
),