Merge pull request 'feat(tenants): staff may create the "breakpilot" workspace' (#128) from feat/staff-brand-slug into main
ci / shared (push) Successful in 12s
ci / test (push) Successful in 5m53s
ci / image (push) Successful in 37s

This commit was merged in pull request #128.
This commit is contained in:
sharang committed 2026-11-12 17:04:58 +00:00
commit 6789e8053a
2 files changed
+33 -2

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
package server
import (
"net/http"
"strings"
"testing"
)
func TestCreateTenant_brandSlugOnlyForStaff(t *testing.T) {
f := newTeamFixture(t, portal, "portal-svc:*")
staff := map[string]string{"X-Staff-Subject": "staff-1", "X-Staff-Email": "staff@breakpilot.test"}
// without a named staff member: reserved like any platform path
if code, _, raw := f.call(t, "POST", "/v1/tenants", `{"slug":"breakpilot","name":"Breakpilot GmbH"}`, nil); code != http.StatusBadRequest || !strings.Contains(string(raw), "reserved_slug") {
t.Fatalf("non-staff: %d %s", code, raw)
}
// staff may not take other reserved slugs
if code, _, raw := f.call(t, "POST", "/v1/tenants", `{"slug":"admin","name":"Shadow"}`, staff); code != http.StatusBadRequest || !strings.Contains(string(raw), "reserved_slug") {
t.Fatalf("staff, admin: %d %s", code, raw)
}
// staff may create the company's own workspace
if code, _, raw := f.call(t, "POST", "/v1/tenants", `{"slug":"breakpilot","name":"Breakpilot GmbH"}`, staff); code != http.StatusCreated {
t.Fatalf("staff, breakpilot: %d %s", code, raw)
}
}
+9 -2
View File
@@ -30,6 +30,11 @@ var reservedSlugs = map[string]bool{
"datenschutz": true, "privacy": true, "impressum": true, "testbedingungen": true,
}
// staffOnlySlugs are reserved for everyone but Breakpilot staff: the company's own
// workspace is app.breakpilot.com/breakpilot (Sharang's decision, 12.11.2026), while no
// customer and no trial offer may take the name (the trial's freeSlug still skips it).
var staffOnlySlugs = map[string]bool{"breakpilot": true}
type createTenantReq struct {
Slug string `json:"slug"`
Name string `json:"name"`
@@ -65,8 +70,10 @@ func (s *Server) createTenant(w http.ResponseWriter, r *http.Request) {
return
}
if reservedSlugs[in.Slug] {
writeError(w, http.StatusBadRequest, "reserved_slug", "this slug is reserved for a platform path")
return
if _, _, staff := s.staffActor(r); !staff || !staffOnlySlugs[in.Slug] {
writeError(w, http.StatusBadRequest, "reserved_slug", "this slug is reserved for a platform path")
return
}
}
if in.Name == "" || len(in.Name) > 255 {
writeError(w, http.StatusBadRequest, "invalid_name", "name must be 1..255 chars")