Name no node in minio's and mailu's fixtures (issue 1838)

This commit is contained in:
jochen
2026-10-22 21:42:46 +02:00
parent 3209cfa6fb
commit 4b50f5171b
29 changed files with 73 additions and 73 deletions
+9 -9
View File
@@ -14,13 +14,13 @@ import (
"testing"
)
// The environment mailu gives automx on novox when the fixtures were captured (files/mailu.env): the mail domain,
// The environment mailu gives automx on node-c when the fixtures were captured (files/mailu.env): the mail domain,
// the route name for both servers, the ports.
var capturedEnvironment = map[string]string{
"AMX_MAIL_DOMAINS": "novox.be",
"AMX_IMAP_ADDRESS": "mail.novox.be",
"AMX_MAIL_DOMAINS": "node-c.be",
"AMX_IMAP_ADDRESS": "mail.node-c.be",
"AMX_IMAP_PORT": "143",
"AMX_SMTP_ADDRESS": "mail.novox.be",
"AMX_SMTP_ADDRESS": "mail.node-c.be",
"AMX_SMTP_PORT": "587",
"AUTOMX_PORT": "4243",
}
@@ -176,7 +176,7 @@ func TestTheOnlyCorrectedAnswerIsTheImapServersName(t *testing.T) {
}
for _, c := range corrected {
orig := readFile(t, strings.TrimSuffix(c, ".corrected.body")+".body")
want := strings.Replace(orig, "<hostname />", "<hostname>mail.novox.be</hostname>", 1)
want := strings.Replace(orig, "<hostname />", "<hostname>mail.node-c.be</hostname>", 1)
if strings.Contains(want, "<hostname />") || want == orig {
t.Fatalf("%s: the capture has no single empty hostname to correct", c)
}
@@ -198,12 +198,12 @@ func TestTheImapServerIsNamedFromTheImapAddress(t *testing.T) {
t.Fatal(err)
}
rec := httptest.NewRecorder()
newHandler(cfg).ServeHTTP(rec, httptest.NewRequest("GET", "/mail/config-v1.1.xml?emailaddress=a@novox.be", nil))
newHandler(cfg).ServeHTTP(rec, httptest.NewRequest("GET", "/mail/config-v1.1.xml?emailaddress=a@node-c.be", nil))
body := rec.Body.String()
if !strings.Contains(body, `<incomingServer type="imap"><hostname>imap.example.test</hostname><port>993</port>`) {
t.Errorf("incoming server not named from AMX_IMAP_ADDRESS and AMX_IMAP_PORT: %s", body)
}
if !strings.Contains(body, `<outgoingServer type="smtp"><hostname>mail.novox.be</hostname><port>587</port>`) {
if !strings.Contains(body, `<outgoingServer type="smtp"><hostname>mail.node-c.be</hostname><port>587</port>`) {
t.Errorf("outgoing server changed: %s", body)
}
}
@@ -213,13 +213,13 @@ func TestEveryDomainOfTheEnvironmentIsServed(t *testing.T) {
for k, v := range capturedEnvironment {
env[k] = v
}
env["AMX_MAIL_DOMAINS"] = "novox.be, example.test"
env["AMX_MAIL_DOMAINS"] = "node-c.be, example.test"
cfg, err := configFrom(getenvOf(env))
if err != nil {
t.Fatal(err)
}
h := newHandler(cfg)
for _, d := range []string{"novox.be", "example.test"} {
for _, d := range []string{"node-c.be", "example.test"} {
rec := httptest.NewRecorder()
h.ServeHTTP(rec, httptest.NewRequest("GET", "/mail/config-v1.1.xml?emailaddress=a@"+d, nil))
if rec.Code != 200 || !strings.Contains(rec.Body.String(), "<domain>"+d+"</domain>") {
@@ -1 +1 @@
<clientConfig version="1.1"><emailProvider id="automx2-1"><identity /><domain>novox.be</domain><displayName>novox.be</displayName><displayShortName>novox.be</displayShortName><incomingServer type="imap"><hostname /><port>143</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></incomingServer><outgoingServer type="smtp"><hostname>mail.novox.be</hostname><port>587</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></outgoingServer></emailProvider></clientConfig>
<clientConfig version="1.1"><emailProvider id="automx2-1"><identity /><domain>node-c.be</domain><displayName>node-c.be</displayName><displayShortName>node-c.be</displayShortName><incomingServer type="imap"><hostname /><port>143</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></incomingServer><outgoingServer type="smtp"><hostname>mail.node-c.be</hostname><port>587</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></outgoingServer></emailProvider></clientConfig>
@@ -1 +1 @@
<clientConfig version="1.1"><emailProvider id="automx2-1"><identity /><domain>novox.be</domain><displayName>novox.be</displayName><displayShortName>novox.be</displayShortName><incomingServer type="imap"><hostname>mail.novox.be</hostname><port>143</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></incomingServer><outgoingServer type="smtp"><hostname>mail.novox.be</hostname><port>587</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></outgoingServer></emailProvider></clientConfig>
<clientConfig version="1.1"><emailProvider id="automx2-1"><identity /><domain>node-c.be</domain><displayName>node-c.be</displayName><displayShortName>node-c.be</displayShortName><incomingServer type="imap"><hostname>mail.node-c.be</hostname><port>143</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></incomingServer><outgoingServer type="smtp"><hostname>mail.node-c.be</hostname><port>587</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></outgoingServer></emailProvider></clientConfig>
@@ -1,3 +1,3 @@
GET https://autoconfig.novox.be/mail/config-v1.1.xml?emailaddress=jochen@novox.be
GET https://autoconfig.node-c.be/mail/config-v1.1.xml?emailaddress=jochen@node-c.be
User-Agent: Thunderbird
Accept: */*
@@ -1 +1 @@
<clientConfig version="1.1"><emailProvider id="automx2-1"><identity /><domain>novox.be</domain><displayName>novox.be</displayName><displayShortName>novox.be</displayShortName><incomingServer type="imap"><hostname /><port>143</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></incomingServer><outgoingServer type="smtp"><hostname>mail.novox.be</hostname><port>587</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></outgoingServer></emailProvider></clientConfig>
<clientConfig version="1.1"><emailProvider id="automx2-1"><identity /><domain>node-c.be</domain><displayName>node-c.be</displayName><displayShortName>node-c.be</displayShortName><incomingServer type="imap"><hostname /><port>143</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></incomingServer><outgoingServer type="smtp"><hostname>mail.node-c.be</hostname><port>587</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></outgoingServer></emailProvider></clientConfig>
@@ -1 +1 @@
<clientConfig version="1.1"><emailProvider id="automx2-1"><identity /><domain>novox.be</domain><displayName>novox.be</displayName><displayShortName>novox.be</displayShortName><incomingServer type="imap"><hostname>mail.novox.be</hostname><port>143</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></incomingServer><outgoingServer type="smtp"><hostname>mail.novox.be</hostname><port>587</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></outgoingServer></emailProvider></clientConfig>
<clientConfig version="1.1"><emailProvider id="automx2-1"><identity /><domain>node-c.be</domain><displayName>node-c.be</displayName><displayShortName>node-c.be</displayShortName><incomingServer type="imap"><hostname>mail.node-c.be</hostname><port>143</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></incomingServer><outgoingServer type="smtp"><hostname>mail.node-c.be</hostname><port>587</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></outgoingServer></emailProvider></clientConfig>
@@ -1,2 +1,2 @@
GET https://automx.novox.be/mail/config-v1.1.xml?emailaddress=jochen@novox.be
GET https://automx.node-c.be/mail/config-v1.1.xml?emailaddress=jochen@node-c.be
User-Agent: Thunderbird
@@ -1 +1 @@
<clientConfig version="1.1"><emailProvider id="automx2-1"><identity /><domain>novox.be</domain><displayName>novox.be</displayName><displayShortName>novox.be</displayShortName><incomingServer type="imap"><hostname /><port>143</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></incomingServer><outgoingServer type="smtp"><hostname>mail.novox.be</hostname><port>587</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></outgoingServer></emailProvider></clientConfig>
<clientConfig version="1.1"><emailProvider id="automx2-1"><identity /><domain>node-c.be</domain><displayName>node-c.be</displayName><displayShortName>node-c.be</displayShortName><incomingServer type="imap"><hostname /><port>143</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></incomingServer><outgoingServer type="smtp"><hostname>mail.node-c.be</hostname><port>587</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></outgoingServer></emailProvider></clientConfig>
@@ -1 +1 @@
<clientConfig version="1.1"><emailProvider id="automx2-1"><identity /><domain>novox.be</domain><displayName>novox.be</displayName><displayShortName>novox.be</displayShortName><incomingServer type="imap"><hostname>mail.novox.be</hostname><port>143</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></incomingServer><outgoingServer type="smtp"><hostname>mail.novox.be</hostname><port>587</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></outgoingServer></emailProvider></clientConfig>
<clientConfig version="1.1"><emailProvider id="automx2-1"><identity /><domain>node-c.be</domain><displayName>node-c.be</displayName><displayShortName>node-c.be</displayShortName><incomingServer type="imap"><hostname>mail.node-c.be</hostname><port>143</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></incomingServer><outgoingServer type="smtp"><hostname>mail.node-c.be</hostname><port>587</port><socketType>STARTTLS</socketType><username>%EMAILADDRESS%</username><authentication>password-cleartext</authentication></outgoingServer></emailProvider></clientConfig>
@@ -1,2 +1,2 @@
GET https://autodiscover.novox.be/mail/config-v1.1.xml?emailaddress=jochen@novox.be
GET https://autodiscover.node-c.be/mail/config-v1.1.xml?emailaddress=jochen@node-c.be
User-Agent: Thunderbird
@@ -1,2 +1,2 @@
GET https://autoconfig.novox.be/mail/config-v1.1.xml?emailaddress=nobody@unknown.example
GET https://autoconfig.node-c.be/mail/config-v1.1.xml?emailaddress=nobody@unknown.example
User-Agent: Thunderbird
@@ -1,2 +1,2 @@
GET https://autoconfig.novox.be/mail/config-v1.1.xml
GET https://autoconfig.node-c.be/mail/config-v1.1.xml
User-Agent: Thunderbird
@@ -1,2 +1,2 @@
GET https://autoconfig.novox.be/
GET https://autoconfig.node-c.be/
User-Agent: Mozilla/5.0
@@ -1 +1 @@
GET https://autoconfig.novox.be/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=jochen@novox.be
GET https://autoconfig.node-c.be/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=jochen@node-c.be
@@ -1,4 +1,4 @@
POST https://autodiscover.novox.be/autodiscover/autodiscover.xml
POST https://autodiscover.node-c.be/autodiscover/autodiscover.xml
User-Agent: Microsoft Office/16.0 (Windows NT 10.0; Microsoft Outlook 16.0.14326; Pro)
Content-Type: text/xml
Accept: */*
@@ -6,7 +6,7 @@ Accept: */*
<?xml version="1.0" encoding="utf-8"?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006">
<Request>
<EMailAddress>jochen@novox.be</EMailAddress>
<EMailAddress>jochen@node-c.be</EMailAddress>
<AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema>
</Request>
</Autodiscover>
@@ -1,4 +1,4 @@
POST https://autodiscover.novox.be/autodiscover/autodiscover.xml
POST https://autodiscover.node-c.be/autodiscover/autodiscover.xml
User-Agent: Microsoft Office/16.0
Content-Type: text/xml
@@ -1,4 +1,4 @@
POST https://autodiscover.novox.be/autodiscover/autodiscover.xml
POST https://autodiscover.node-c.be/autodiscover/autodiscover.xml
User-Agent: Microsoft Office/16.0
Content-Type: text/xml
@@ -1,4 +1,4 @@
POST https://autodiscover.novox.be/autodiscover/autodiscover.xml
POST https://autodiscover.node-c.be/autodiscover/autodiscover.xml
User-Agent: Microsoft Office/16.0
Content-Type: text/xml
@@ -1,2 +1,2 @@
GET https://autodiscover.novox.be/autodiscover/autodiscover.xml
GET https://autodiscover.node-c.be/autodiscover/autodiscover.xml
User-Agent: Microsoft Office/16.0
@@ -1,6 +1,6 @@
POST https://autodiscover.novox.be/Autodiscover/Autodiscover.xml
POST https://autodiscover.node-c.be/Autodiscover/Autodiscover.xml
User-Agent: Microsoft Office/16.0
Content-Type: text/xml
<?xml version="1.0" encoding="utf-8"?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006"><Request><EMailAddress>jochen@novox.be</EMailAddress><AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema></Request></Autodiscover>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006"><Request><EMailAddress>jochen@node-c.be</EMailAddress><AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema></Request></Autodiscover>
@@ -2,4 +2,4 @@
<html lang=en>
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to the target URL: <a href="https://automx.novox.be/mobileconfig/?emailaddress=jochen@novox.be">https://automx.novox.be/mobileconfig/?emailaddress=jochen@novox.be</a>. If not, click the link.
<p>You should be redirected automatically to the target URL: <a href="https://automx.node-c.be/mobileconfig/?emailaddress=jochen@node-c.be">https://automx.node-c.be/mobileconfig/?emailaddress=jochen@node-c.be</a>. If not, click the link.
@@ -1,4 +1,4 @@
Content-Length: 319
Content-Length: 323
Content-Type: text/html; charset=utf-8
Location: https://automx.novox.be/mobileconfig/?emailaddress=jochen@novox.be
Location: https://automx.node-c.be/mobileconfig/?emailaddress=jochen@node-c.be
Server: Werkzeug/3.1.9 Python/3.9.5
@@ -1,3 +1,3 @@
GET https://automx.novox.be/mobileconfig?emailaddress=jochen@novox.be
GET https://automx.node-c.be/mobileconfig?emailaddress=jochen@node-c.be
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) Safari
Accept: */*
@@ -1,3 +1,3 @@
GET https://automx.novox.be/mobileconfig/?emailaddress=jochen@novox.be
GET https://automx.node-c.be/mobileconfig/?emailaddress=jochen@node-c.be
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) Safari
Accept: */*
@@ -1,2 +1,2 @@
GET https://automx.novox.be/mobileconfig/?emailaddress=nobody@unknown.example
GET https://automx.node-c.be/mobileconfig/?emailaddress=nobody@unknown.example
User-Agent: Mozilla/5.0 (iPhone)
@@ -1,2 +1,2 @@
GET https://automx.novox.be/mobileconfig/
GET https://automx.node-c.be/mobileconfig/
User-Agent: Mozilla/5.0 (iPhone)
+5 -5
View File
@@ -1,10 +1,10 @@
What mailu's autoconfiguration module (automx2 2021.6, container mailu-automx on novox, Werkzeug/3.1.9 Python/3.9.5)
What mailu's autoconfiguration module (automx2 2021.6, container mailu-automx on node-c, Werkzeug/3.1.9 Python/3.9.5)
answers to the requests mail clients make (R4d step AMX-1, issue 1630, ADR 0480).
Captured 2026-10-21 between 13:58:25 and 13:58:52 (CEST; the Date headers said 11:58 GMT) with the mesh tool
shanks/netcheck.netcheck_request, called from shanks, through the names clients use (autoconfig.novox.be,
autodiscover.novox.be, automx.novox.be: HTTPS, the mesh's route), no ssh. A redirect is reported, never followed.
Mail domain served: novox.be. Mailbox used: jochen@novox.be; unknown domain: nobody@unknown.example.
node-d/netcheck.netcheck_request, called from node-d, through the names clients use (autoconfig.node-c.be,
autodiscover.node-c.be, automx.node-c.be: HTTPS, the mesh's route), no ssh. A redirect is reported, never followed.
Mail domain served: node-c.be. Mailbox used: jochen@node-c.be; unknown domain: nobody@unknown.example.
Each capture is four files with the same stem:
<stem>.request method and URL, then the request headers sent, then (after a blank line) the body sent
@@ -24,7 +24,7 @@ A fixture is not the bytes on the wire in four ways (issue 1701):
What the answers show (read, not guessed):
- GET /mail/config-v1.1.xml?emailaddress=... answers 200 application/xml on all three names; same body on each.
- The incoming (IMAP) server has an EMPTY hostname (<hostname />), port 143, STARTTLS. The outgoing server is
mail.novox.be:587 STARTTLS. Cause (from reading the module, not from the database): automx/files/add-domains:35
mail.node-c.be:587 STARTTLS. Cause (from reading the module, not from the database): automx/files/add-domains:35
reads AMX_IMAP_SERVER, files/mailu.env:58 sets AMX_IMAP_ADDRESS, so the IMAP name was never written.
A client given this answer cannot find its IMAP server.
- POST /autodiscover/autodiscover.xml with a valid request for the served domain answers 500 (the Outlook
+1 -1
View File
@@ -6,7 +6,7 @@ whole list of where the two differ.
server because its setup script read AMX_IMAP_SERVER, which mailu's environment does not set (it sets
AMX_IMAP_ADDRESS). The program names it from AMX_IMAP_ADDRESS (and the port from AMX_IMAP_PORT).
Fixtures 01, 02 and 03 each have a <stem>.corrected.body: the capture with <hostname /> replaced by
<hostname>mail.novox.be</hostname> and nothing else (a test checks that). Their Content-Length is that file's
<hostname>mail.node-c.be</hostname> and nothing else (a test checks that). Their Content-Length is that file's
size, 634, not the captured 612.
2. The Server header. The capture has "Server: Werkzeug/3.1.9 Python/3.9.5". The program sends no Server header, and
+30 -30
View File
@@ -18,19 +18,19 @@ const grantFile = `{
"contributions": 1,
"requirement": "s3-bucket",
"given": [
{"from": "brother", "node": "shanks", "as": "brother-key",
{"from": "brother", "node": "node-d", "as": "brother-key",
"values": {"shares": [{"to": "seat:node-files", "methods": ["put"]}, {"to": "print-and-scan", "methods": ["get"]}]},
"derived": {"bucket": "mesh-shanks-brother"}},
{"from": "nextcloud", "node": "novox", "as": "nextcloud-key", "derived": {"bucket": "mesh-novox-nextcloud"}}
"derived": {"bucket": "mesh-node-d-brother"}},
{"from": "nextcloud", "node": "node-c", "as": "nextcloud-key", "derived": {"bucket": "mesh-node-c-nextcloud"}}
]
}`
// The seats answer is the controller's (mesh-controller.seats read on 2026-10-21): seats[].holders[] of {node, module},
// and outside[] of {Claim, Node, Module}.
const seatsAnswer = `{"answer": {"seats": [
{"seat": "node-files", "scope": "node", "holders": [{"node": "g14", "module": "mesh-files"}, {"node": "shanks", "module": "mesh-files"}]},
{"seat": "node-backup", "scope": "node", "holders": [{"node": "g14", "module": "restic"}]}
], "outside": [{"Claim": "printer", "Scope": "mesh", "Node": "shanks", "Module": "brother", "Site": "home", "Kind": ""}]}}`
{"seat": "node-files", "scope": "node", "holders": [{"node": "node-b", "module": "mesh-files"}, {"node": "node-d", "module": "mesh-files"}]},
{"seat": "node-backup", "scope": "node", "holders": [{"node": "node-b", "module": "restic"}]}
], "outside": [{"Claim": "printer", "Scope": "mesh", "Node": "node-d", "Module": "brother", "Site": "home", "Kind": ""}]}}`
type rig struct {
s *server
@@ -54,10 +54,10 @@ func newRig(t *testing.T) *rig {
}
return p
}
// What the mesh renders from files/object-store.json for a store on novox.internal, port 20001.
cfg := write("object-store.json", `{"scheme":"http","at":"novox.internal","port":"20001","region":"eu-west"}`)
write("links/mesh-shanks-brother.secret", "brother-link-secret\n")
write("links/mesh-novox-nextcloud.secret", "nextcloud-link-secret\n")
// What the mesh renders from files/object-store.json for a store on node-c.internal, port 20001.
cfg := write("object-store.json", `{"scheme":"http","at":"node-c.internal","port":"20001","region":"eu-west"}`)
write("links/mesh-node-d-brother.secret", "brother-link-secret\n")
write("links/mesh-node-c-nextcloud.secret", "nextcloud-link-secret\n")
grants := write("grants/mesh.json", grantFile)
s, err := newServer(cfg, filepath.Join(dir, "links"), grants)
if err != nil {
@@ -96,16 +96,16 @@ func linkOf(t *testing.T, got any) *url.URL {
// 1516/AC1: brother's own ask gets a link signed with the bucket's link key, for the store's host and port, 300 s.
func TestLinkIsSignedWithTheBucketsLinkKey(t *testing.T) {
r := newRig(t)
got, err := r.s.link("shanks.brother", ask("mesh-shanks-brother", "get", float64(300)))
got, err := r.s.link("node-d.brother", ask("mesh-node-d-brother", "get", float64(300)))
if err != nil {
t.Fatal(err)
}
u := linkOf(t, got)
if u.Host != "novox.internal:20001" || u.Scheme != "http" || u.Path != "/mesh-shanks-brother/doc.pdf" {
if u.Host != "node-c.internal:20001" || u.Scheme != "http" || u.Path != "/mesh-node-d-brother/doc.pdf" {
t.Fatalf("link goes to %s", u)
}
q := u.Query()
if cred := q.Get("X-Amz-Credential"); !strings.HasPrefix(cred, linkKeyID("mesh-shanks-brother")+"/20261021/eu-west/s3/") {
if cred := q.Get("X-Amz-Credential"); !strings.HasPrefix(cred, linkKeyID("mesh-node-d-brother")+"/20261021/eu-west/s3/") {
t.Fatalf("credential %q is not the bucket's link key", cred)
}
if strings.Contains(u.String(), "meshroot") {
@@ -124,18 +124,18 @@ func TestLinkKeyIDMatchesTheProvisioners(t *testing.T) {
}
}
// 1516/AC2: a share to seat:node-files for put, mesh-files holding node-files on g14: put given, get refused naming the method.
// 1516/AC2: a share to seat:node-files for put, mesh-files holding node-files on node-b: put given, get refused naming the method.
func TestSeatShareGivesTheHoldersTheSharedMethodOnly(t *testing.T) {
r := newRig(t)
if _, err := r.s.link("g14.mesh-files", ask("mesh-shanks-brother", "put", nil)); err != nil {
if _, err := r.s.link("node-b.mesh-files", ask("mesh-node-d-brother", "put", nil)); err != nil {
t.Fatalf("put: %v", err)
}
_, err := r.s.link("g14.mesh-files", ask("mesh-shanks-brother", "get", nil))
_, err := r.s.link("node-b.mesh-files", ask("mesh-node-d-brother", "get", nil))
if err == nil || !strings.Contains(err.Error(), "put, not get") {
t.Fatalf("get was not refused naming the method: %v", err)
}
// A module share is judged by name alone.
if _, err := r.s.link("novox.print-and-scan", ask("mesh-shanks-brother", "get", nil)); err != nil {
if _, err := r.s.link("node-c.print-and-scan", ask("mesh-node-d-brother", "get", nil)); err != nil {
t.Fatalf("print-and-scan get: %v", err)
}
}
@@ -148,14 +148,14 @@ func TestRefusals(t *testing.T) {
args map[string]any
want string
}{
{"a stranger", "g14.restic", ask("mesh-shanks-brother", "get", nil), "not the bucket's consumer"},
{"a seat it does not hold", "g14.restic", ask("mesh-shanks-brother", "put", nil), "not the bucket's consumer"},
{"unproven", "unproven", ask("mesh-shanks-brother", "get", nil), "did not prove"},
{"no grant", "shanks.brother", ask("no-such-bucket", "get", nil), "no grant names bucket"},
{"seconds over 600", "shanks.brother", ask("mesh-shanks-brother", "get", float64(601)), "at most ten minutes"},
{"seconds zero", "shanks.brother", ask("mesh-shanks-brother", "get", float64(0)), "outside 1 to 600"},
{"method delete", "shanks.brother", ask("mesh-shanks-brother", "delete", nil), "not get or put"},
{"another consumer's bucket", "shanks.brother", ask("mesh-novox-nextcloud", "get", nil), "not the bucket's consumer"},
{"a stranger", "node-b.restic", ask("mesh-node-d-brother", "get", nil), "not the bucket's consumer"},
{"a seat it does not hold", "node-b.restic", ask("mesh-node-d-brother", "put", nil), "not the bucket's consumer"},
{"unproven", "unproven", ask("mesh-node-d-brother", "get", nil), "did not prove"},
{"no grant", "node-d.brother", ask("no-such-bucket", "get", nil), "no grant names bucket"},
{"seconds over 600", "node-d.brother", ask("mesh-node-d-brother", "get", float64(601)), "at most ten minutes"},
{"seconds zero", "node-d.brother", ask("mesh-node-d-brother", "get", float64(0)), "outside 1 to 600"},
{"method delete", "node-d.brother", ask("mesh-node-d-brother", "delete", nil), "not get or put"},
{"another consumer's bucket", "node-d.brother", ask("mesh-node-c-nextcloud", "get", nil), "not the bucket's consumer"},
}
for _, c := range cases {
_, err := r.s.link(c.caller, c.args)
@@ -170,14 +170,14 @@ func TestRefusals(t *testing.T) {
func TestSeatsUnreadableAndCached(t *testing.T) {
r := newRig(t)
r.seatsErr = errors.New("the controller did not answer")
_, err := r.s.link("g14.mesh-files", ask("mesh-shanks-brother", "put", nil))
_, err := r.s.link("node-b.mesh-files", ask("mesh-node-d-brother", "put", nil))
if err == nil || !strings.Contains(err.Error(), "the controller did not answer") || !strings.Contains(err.Error(), "node-files") {
t.Fatalf("not refused naming why: %v", err)
}
r.seatsErr = nil
put := func() {
t.Helper()
if _, err := r.s.link("g14.mesh-files", ask("mesh-shanks-brother", "put", nil)); err != nil {
if _, err := r.s.link("node-b.mesh-files", ask("mesh-node-d-brother", "put", nil)); err != nil {
t.Fatal(err)
}
}
@@ -201,17 +201,17 @@ func TestSeatsUnreadableAndCached(t *testing.T) {
// 1516/AC5: the grant file is read at each call.
func TestGrantFileIsReadAtEachCall(t *testing.T) {
r := newRig(t)
if _, err := r.s.link("novox.print-and-scan", ask("mesh-shanks-brother", "get", nil)); err != nil {
if _, err := r.s.link("node-c.print-and-scan", ask("mesh-node-d-brother", "get", nil)); err != nil {
t.Fatal(err)
}
changed := strings.Replace(grantFile, `{"to": "print-and-scan", "methods": ["get"]}`, `{"to": "someone-else", "methods": ["get"]}`, 1)
if err := os.WriteFile(r.s.receives, []byte(changed), 0o600); err != nil {
t.Fatal(err)
}
if _, err := r.s.link("novox.print-and-scan", ask("mesh-shanks-brother", "get", nil)); err == nil {
if _, err := r.s.link("node-c.print-and-scan", ask("mesh-node-d-brother", "get", nil)); err == nil {
t.Fatal("the second call judged by the old shares")
}
if _, err := r.s.link("novox.someone-else", ask("mesh-shanks-brother", "get", nil)); err != nil {
if _, err := r.s.link("node-c.someone-else", ask("mesh-node-d-brother", "get", nil)); err != nil {
t.Fatal(err)
}
}