carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package instancectl
2
3import (
4 "context"
5 "net/http"
6 "net/http/httptest"
7 "strings"
8 "testing"
9)
10
11func TestClaimRootRefusesLegacyProcessMutations(t *testing.T) {
12 called := false
13 server := &Server{ClaimStop: http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}), Systemctl: func(context.Context, ...string) (string, error) { called = true; return "", nil }}
14 for _, verb := range []string{"start", "seed", "stop", "reset", "sweep", "cmd"} {
15 response := httptest.NewRecorder()
16 server.Handler().ServeHTTP(response, httptest.NewRequest(http.MethodPost, "/"+verb+"?host=app.example&role=run&memory_max=536870912", strings.NewReader("")))
17 if response.Code != http.StatusServiceUnavailable {
18 t.Fatalf("%s status=%d", verb, response.Code)
19 }
20 }
21 if called {
22 t.Fatal("legacy unit mutation reached systemctl")
23 }
24}
25