mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-10 02:25:56 +00:00
Match secure runtime revoke protocol
This commit is contained in:
@@ -549,7 +549,7 @@ func (f *secureRuntimeLabFixture) handleActionRunnerSelfRevoke(w http.ResponseWr
|
||||
return
|
||||
}
|
||||
f.actionServer.InvalidateActionRunnerSession(admission)
|
||||
writeSecureRuntimeJSON(w, http.StatusOK, map[string]any{"success": true})
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func (f *secureRuntimeLabFixture) handleReport(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -1086,6 +1086,23 @@ func TestSecureRuntimeFixtureAcceptsBearerOnlyCollectorLifecycleLookup(t *testin
|
||||
}
|
||||
}
|
||||
|
||||
func TestSecureRuntimeFixtureSelfRevokeUsesBodylessNoContentResponse(t *testing.T) {
|
||||
fixture := newSecureRuntimeLabFixture(nil, "", nil, nil, "fixture")
|
||||
defer fixture.actionServer.Shutdown()
|
||||
body := fmt.Sprintf(`{"agentId":%q,"hostname":%q}`, secureRuntimeLabAgentID, secureRuntimeLabHostname)
|
||||
request := httptest.NewRequest(http.MethodDelete, "/api/agents/action-runner/credential", strings.NewReader(body))
|
||||
request.Header.Set("Authorization", "Bearer "+secureRuntimeRunnerSecretV1)
|
||||
recorder := httptest.NewRecorder()
|
||||
fixture.ServeHTTP(recorder, request)
|
||||
if recorder.Code != http.StatusNoContent || recorder.Body.Len() != 0 {
|
||||
t.Fatalf("self-revoke response = status %d body %q, want bodyless 204", recorder.Code, recorder.Body.String())
|
||||
}
|
||||
_, revoked, revokeCount := fixture.actionSnapshot()
|
||||
if !revoked || revokeCount != 1 {
|
||||
t.Fatalf("self-revoke state = revoked:%t count:%d", revoked, revokeCount)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSecureRuntimeSystemdLab(t *testing.T) {
|
||||
if os.Getenv(secureRuntimeLabOptIn) != "1" {
|
||||
t.Skip("set PULSE_SECURE_RUNTIME_SYSTEMD_LAB=1 only inside a disposable systemd VM")
|
||||
|
||||
Reference in New Issue
Block a user