@@ -144,10 +144,10 @@ func setupWithNango(t *testing.T) *testEnv {
144144 _ = json .NewDecoder (r .Body ).Decode (& req )
145145 if len (req .AllowedIntegrations ) > 0 {
146146 if _ , ok := configuredIntegrations [req .AllowedIntegrations [0 ]]; ! ok {
147- w .WriteHeader (http .StatusBadRequest )
148- _ , _ = w .Write ([]byte (`{"error":"provider config not found"}` ))
149- return
150- }
147+ w .WriteHeader (http .StatusBadRequest )
148+ _ , _ = w .Write ([]byte (`{"error":"provider config not found"}` ))
149+ return
150+ }
151151 }
152152 w .Header ().Set ("Content-Type" , "application/json" )
153153 w .WriteHeader (http .StatusOK )
@@ -157,6 +157,43 @@ func setupWithNango(t *testing.T) *testEnv {
157157 case r .Method == http .MethodDelete && strings .HasPrefix (r .URL .Path , "/connection/" ):
158158 w .WriteHeader (http .StatusNoContent )
159159
160+ // GET /connections — returns connection records for reconciliation after OAuth.
161+ case r .Method == http .MethodGet && r .URL .Path == "/connections" :
162+ type conn struct {
163+ ConnectionID string `json:"connection_id"`
164+ ProviderConfigKey string `json:"provider_config_key"`
165+ Provider string `json:"provider"`
166+ Tags map [string ]string `json:"tags"`
167+ Created string `json:"created"`
168+ }
169+ connections := []conn {
170+ {
171+ ConnectionID : "mock-connection-github" ,
172+ ProviderConfigKey : "github" ,
173+ Provider : "github" ,
174+ Tags : map [string ]string {"velane_alias" : "default" },
175+ Created : "2026-01-01T00:00:00Z" ,
176+ },
177+ {
178+ ConnectionID : "mock-connection-figma" ,
179+ ProviderConfigKey : "figma" ,
180+ Provider : "figma" ,
181+ Tags : map [string ]string {"velane_alias" : "default" },
182+ Created : "2026-01-01T00:00:00Z" ,
183+ },
184+ }
185+ for key , provider := range configuredIntegrations {
186+ connections = append (connections , conn {
187+ ConnectionID : "mock-connection-" + key ,
188+ ProviderConfigKey : key ,
189+ Provider : provider ,
190+ Created : "2026-01-02T00:00:00Z" ,
191+ })
192+ }
193+ w .Header ().Set ("Content-Type" , "application/json" )
194+ w .WriteHeader (http .StatusOK )
195+ _ = json .NewEncoder (w ).Encode (map [string ]any {"connections" : connections })
196+
160197 // GET /providers — returns a minimal provider list.
161198 case r .Method == http .MethodGet && r .URL .Path == "/providers" :
162199 w .Header ().Set ("Content-Type" , "application/json" )
@@ -279,6 +316,26 @@ func TestConnections_Record(t *testing.T) {
279316 }
280317}
281318
319+ func TestConnections_RecordBackfillsNangoConnectionID (t * testing.T ) {
320+ env := setupWithNango (t )
321+ path := "/v1/tenant/connections"
322+ profile := configureProfile (t , env , "github" , "default" , true )
323+
324+ rec := env .do (t , http .MethodPost , path , env .manageKey , map [string ]any {
325+ "provider" : "github" ,
326+ "credential_profile_id" : profile ["id" ],
327+ })
328+ if rec .Code != http .StatusCreated {
329+ t .Fatalf ("status = %d; want 201\n body: %s" , rec .Code , rec .Body .String ())
330+ }
331+
332+ body := decodeJSON (t , rec )
333+ want := "mock-connection-" + profile ["nango_provider_config_key" ].(string )
334+ if body ["nango_connection_id" ] != want {
335+ t .Errorf ("nango_connection_id = %q; want %q" , body ["nango_connection_id" ], want )
336+ }
337+ }
338+
282339func TestConnections_ListAfterRecord (t * testing.T ) {
283340 env := setupWithNango (t )
284341 path := "/v1/tenant/connections"
0 commit comments