@@ -26,7 +26,14 @@ func TestRefresh_StaticKeyProvider(t *testing.T) {
2626 defer db .Close ()
2727
2828 sqlxDB := sqlx .NewDb (db , "sqlmock" )
29- handler := NewCallbackHandler (sqlxDB , "http://localhost:8080" , "/auth/callback" , []byte ("test-key" ), []byte ("test-key" ), http .DefaultClient )
29+ handler := NewCallbackHandler (CallbackHandlerConfig {
30+ DB : sqlxDB ,
31+ BaseURL : "http://localhost:8080" ,
32+ RedirectPath : "/auth/callback" ,
33+ EncryptionKey : []byte ("test-key" ),
34+ StateKey : []byte ("test-key" ),
35+ HTTPClient : http .DefaultClient ,
36+ })
3037
3138 // Mock the initial query to find the connection
3239
@@ -66,7 +73,14 @@ func TestRefresh_OAuth2Provider(t *testing.T) {
6673 }))
6774 defer mockProviderServer .Close ()
6875
69- handler := NewCallbackHandler (sqlxDB , "http://localhost:8080" , "/auth/callback" , []byte ("01234567890123456789012345678901" ), []byte ("01234567890123456789012345678901" ), mockProviderServer .Client ())
76+ handler := NewCallbackHandler (CallbackHandlerConfig {
77+ DB : sqlxDB ,
78+ BaseURL : "http://localhost:8080" ,
79+ RedirectPath : "/auth/callback" ,
80+ EncryptionKey : []byte ("01234567890123456789012345678901" ),
81+ StateKey : []byte ("01234567890123456789012345678901" ),
82+ HTTPClient : mockProviderServer .Client (),
83+ })
7084
7185 // Mock the initial query to find the connection
7286
@@ -117,7 +131,14 @@ func TestGetCaptureSchema(t *testing.T) {
117131 sqlxDB := sqlx .NewDb (db , "sqlmock" )
118132 // Use a real key for signing/verifying state
119133 stateKey := []byte ("01234567890123456789012345678901" )
120- handler := NewCallbackHandler (sqlxDB , "http://localhost:8080" , "/auth/callback" , nil , stateKey , http .DefaultClient )
134+ handler := NewCallbackHandler (CallbackHandlerConfig {
135+ DB : sqlxDB ,
136+ BaseURL : "http://localhost:8080" ,
137+ RedirectPath : "/auth/callback" ,
138+ EncryptionKey : nil ,
139+ StateKey : stateKey ,
140+ HTTPClient : http .DefaultClient ,
141+ })
121142
122143 providerID := uuid .New ()
123144 stateData := auth.StateData {
@@ -170,7 +191,14 @@ func TestSaveCredential_ValidState(t *testing.T) {
170191 sqlxDB := sqlx .NewDb (db , "sqlmock" )
171192 stateKey := []byte ("01234567890123456789012345678901" )
172193 encryptionKey := []byte ("01234567890123456789012345678901" )
173- handler := NewCallbackHandler (sqlxDB , "http://localhost:8080" , "/auth/callback" , encryptionKey , stateKey , http .DefaultClient )
194+ handler := NewCallbackHandler (CallbackHandlerConfig {
195+ DB : sqlxDB ,
196+ BaseURL : "http://localhost:8080" ,
197+ RedirectPath : "/auth/callback" ,
198+ EncryptionKey : encryptionKey ,
199+ StateKey : stateKey ,
200+ HTTPClient : http .DefaultClient ,
201+ })
174202
175203 connectionID := uuid .New ()
176204 stateData := auth.StateData {
@@ -224,7 +252,14 @@ func TestSaveCredential_ValidState(t *testing.T) {
224252}
225253
226254func TestSaveCredential_InvalidState (t * testing.T ) {
227- handler := NewCallbackHandler (nil , "http://localhost:8080" , "/auth/callback" , nil , []byte ("test-key" ), http .DefaultClient )
255+ handler := NewCallbackHandler (CallbackHandlerConfig {
256+ DB : nil ,
257+ BaseURL : "http://localhost:8080" ,
258+ RedirectPath : "/auth/callback" ,
259+ EncryptionKey : nil ,
260+ StateKey : []byte ("test-key" ),
261+ HTTPClient : http .DefaultClient ,
262+ })
228263
229264 creds := map [string ]interface {}{"api_key" : "test-key" }
230265 body := map [string ]interface {}{
@@ -245,7 +280,14 @@ func TestSaveCredential_InvalidState(t *testing.T) {
245280}
246281
247282func TestSaveCredential_InvalidJSON (t * testing.T ) {
248- handler := NewCallbackHandler (nil , "http://localhost:8080" , "/auth/callback" , nil , nil , http .DefaultClient )
283+ handler := NewCallbackHandler (CallbackHandlerConfig {
284+ DB : nil ,
285+ BaseURL : "http://localhost:8080" ,
286+ RedirectPath : "/auth/callback" ,
287+ EncryptionKey : nil ,
288+ StateKey : nil ,
289+ HTTPClient : http .DefaultClient ,
290+ })
249291
250292 req , err := http .NewRequest ("POST" , "/auth/capture-credential" , bytes .NewBuffer ([]byte ("not-json" )))
251293 assert .NoError (t , err )
0 commit comments