Skip to content

Commit 1a8eeb6

Browse files
committed
sso_proxy: oauthproxy tests
1 parent 71345df commit 1a8eeb6

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

internal/proxy/oauthproxy_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ func TestSignOutPage(t *testing.T) {
13741374
expectedLocation string
13751375
}{
13761376
{
1377-
Name: "successful sign out response",
1377+
Name: "successful rendered sign out html page",
13781378
mockSessionStore: &sessions.MockSessionStore{
13791379
Session: &sessions.SessionState{
13801380
@@ -1384,20 +1384,9 @@ func TestSignOutPage(t *testing.T) {
13841384
},
13851385
},
13861386
ExpectedStatusCode: http.StatusOK,
1387-
expectedSignOutResp: signOutResp{
1388-
ProviderSlug: "Test Provider",
1389-
Version: VERSION,
1390-
Action: "http://localhost/oauth/sign_out",
1391-
Destination: "localhost",
1392-
1393-
SignOutParams: providers.SignOutParams{
1394-
//TODO: where is example.com coming from?
1395-
RedirectURL: "http://example.com/",
1396-
},
1397-
},
13981387
},
13991388
{
1400-
Name: "successful rendered sign out html page",
1389+
Name: "successful sign out response",
14011390
mockSessionStore: &sessions.MockSessionStore{
14021391
Session: &sessions.SessionState{
14031392
@@ -1407,14 +1396,25 @@ func TestSignOutPage(t *testing.T) {
14071396
},
14081397
},
14091398
ExpectedStatusCode: http.StatusOK,
1399+
expectedSignOutResp: signOutResp{
1400+
//TODO: standardise on ProviderSlug or ProviderName?
1401+
ProviderSlug: "",
1402+
Version: VERSION,
1403+
Action: "http://localhost/oauth/sign_out",
1404+
Destination: "example.com",
1405+
1406+
SignOutParams: providers.SignOutParams{
1407+
RedirectURL: "https://example.com/",
1408+
},
1409+
},
14101410
},
14111411
{ // TODO: Check the redirect URL is what we expect
14121412
Name: "redirect to sso_auth if no session exists",
14131413
mockSessionStore: &sessions.MockSessionStore{
14141414
LoadError: http.ErrNoCookie,
14151415
},
14161416
ExpectedStatusCode: http.StatusFound,
1417-
expectedLocation: "http://localhost/oauth/sign_out?redirect_uri=http%3A%2F%2Fexample.com%2F&sig=&ts=",
1417+
expectedLocation: "http://localhost/oauth/sign_out?redirect_uri=https%3A%2F%2Fexample.com%2F&sig=&ts=",
14181418
},
14191419
//{
14201420
// Name: "cookieSecure sets scheme to https, if no scheme included",
@@ -1454,7 +1454,7 @@ func TestSignOutPage(t *testing.T) {
14541454
}
14551455

14561456
rw := httptest.NewRecorder()
1457-
req := httptest.NewRequest("GET", "/sign_out", nil)
1457+
req := httptest.NewRequest("GET", "https://example.com/sign_out", nil)
14581458

14591459
proxy.SignOutPage(rw, req)
14601460

@@ -1475,7 +1475,7 @@ func TestSignOutPage(t *testing.T) {
14751475
t.Errorf("unable to properly parse response: %v", err)
14761476
}
14771477

1478-
expectedBody := "Sign out of <b>localhost</b>"
1478+
expectedBody := "Sign out of <b>example.com</b>"
14791479
actualBody := string(respBytes)
14801480
if !strings.Contains(actualBody, expectedBody) {
14811481
t.Logf("expected body to contain: %q", expectedBody)

0 commit comments

Comments
 (0)