Registry becomes the entitlement authority (ERP/02, PRODUCT_INTEGRATION_SPEC 2.0):
- migrations 0002/0003: ladder statuses warning|restricted|halted on
tenant_status; products table replaces the hard-coded catalog, seeded with
pruefwerk (+ werkbank add-on), werkpilot, firmwerk; compliance disabled
until the dsms migration (M-MIG-9)
- GET /v1/tenants (keyset pagination, status/kind filters) for product
schedulers and reconcile jobs
- POST /v1/internal/entitlements/check → {allowed, read_only, status, limits,
expires_at, reason}; add-on limits from tenant_products.config
- POST /v1/tenants/{id}/status — the single ladder transition endpoint;
cancel now moves to halted; activate accepts products[] with limits and
provisions them via the catalog's per-env provision_urls
- SyncTenantStatus: coarse tenant_status attribute on every Keycloak org
member after every status change (attributes merged, roles untouched)
- AUTHZ_RULES: per-client (JWT azp) route groups; 403 FORBIDDEN_CLIENT
- INVITE_CLIENT_ID / INVITE_REDIRECT_URI replace the hard-coded dev-portal
invite parameters
- catalog entries carry type, launch_url (per APP_ENV), skus, addons,
trial_days; openapi.yaml + README updated
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
33 lines
1.3 KiB
Go
33 lines
1.3 KiB
Go
package server
|
|
|
|
import "testing"
|
|
|
|
func TestAuthzRules(t *testing.T) {
|
|
a := ParseAuthzRules(" portal-svc:tenants,catalog,api-keys,audit,users ; pruefwerk-svc:entitlements,tenants.read,api-keys.verify,audit.write; root:* ;broken")
|
|
cases := []struct {
|
|
azp, method, path string
|
|
want bool
|
|
}{
|
|
{"portal-svc", "POST", "/v1/tenants", true},
|
|
{"portal-svc", "GET", "/v1/tenants/by-slug/acme", true},
|
|
{"portal-svc", "POST", "/v1/internal/entitlements/check", false},
|
|
{"pruefwerk-svc", "POST", "/v1/internal/entitlements/check", true},
|
|
{"pruefwerk-svc", "GET", "/v1/tenants", true},
|
|
{"pruefwerk-svc", "POST", "/v1/tenants", false},
|
|
{"pruefwerk-svc", "POST", "/v1/internal/api-keys/verify", true},
|
|
{"pruefwerk-svc", "POST", "/v1/api-keys", false},
|
|
{"pruefwerk-svc", "POST", "/v1/audit", true},
|
|
{"pruefwerk-svc", "GET", "/v1/audit", false},
|
|
{"root", "DELETE", "/v1/api-keys/x", true},
|
|
{"unknown", "GET", "/v1/catalog", false},
|
|
}
|
|
for _, c := range cases {
|
|
if got := a.Allowed(c.azp, routeGroup(c.method, c.path)); got != c.want {
|
|
t.Errorf("%s %s %s: got %v want %v", c.azp, c.method, c.path, got, c.want)
|
|
}
|
|
}
|
|
if ParseAuthzRules("") != nil || !(*Authz)(nil).Allowed("anyone", "tenants.write") {
|
|
t.Errorf("empty rules must allow everything")
|
|
}
|
|
}
|