@@ -32,14 +32,13 @@ func TestGetSpec_OAuth2(t *testing.T) {
3232 defer mockProviderServer .Close ()
3333
3434 // Pass the test server's client to the handler
35- handler := NewConsentHandler (sqlxDB , "http://localhost:8080" , []byte ("test-key" ), mockProviderServer .Client ())
35+ handler := NewConsentHandler (sqlxDB , "http://localhost:8080" , "/auth/callback" , []byte ("test-key" ), mockProviderServer .Client ())
3636
3737 paramsJSON := []byte (`{"access_type": "offline", "prompt": "consent"}` )
3838
39-
40- rows := sqlmock .NewRows ([]string {"id" , "name" , "auth_type" , "auth_url" , "client_id" , "scopes" , "params" }).
39+ rows := sqlmock .NewRows ([]string {"id" , "name" , "auth_type" , "auth_url" , "client_id" , "scopes" , "params" }).
4140 AddRow ("a0a0a0a0-a0a0-a0a0-a0a0-a0a0a0a0a0a0" , "Test OAuth2 Provider" , "oauth2" , "http://provider.com/auth" , "test-client-id" , "{openid}" , paramsJSON )
42- mock .ExpectQuery ("SELECT id, name, auth_type, auth_url, client_id, scopes, params FROM provider_profiles WHERE id = \\ $1" ).
41+ mock .ExpectQuery ("SELECT id, name, auth_type, auth_url, client_id, scopes, params FROM provider_profiles WHERE id = \\ $1" ).
4342 WithArgs ("a0a0a0a0-a0a0-a0a0-a0a0-a0a0a0a0a0a0" ).
4443 WillReturnRows (rows )
4544
@@ -82,12 +81,11 @@ func TestGetSpec_StaticKey(t *testing.T) {
8281
8382 sqlxDB := sqlx .NewDb (db , "sqlmock" )
8483 // For static key tests, we can pass a default client as no external calls are made.
85- handler := NewConsentHandler (sqlxDB , "http://localhost:8080" , []byte ("test-key" ), http .DefaultClient )
86-
84+ handler := NewConsentHandler (sqlxDB , "http://localhost:8080" , "/auth/callback" , []byte ("test-key" ), http .DefaultClient )
8785
88- rows := sqlmock .NewRows ([]string {"id" , "name" , "auth_type" , "auth_url" , "client_id" , "scopes" , "params" }).
86+ rows := sqlmock .NewRows ([]string {"id" , "name" , "auth_type" , "auth_url" , "client_id" , "scopes" , "params" }).
8987 AddRow ("b1b1b1b1-b1b1-b1b1-b1b1-b1b1b1b1b1b1" , "Test API" , "api_key" , nil , nil , "{}" , []byte ("{}" ))
90- mock .ExpectQuery ("SELECT id, name, auth_type, auth_url, client_id, scopes, params FROM provider_profiles WHERE id = \\ $1" ).
88+ mock .ExpectQuery ("SELECT id, name, auth_type, auth_url, client_id, scopes, params FROM provider_profiles WHERE id = \\ $1" ).
9189 WithArgs ("b1b1b1b1-b1b1-b1b1-b1b1-b1b1b1b1b1b1" ).
9290 WillReturnRows (rows )
9391
@@ -134,7 +132,7 @@ func TestGetSpec_MixedOAuth2_Discovery(t *testing.T) {
134132 "authorization_endpoint": "http://%s/openid/connect/authorize",
135133 "jwks_uri": "http://%s/jwks"
136134 }` ,
137- r .Host , r .Host , r .Host )
135+ r .Host , r .Host , r .Host )
138136 w .Write ([]byte (oidcConfig ))
139137 return
140138 }
@@ -143,16 +141,16 @@ func TestGetSpec_MixedOAuth2_Discovery(t *testing.T) {
143141 defer ts .Close ()
144142
145143 // Handler under test
146- handler := NewConsentHandler (sqlxDB , "http://localhost:8080" , []byte ("test-key" ), ts .Client ())
144+ handler := NewConsentHandler (sqlxDB , "http://localhost:8080" , "/auth/callback" , []byte ("test-key" ), ts .Client ())
147145
148146 // Define the configured (legacy) auth URL
149147 configuredAuthURL := ts .URL + "/oauth/v2/authorize"
150148
151149 // 1. Mock DB Provider Query
152150
153- rows := sqlmock .NewRows ([]string {"id" , "name" , "auth_type" , "auth_url" , "client_id" , "scopes" , "params" }).
151+ rows := sqlmock .NewRows ([]string {"id" , "name" , "auth_type" , "auth_url" , "client_id" , "scopes" , "params" }).
154152 AddRow ("00000000-0000-0000-0000-000000000000" , "Slack" , "oauth2" , configuredAuthURL , "slack-client" , "{chat:write}" , []byte ("{}" ))
155-
153+
156154 // Use regex to avoid strict string matching issues with sqlmock
157155 mock .ExpectQuery ("SELECT .* FROM provider_profiles WHERE id = .*" ).
158156 WithArgs ("00000000-0000-0000-0000-000000000000" ).
@@ -192,4 +190,4 @@ rows := sqlmock.NewRows([]string{"id", "name", "auth_type", "auth_url", "client_
192190 if ! strings .HasPrefix (response .AuthURL , configuredAuthURL ) {
193191 t .Errorf ("Expected AuthURL to start with configured URL %s, but got %s" , configuredAuthURL , response .AuthURL )
194192 }
195- }
193+ }
0 commit comments