Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/credential-provider/kubernetes-secrets/statusz.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ args: {{.Args}}</p>
{{end}}
</table>
{{else}}
<p><b>authorization disabled</b> — every namespace is allowed (dev only).</p>
<p><b>no grants</b>: no atespace can resolve Secrets.</p>
{{end}}

<h2>Flags</h2>
Expand Down
15 changes: 15 additions & 0 deletions cmd/credential-provider/kubernetes-secrets/statusz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,18 @@ func TestStatuszHTMLNeverShowsSecret(t *testing.T) {
t.Fatal("statusz HTML leaked a label from a Kubernetes Secret rather than the policy")
}
}

func TestStatuszHTMLNoGrants(t *testing.T) {
authz, err := newNamespaceAuthorizer(namespacePolicyFile{})
if err != nil {
t.Fatalf("newNamespaceAuthorizer: %v", err)
}
rec := httptest.NewRecorder()
newStatuszHandler(NewServer(fake.NewSimpleClientset(), authz, 0))(rec, httptest.NewRequest(http.MethodGet, "/statusz", nil))
if rec.Code != http.StatusOK {
t.Fatalf("status = %d, want 200", rec.Code)
}
if body := rec.Body.String(); !strings.Contains(body, "no atespace can resolve Secrets") {
t.Errorf("HTML page for a policy with no grants does not say every atespace is denied:\n%s", body)
}
}
Loading