MCPcopy Create free account
hub / github.com/supabase/auth / TestPrepRedirectURL

Method TestPrepRedirectURL

internal/api/verify_test.go:1144–1189  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1142}
1143
1144func (ts *VerifyTestSuite) TestPrepRedirectURL() {
1145 escapedMessage := url.QueryEscape(singleConfirmationAccepted)
1146 cases := []struct {
1147 desc string
1148 message string
1149 rurl string
1150 flowType models.FlowType
1151 expected string
1152 }{
1153 {
1154 desc: "(PKCE): Redirect URL with additional query params",
1155 message: singleConfirmationAccepted,
1156 rurl: "https://example.com/?first=another&second=other",
1157 flowType: models.PKCEFlow,
1158 expected: fmt.Sprintf("https://example.com/?first=another&message=%s&second=other#message=%s&sb=", escapedMessage, escapedMessage),
1159 },
1160 {
1161 desc: "(PKCE): Query params in redirect url are overriden",
1162 message: singleConfirmationAccepted,
1163 rurl: "https://example.com/?message=Valid+redirect+URL",
1164 flowType: models.PKCEFlow,
1165 expected: fmt.Sprintf("https://example.com/?message=%s#message=%s&sb=", escapedMessage, escapedMessage),
1166 },
1167 {
1168 desc: "(Implicit): plain redirect url",
1169 message: singleConfirmationAccepted,
1170 rurl: "https://example.com/",
1171 flowType: models.ImplicitFlow,
1172 expected: fmt.Sprintf("https://example.com/#message=%s&sb=", escapedMessage),
1173 },
1174 {
1175 desc: "(Implicit): query params retained",
1176 message: singleConfirmationAccepted,
1177 rurl: "https://example.com/?first=another",
1178 flowType: models.ImplicitFlow,
1179 expected: fmt.Sprintf("https://example.com/?first=another#message=%s&sb=", escapedMessage),
1180 },
1181 }
1182 for _, c := range cases {
1183 ts.Run(c.desc, func() {
1184 rurl, err := ts.API.prepRedirectURL(c.message, c.rurl, c.flowType)
1185 require.NoError(ts.T(), err)
1186 require.Equal(ts.T(), c.expected, rurl)
1187 })
1188 }
1189}
1190
1191func (ts *VerifyTestSuite) TestPrepErrorRedirectURL() {
1192 const DefaultError = "Invalid redirect URL"

Callers

nothing calls this directly

Calls 3

prepRedirectURLMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected