chore: build
ci-api / test (push) Successful in 23m50s
ci-web / test (push) Successful in 13m43s

This commit is contained in:
Xor290
2026-10-04 12:52:16 +02:00
parent 8d857faa45
commit 4bb8c143e2
29 changed files with 2256 additions and 1561 deletions
@@ -25,6 +25,7 @@ func newTestRouter(t *testing.T) (*gin.Engine, *fakeProv) {
r.DELETE("/projects/:id", h.Delete)
r.POST("/projects/:id/extend", h.Extend)
r.GET("/projects/:id/details", h.Details)
r.POST("/projects/:id/domain", h.SetDomain)
return r, prov
}
@@ -135,3 +136,36 @@ func TestHandlerDetails(t *testing.T) {
t.Errorf("erreur cluster : %d %s (500 sans détail interne attendu)", w.Code, w.Body)
}
}
func TestHandlerSetDomain_StatusCodes(t *testing.T) {
r, prov := newTestRouter(t)
w := do(r, "POST", "/projects", body("1"))
var created Project
if err := json.Unmarshal(w.Body.Bytes(), &created); err != nil {
t.Fatal(err)
}
<-prov.provisioned
path := "/projects/" + created.ID + "/domain"
cases := []struct {
name, path, body string
want int
}{
{"valide", path, `{"domain":"boutique.client.fr"}`, http.StatusOK},
{"retrait", path, `{"domain":""}`, http.StatusOK},
{"format invalide", path, `{"domain":"pas un domaine"}`, http.StatusBadRequest},
{"domaine omnex", path, `{"domain":"x.vitrine-omnex.club"}`, http.StatusBadRequest},
{"json invalide", path, `{`, http.StatusBadRequest},
{"projet inconnu", "/projects/inconnu/domain", `{"domain":"a.client.fr"}`, http.StatusNotFound},
}
for _, c := range cases {
if got := do(r, "POST", c.path, c.body); got.Code != c.want {
t.Errorf("%s : %d, attendu %d (%s)", c.name, got.Code, c.want, got.Body)
}
}
prov.domainErr = errors.New("helm: secret interne")
if got := do(r, "POST", path, `{"domain":"boutique.client.fr"}`); got.Code != http.StatusInternalServerError || strings.Contains(got.Body.String(), "secret") {
t.Errorf("erreur cluster : %d %s (500 sans détail interne attendu)", got.Code, got.Body)
}
}