(t *testing.T, mux *http.ServeMux, nodeID string, body any)
| 30 | } |
| 31 | |
| 32 | func doEnrollToken(t *testing.T, mux *http.ServeMux, nodeID string, body any) *httptest.ResponseRecorder { |
| 33 | t.Helper() |
| 34 | var r *http.Request |
| 35 | path := "/v1/nodes/" + nodeID + "/enroll-token" |
| 36 | if body == nil { |
| 37 | r = httptest.NewRequest(http.MethodPost, path, nil) |
| 38 | } else { |
| 39 | buf, _ := json.Marshal(body) |
| 40 | r = httptest.NewRequest(http.MethodPost, path, bytes.NewReader(buf)) |
| 41 | r.Header.Set("Content-Type", "application/json") |
| 42 | } |
| 43 | r.Host = "panel.example.com" |
| 44 | w := httptest.NewRecorder() |
| 45 | mux.ServeHTTP(w, r) |
| 46 | return w |
| 47 | } |
| 48 | |
| 49 | func TestNodeEnrollToken_DefaultTTL(t *testing.T) { |
| 50 | store := enrolltokens.NewMemoryStore() |
no test coverage detected