give: test that a trusted party's secret given at the terminal is announced before it is kept, and refuse an unknown machine before anybody types
The terminal path's order is one function, keepGiven, so the test fails when the announcement before a trusted party's secret is removed, and when a failed announcement still keeps it. give also refuses a machine the mesh does not know, as the secret's or as the desk, before the prompt (the final review).
This commit is contained in:
@@ -115,20 +115,18 @@ func secretCommand(ctx context.Context, args []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if trusted {
|
||||
if err := announceSecretGiven(ctx, node, module, name, "at the controller's terminal"); err != nil {
|
||||
untilStart, unannounced, err := keepGiven(trusted,
|
||||
func() error { return announceSecretGiven(ctx, node, module, name, "at the controller's terminal") },
|
||||
func() (bool, error) { return open.inventory.AcceptGivenSecret(ctx, node, module, name, value) })
|
||||
if err != nil {
|
||||
if trusted && unannounced != nil {
|
||||
return fmt.Errorf("%s runs as an account of its own, and the change of its %s could not be announced on "+
|
||||
"your channels first, so nothing was kept: %w", module, name, err)
|
||||
}
|
||||
}
|
||||
untilStart, err := open.inventory.AcceptGivenSecret(ctx, node, module, name, value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !trusted {
|
||||
if err := announceSecretGiven(ctx, node, module, name, "at the controller's terminal"); err != nil {
|
||||
fmt.Printf(" this change could NOT be announced on the operator's channels: %v\n", err)
|
||||
}
|
||||
if unannounced != nil {
|
||||
fmt.Printf(" this change could NOT be announced on the operator's channels: %v\n", unannounced)
|
||||
}
|
||||
// Not printed back, and there is nowhere it could be printed from: it is sealed to that
|
||||
// machine and the mesh cannot read it again.
|
||||
@@ -487,3 +485,23 @@ func whoAsked() string {
|
||||
}
|
||||
return "the mesh"
|
||||
}
|
||||
|
||||
// keepGiven keeps a value given at the controller's terminal, and announces it on the operator's channels
|
||||
// (the confirmation review of 2026-10-09, N1-give). **A trusted party's — a module running as an account of its
|
||||
// own: the router, a verified channel — is announced before it is kept, and not kept when the announcement
|
||||
// fails**: a channel whose token changed unheard of answers for somebody else. Any other module's is kept first
|
||||
// and announced after, and a failed announcement is said (unannounced) without undoing it.
|
||||
func keepGiven(trusted bool, announce func() error, keep func() (bool, error)) (untilStart bool, unannounced, err error) {
|
||||
if trusted {
|
||||
if err := announce(); err != nil {
|
||||
return false, err, err
|
||||
}
|
||||
untilStart, err = keep()
|
||||
return untilStart, nil, err
|
||||
}
|
||||
untilStart, err = keep()
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
return untilStart, announce(), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user