M-8: the bindings verb answers each licence's key (issue 1409)
Each binding the verb bindings answers carries its licence's key beside the §3 fields, as binding.changed does, so the vault's first view matches a token's secret name to the binding without the key form of its own. Builds: design 39 bus-and-switch §17, B10, B25 (hq 128236e7 and after, PR #561) Claude-Session: https://claude.ai/code/session_01NcbgfHb9d4T9nq5Q6WqdiJ
This commit is contained in:
@@ -749,15 +749,17 @@ func Health(l Licence, now time.Time, s Settings) string {
|
||||
return "ok"
|
||||
}
|
||||
|
||||
// BindingsOf is every binding, or the one of consumer when one is named (B10): a list either way, unpaged.
|
||||
// BindingsOf is every binding, or the one of consumer when one is named (B10): a list either way, unpaged, each with
|
||||
// its licence's key beside the §3 fields (B25).
|
||||
func (m *Manager) BindingsOf(ctx context.Context, consumer string) ([]Binding, error) {
|
||||
all, err := m.Store.Bindings(ctx)
|
||||
if err != nil || consumer == "" {
|
||||
return all, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := []Binding{}
|
||||
for _, b := range all {
|
||||
if b.Consumer == consumer {
|
||||
if consumer == "" || b.Consumer == consumer {
|
||||
b.Key = KeyFor(b.Licence)
|
||||
out = append(out, b)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,6 +339,10 @@ func TestCurrentHoldsNoToken(t *testing.T) {
|
||||
if bs, _ := mm.m.BindingsOf(ctx, "laptop"); len(bs) != 1 || bs[0].Consumer != "laptop" {
|
||||
t.Fatalf("bindings of laptop: %v", bs)
|
||||
}
|
||||
// design 39 bus-and-switch B25: the verb bindings answers each binding's licence key beside the §3 fields.
|
||||
if bs, _ := mm.m.BindingsOf(ctx, ""); len(bs) == 0 || bs[0].Key != KeyFor(bs[0].Licence) {
|
||||
t.Fatalf("bindings answered %+v", bs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNothingTheManagerPublishesKeepsOrListsCarriesAToken(t *testing.T) {
|
||||
|
||||
@@ -34,8 +34,10 @@ type Licence struct {
|
||||
// Binding is one consumer's binding (ADR 0206, §3): the licence, kind and generation it should hold, since when, and
|
||||
// why and by whom it was moved last.
|
||||
type Binding struct {
|
||||
Consumer string `json:"consumer"`
|
||||
Licence string `json:"licence"`
|
||||
Consumer string `json:"consumer"`
|
||||
Licence string `json:"licence"`
|
||||
// Key is the licence's key (§10), answered by the verb bindings (B25); the store keeps none.
|
||||
Key string `json:"key,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
Generation int64 `json:"generation"`
|
||||
Since string `json:"since,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user