mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-16 19:49:56 +00:00
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.
31 lines
911 B
Go
31 lines
911 B
Go
//go:build e2e
|
|
|
|
package agentnetwork
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// 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 := context.Background()
|
|
|
|
require.NotEmpty(t, srv.PAT, "TestMain must have minted an admin PAT")
|
|
|
|
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")
|
|
|
|
var emails []string
|
|
for _, u := range users {
|
|
emails = append(emails, u.Email)
|
|
}
|
|
assert.Contains(t, emails, "admin@netbird.test", "the bootstrapped owner should appear in the users list")
|
|
}
|