Skip to content

Commit e6a24f0

Browse files
committed
Test that explicit AuthorizationServer settings take precedence.
1 parent 5c06b12 commit e6a24f0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

pkg/http/oauth/oauth_test.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ func TestAPIHostResolver_AuthorizationServerURL(t *testing.T) {
626626
tests := []struct {
627627
name string
628628
host string
629+
oauthConfig *Config
629630
expectedURL string
630631
expectedError bool
631632
expectedStatusCode int
@@ -669,6 +670,15 @@ func TestAPIHostResolver_AuthorizationServerURL(t *testing.T) {
669670
expectedURL: "http://ghe.example.com/login/oauth",
670671
expectedStatusCode: http.StatusOK,
671672
},
673+
{
674+
name: "custom authorization server in config takes precedence",
675+
host: "https://github.com",
676+
oauthConfig: &Config{
677+
AuthorizationServer: "https://custom.auth.example.com/oauth",
678+
},
679+
expectedURL: "https://custom.auth.example.com/oauth",
680+
expectedStatusCode: http.StatusOK,
681+
},
672682
}
673683

674684
for _, tc := range tests {
@@ -685,9 +695,13 @@ func TestAPIHostResolver_AuthorizationServerURL(t *testing.T) {
685695
}
686696
require.NoError(t, err)
687697

688-
handler, err := NewAuthHandler(&Config{
689-
BaseURL: "https://api.example.com",
690-
}, apiHost)
698+
config := tc.oauthConfig
699+
if config == nil {
700+
config = &Config{}
701+
}
702+
config.BaseURL = tc.host
703+
704+
handler, err := NewAuthHandler(config, apiHost)
691705
require.NoError(t, err)
692706

693707
router := chi.NewRouter()

0 commit comments

Comments
 (0)