Skip to content

Commit 131d003

Browse files
mjudeikisclaude
andcommitted
test(e2e): serve with the init-minted SA kubeconfig, not admin
Review feedback: running serve with the kcp admin kubeconfig bypasses the init/serve split's RBAC — the suite would mask permission regressions in the controller chain. init already mints the workspace-scoped ServiceAccount kubeconfig; serve now uses it, exactly like the chart's serve container. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 0c6d5a4 commit 131d003

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

test/e2e/suites/infraprovider/main_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,15 @@ func TestMain(m *testing.M) {
152152

153153
// Bootstrap: `infrastructure-provider init` installs the CRDs, APIExport,
154154
// CachedResource and seeds the templates (mirrors the chart init
155-
// container / `make init-provider-infrastructure`).
155+
// container / `make init-provider-infrastructure`). It also mints the
156+
// workspace-scoped ServiceAccount kubeconfig serve runs with.
157+
mintedKubeconfig := filepath.Join(dataDir, "infrastructure.kubeconfig")
156158
initLog, _ := os.Create(filepath.Join(dataDir, "init.log"))
157159
initCmd := exec.Command(filepath.Join(repoRoot, "bin", "infrastructure-provider"), "init")
158160
initCmd.Env = append(os.Environ(),
159161
"INFRASTRUCTURE_ADMIN_KUBECONFIG="+adminKubeconfig,
160162
"INFRASTRUCTURE_WORKSPACE_PATH="+workspacePath,
161-
// Keep init off the runtime-cluster steps — no kro in this suite.
162-
"INFRASTRUCTURE_KUBECONFIG="+filepath.Join(dataDir, "infrastructure.kubeconfig"),
163+
"INFRASTRUCTURE_KUBECONFIG="+mintedKubeconfig,
163164
)
164165
initCmd.Stdout = initLog
165166
initCmd.Stderr = initLog
@@ -170,8 +171,9 @@ func TestMain(m *testing.M) {
170171
}
171172

172173
// Serve: REST + MCP + the Template controller (stub backend only — no
173-
// KRO_KUBECONFIG). The admin kubeconfig is retargeted at the provider
174-
// workspace via INFRASTRUCTURE_WORKSPACE_PATH, same as the operator flow.
174+
// KRO_KUBECONFIG). Runs with the SA kubeconfig init minted — NOT the
175+
// admin one — so the suite exercises the RBAC init actually granted,
176+
// exactly like the chart's serve container.
175177
provLog, _ := os.Create(filepath.Join(dataDir, "provider.log"))
176178
provCmd = exec.Command(filepath.Join(repoRoot, "bin", "infrastructure-provider"))
177179
provCmd.Env = append(os.Environ(),
@@ -180,8 +182,7 @@ func TestMain(m *testing.M) {
180182
"KEDGE_HUB_TOKEN="+staticToken,
181183
"KEDGE_HUB_INSECURE=true",
182184
"KEDGE_PROVIDER_NAME=infrastructure",
183-
"INFRASTRUCTURE_KUBECONFIG="+adminKubeconfig,
184-
"INFRASTRUCTURE_WORKSPACE_PATH="+workspacePath,
185+
"INFRASTRUCTURE_KUBECONFIG="+mintedKubeconfig,
185186
)
186187
provCmd.Stdout = provLog
187188
provCmd.Stderr = provLog

0 commit comments

Comments
 (0)