mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-14 09:29:07 +02:00
[management] Check a vendor change, and bound the check by one deadline
Two gaps a review surfaced. Moving a record from one catalog provider to another changed neither field the check looked at, so an unchanged credential started being offered to a different vendor, under a different auth header, with nothing asking whether it was accepted there. And each host lookup built its own eight-second budget from a background context, so a slow resolver could spend one before the request spent another, and a caller that gave up was still waiting. Bedrock made that three: it now checks its runtime host as well. One deadline is taken at the top of Fetch and carried through both lookups and the request. The create description also had the exemption backwards, reading as though an upstream the check cannot reach is stored unverified. Unreachable blocks; only what cannot be checked at all is exempt.
This commit is contained in:
@@ -503,3 +503,30 @@ func TestDiscoverProviderModels_FallsBackToTheStoredUrl(t *testing.T) {
|
||||
|
||||
require.Equal(t, stored, f.vendor.only(t).UpstreamURL)
|
||||
}
|
||||
|
||||
// TestUpdateProvider_MovingARecordToAnotherVendorIsChecked covers the edit that
|
||||
// changes neither field the vendor judges and still invalidates both. The
|
||||
// catalog entry decides which vendor is asked and under which auth header, so
|
||||
// the unchanged credential is now being offered somewhere it has never been
|
||||
// accepted.
|
||||
func TestUpdateProvider_MovingARecordToAnotherVendorIsChecked(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
f := newBootstrapFixture(t)
|
||||
f.expectPermission("account1", "user1", modules.AgentNetworkProviders, operations.Create, true)
|
||||
|
||||
created, err := f.manager.CreateProvider(ctx, "user1", newCheckedProvider("account1"))
|
||||
require.NoError(t, err)
|
||||
f.vendor.requests = nil
|
||||
|
||||
f.expectPermission("account1", "user1", modules.AgentNetworkProviders, operations.Update, true)
|
||||
edit := newCheckedProvider("account1")
|
||||
edit.ID = created.ID
|
||||
edit.ProviderID = "anthropic_api"
|
||||
edit.APIKey = ""
|
||||
|
||||
_, err = f.manager.UpdateProvider(ctx, "user1", edit)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, "anthropic_api", f.vendor.only(t).CatalogID,
|
||||
"the new vendor is the one that has to accept the key")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user