feat(tenants): staff may create the "breakpilot" workspace
The slug "breakpilot" was reserved (#32) so no customer could pose as Breakpilot. Sharang decided (12.11.) that the company's own workspace is app.breakpilot.com/breakpilot. Staff (a named staff member on the admin client) may now create exactly this slug; everyone else, and the trial offer's slug choice, still get reserved_slug. The other reserved slugs stay closed to staff too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b28d564867
commit
fb7aea76a9
2 files changed
+33
-2
No files matched your search
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user