1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-06-15 00:15:00 +02:00

Improve handler vs helper organization in oauthproxy.go

Additionally, convert a lot of helper methods to be private
This commit is contained in:
Nick Meves
2021-01-02 14:20:48 -08:00
parent 73fc7706bc
commit fa6a785eaf
2 changed files with 332 additions and 329 deletions

View File

@ -415,8 +415,9 @@ func Test_redeemCode(t *testing.T) {
t.Fatal(err)
}
_, err = proxy.redeemCode(context.Background(), "www.example.com", "")
assert.Error(t, err)
req := httptest.NewRequest(http.MethodGet, "/", nil)
_, err = proxy.redeemCode(req)
assert.Equal(t, providers.ErrMissingCode, err)
}
func Test_enrichSession(t *testing.T) {
@ -1749,7 +1750,7 @@ func TestRequestSignature(t *testing.T) {
}
}
func TestGetRedirect(t *testing.T) {
func Test_getAppRedirect(t *testing.T) {
opts := baseTestOptions()
opts.WhitelistDomains = append(opts.WhitelistDomains, ".example.com", ".example.com:8443")
err := validation.Validate(opts)
@ -1900,7 +1901,7 @@ func TestGetRedirect(t *testing.T) {
req = middleware.AddRequestScope(req, &middleware.RequestScope{
ReverseProxy: tt.reverseProxy,
})
redirect, err := proxy.GetAppRedirect(req)
redirect, err := proxy.getAppRedirect(req)
assert.NoError(t, err)
assert.Equal(t, tt.expectedRedirect, redirect)