No client names the holder of the seat mesh-provisioner: each reader keeps its own constant, held to its manifest (ADR 0625 section 4, issue 1966)
Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
@@ -49,7 +49,7 @@ func noOpPlan(bus *bucketBus, node, module string) {
|
||||
// keycloak on novox the key the seat composes, asked (novox/hq ADR 0570 clauses 1 to 3).
|
||||
func seatPlan(bus *bucketBus, node, module string, plan map[string]any) {
|
||||
raw, _ := json.Marshal(map[string]any{"v": 1, "node": node, "module": module, "plan": plan})
|
||||
_ = bus.Put(ctx, meshprovisionerclient.PlansBucket, node+"."+module, raw)
|
||||
_ = bus.Put(ctx, meshprovisionerclient.PlansBucketOf(provisionerModule), node+"."+module, raw)
|
||||
list, _ := plan["provisions"].([]any)
|
||||
for _, e := range list {
|
||||
entry := e.(map[string]any)
|
||||
@@ -64,7 +64,7 @@ func seatPlan(bus *bucketBus, node, module string, plan map[string]any) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_ = bus.Put(ctx, meshprovisionerclient.ProvisionsBucket, key, asked)
|
||||
_ = bus.Put(ctx, meshprovisionerclient.ProvisionsBucketOf(provisionerModule), key, asked)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ func movedWorld(t *testing.T, h *harness.Harness) (f *fakeKeycloak, start func()
|
||||
}
|
||||
bus := &bucketBus{buckets: map[string]map[string][]byte{}}
|
||||
noOpPlan(bus, "elsewhere", "unrelated")
|
||||
p := provider.New(provider.Options{Node: h.Node, Module: "keycloak", Bus: bus,
|
||||
p := provider.New(provider.Options{Provisioner: provisionerModule, Node: h.Node, Module: "keycloak", Bus: bus,
|
||||
Vault: provider.ConsumersFile{Paths: []string{consumersFile}},
|
||||
Offers: map[string]provider.Offer{ProvisionName: {Credential: provider.PerConsumer, Serves: servedValues(testIssuer)}},
|
||||
Make: run.Make, Gone: run.Gone, Every: h.Every, Logf: func(string, ...any) {}})
|
||||
|
||||
@@ -50,9 +50,13 @@ func valuesOf(e provider.Entry) map[string]any {
|
||||
// them. Each client it gives is made and checked by the harness's grant pass exactly as on the grant path; a client
|
||||
// a plan names is the helper's alone.
|
||||
func moved(consumersFile string, h *harness.Harness, issuer string) (*harness.Moved, *provider.Provider, provider.Bus, error) {
|
||||
return harness.NewMoved(consumersFile, h, harness.MovedSpec{Module: "keycloak", Provision: ProvisionName,
|
||||
return harness.NewMoved(consumersFile, h, harness.MovedSpec{Module: "keycloak", Provisioner: provisionerModule, Provision: ProvisionName,
|
||||
Offer: provider.Offer{Credential: provider.PerConsumer, Serves: servedValues(issuer)},
|
||||
Login: func(e provider.Entry) string { return e.As },
|
||||
Values: valuesOf,
|
||||
Noun: "client id", Made: "client", Backend: "Keycloak", WithGrants: true})
|
||||
}
|
||||
|
||||
// provisionerModule is the holder of the seat mesh-provisioner, named from this module's manifest (its `reads` of plans and
|
||||
// provisions; TestTheProvisionerIsTheManifests).
|
||||
const provisionerModule = "mesh-provisioner"
|
||||
|
||||
@@ -158,7 +158,7 @@ func TestBothPathsLeaveTheSameClientInKeycloak(t *testing.T) {
|
||||
seatPlan(bus, "home", "grafana", map[string]any{
|
||||
"provisions": []any{map[string]any{"provision": ProvisionName, "provider": "novox",
|
||||
"provider-module": "keycloak", "contributes": grafanaContributes, "names": grafanaNames}}})
|
||||
pr := provider.New(provider.Options{Node: "novox", Module: "keycloak", Bus: bus,
|
||||
pr := provider.New(provider.Options{Provisioner: provisionerModule, Node: "novox", Module: "keycloak", Bus: bus,
|
||||
Vault: provider.ConsumersFile{Paths: []string{file}},
|
||||
Offers: map[string]provider.Offer{ProvisionName: {Credential: provider.PerConsumer,
|
||||
Serves: servedValues(testIssuer)}},
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// The module holding the seat mesh-provisioner, which this provider reads the plans and provisions of, is the one its manifest's
|
||||
// `reads` name: no client names a holder (novox/hq ADR 0625 §4).
|
||||
func TestTheProvisionerIsTheManifests(t *testing.T) {
|
||||
raw, err := os.ReadFile("../../module.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var m struct {
|
||||
Reads []string `json:"reads"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, state := range []string{"plans", "provisions"} {
|
||||
if !slices.Contains(m.Reads, provisionerModule+"."+state) {
|
||||
t.Errorf("the provider reads %s.%s, its manifest's reads are %v", provisionerModule, state, m.Reads)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user