[e2e] Add management-side agent-network scenarios (Pillar 2)

Port the API-driven agent-network scenarios from the bash suites to Go,
sharing one combined server per package run (TestMain) with each test
owning its resource cleanup. Drives the /api/agent-network/* endpoints
through the shared REST client's NewRequest primitive with the generated
api types.

Scenarios:
- provider lifecycle (create/get/list/delete + 404 after delete)
- provider validation (missing api_key, unknown catalog id → 4xx)
- settings collection-toggle round-trip with cluster/subdomain immutability
- policy window floor (reject <60s enabled limit, accept at 60s)
- consumption read endpoint returns an array

All deterministic and dependency-free (dummy provider keys; no upstream
calls), so they run headless in CI.
This commit is contained in:
mlsmaycon
2026-06-28 18:56:54 +02:00
parent 4a296c5338
commit d9d437339c
4 changed files with 321 additions and 18 deletions
+5 -18
View File
@@ -5,32 +5,19 @@ package agentnetwork
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/netbirdio/netbird/e2e/harness"
)
// TestCombinedBootstrap proves Pillar 1: a combined NetBird server comes up in a
// container, the /api/setup bootstrap mints an admin PAT with no OIDC, and that
// PAT authenticates real management API calls through the typed REST client.
// TestCombinedBootstrap proves Pillar 1: the shared combined server came up and
// the /api/setup-minted PAT authenticates a real management API call through
// the typed REST client (the bootstrap itself ran in TestMain).
func TestCombinedBootstrap(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()
ctx := context.Background()
srv, err := harness.StartCombined(ctx)
require.NoError(t, err, "combined server must build and start")
t.Cleanup(func() {
_ = srv.Terminate(context.Background())
})
require.NotEmpty(t, srv.PAT, "TestMain must have minted an admin PAT")
pat, err := srv.Bootstrap(ctx)
require.NoError(t, err, "/api/setup must mint an admin PAT")
require.NotEmpty(t, pat, "PAT must be non-empty")
// The PAT must authenticate a real management API call through the client.
users, err := srv.API().Users.List(ctx)
require.NoError(t, err, "authenticated Users.List must round-trip")
require.NotEmpty(t, users, "the bootstrapped account must have at least one user")