S17/S18: send success and failure routes; Sphinx HTML/PDF
Python router + Go sm-leaf reject missing to, empty ct, plaintext body. Summary logs never include ciphertext. MODULE.md.
This commit is contained in:
parent
f4da7ff446
commit
43cbf51d3e
75 changed files with 14878 additions and 9 deletions
|
|
@ -56,19 +56,78 @@ func TestSMSubjectsAck(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
defer n.Shutdown()
|
||||
cases := map[string]string{
|
||||
"verae.sm.send": `{"accepted":true}`,
|
||||
good := []byte(`{"to":"npe.inbox.x","alg":"lab-xor","ct":"abcd","from_lookup_id":"lid-good"}`)
|
||||
msg, err := n.nc.Request("verae.sm.send", good, time.Second)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var ack map[string]any
|
||||
if err := json.Unmarshal(msg.Data, &ack); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if ack["accepted"] != true || ack["lookup_id"] != "lid-good" {
|
||||
t.Fatalf("good send %s", msg.Data)
|
||||
}
|
||||
for subj, want := range map[string]string{
|
||||
"verae.sm.dead": `{"queued":true}`,
|
||||
"verae.sm.error": `{"emitted":true}`,
|
||||
"verae.sm.log.summary": `{"logged":true}`,
|
||||
}
|
||||
for subj, want := range cases {
|
||||
msg, err := n.nc.Request(subj, []byte(`{"lookup_id":"t"}`), time.Second)
|
||||
} {
|
||||
got, err := n.nc.Request(subj, []byte(`{"lookup_id":"t","error_code":"x","dest_class":"mailbox"}`), time.Second)
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", subj, err)
|
||||
}
|
||||
if string(msg.Data) != want {
|
||||
t.Fatalf("%s got %s want %s", subj, msg.Data, want)
|
||||
if string(got.Data) != want {
|
||||
t.Fatalf("%s got %s want %s", subj, got.Data, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSMSendRejectsMissingTo(t *testing.T) {
|
||||
n, err := Start("")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer n.Shutdown()
|
||||
msg, err := n.nc.Request("verae.sm.send", []byte(`{"alg":"lab-xor","ct":"ab"}`), time.Second)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var ack map[string]any
|
||||
_ = json.Unmarshal(msg.Data, &ack)
|
||||
if ack["accepted"] != false || ack["error_code"] != "SM-MISSING-TO" {
|
||||
t.Fatalf("missing to %s", msg.Data)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSMSendRejectsEmptyCiphertext(t *testing.T) {
|
||||
n, err := Start("")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer n.Shutdown()
|
||||
msg, err := n.nc.Request("verae.sm.send", []byte(`{"to":"npe.inbox.x","alg":"lab-xor","ct":""}`), time.Second)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var ack map[string]any
|
||||
_ = json.Unmarshal(msg.Data, &ack)
|
||||
if ack["accepted"] != false || ack["error_code"] != "SM-EMPTY-CT" {
|
||||
t.Fatalf("empty ct %s", msg.Data)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSMSummaryRejectsCiphertextField(t *testing.T) {
|
||||
n, err := Start("")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer n.Shutdown()
|
||||
msg, err := n.nc.Request("verae.sm.log.summary", []byte(`{"error_code":"x","ct":"secret"}`), time.Second)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(msg.Data) == `{"logged":true}` {
|
||||
t.Fatal("must not log body-like fields")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue