Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libraries/authority-core/go/authority/consent.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ func (s *Service) reviewOffer(ctx context.Context, caller Person, org, target st
return refused
}
inst, err := tx.Installation(s.cfg.InstallationID(org, target))
if errors.Is(err, domain.ErrNotFound) && s.cfg.HostInstallsModules {
// A host that installs modules names a module page's
// installation itself, so it is found by its target.
inst, err = installationOf(tx, org, target)
}
if errors.Is(err, domain.ErrNotFound) {
inst, err = domain.Installation{}, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,21 @@ func sameActions(got, want []string) bool {
}
return true
}

// A module page's installation a host names itself is the one its offer
// review reads, as the role holder's capability does.
func TestAHostNamedModulePageInstallationIsReviewed(t *testing.T) {
h := newHostInstalled(t)
if _, err := h.svc.ApplyModule(h.ctx, pageModule(1, true)); err != nil {
t.Fatal(err)
}
if err := h.store.Write(h.ctx, func(tx authority.Tx) error {
return tx.PutInstallation(domain.Installation{ID: "host-pages", Organization: acme, Target: "pages", Status: domain.Active, Revision: 1})
}); err != nil {
t.Fatal(err)
}
offer, err := h.svc.ReviewOffer(h.ctx, authority.Person{ID: "alex", Organization: acme, SessionID: "s"}, acme, "pages")
if err != nil || offer.Installation.ID != "host-pages" || len(offer.Module.Roles) != 2 {
t.Fatalf("the administrator reviews %+v, %v; want the host's installation host-pages", offer.Installation, err)
}
}
Loading