-
Notifications
You must be signed in to change notification settings - Fork 140
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
Bug 2026573: use rd for redirect #234
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -493,6 +493,53 @@ func TestSignInPageIncludesTargetRedirect(t *testing.T) { | |
} | ||
} | ||
|
||
func TestGetRedirect(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
options func() *Options | ||
requestURI string | ||
expected string | ||
}{ | ||
{ | ||
name: "Redirect to root", | ||
options: func() *Options { | ||
return testOptions() | ||
}, | ||
requestURI: "/oauth2/start", | ||
expected: "/", | ||
}, | ||
{ | ||
name: "Redirect to root", | ||
options: func() *Options { | ||
opts := testOptions() | ||
opts.SkipProviderButton = true | ||
opts.ProxyPrefix = "/oauth" | ||
return opts | ||
}, | ||
requestURI: "/oauth/start", | ||
expected: "/", | ||
}, | ||
{ | ||
name: "Redirect to custom uri", | ||
options: func() *Options { | ||
opts := testOptions() | ||
opts.SkipProviderButton = true | ||
opts.ProxyPrefix = "/oauth2" | ||
return opts | ||
}, | ||
requestURI: "/oauth2/start", | ||
expected: "/oauth2/start", | ||
}, | ||
Comment on lines
+511
to
+532
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do these scenarios behave differently? Why is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't see the reason why we should treat There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not know if my case is used by other customers. my case is using default setting with |
||
} | ||
for _, tc := range testCases { | ||
req, _ := http.NewRequest("GET", tc.requestURI, strings.NewReader("")) | ||
req.RequestURI = tc.requestURI | ||
oauthProxy := NewOAuthProxy(tc.options(), func(s string) bool { return true }) | ||
redirect, _ := oauthProxy.GetRedirect(req) | ||
assert.Equal(t, tc.expected, redirect) | ||
} | ||
} | ||
|
||
func TestSignInPageDirectAccessRedirectsToRoot(t *testing.T) { | ||
sip_test := NewSignInPageTest() | ||
code, body := sip_test.GetEndpoint("/oauth2/sign_in") | ||
|
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.
do you mind to add some tests here 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.
Done. Thanks.