fix(bimi): as rotas existiam no protocols e o proxy nao as conhecia
O painel respondia "API endpoint not found" e o logotipo devolvia a pagina de 404 do Next. As rotas estavam registadas no servico protocols, mas o proxy do webmail decide o upstream por uma lista propria, e eu nao acrescentei a "bimi" -- exactamente o erro contra o qual o comentario dessa lista avisa. Ficam ambas cobertas por testes: cada area administrativa que o protocols possui, e o caminho well-known do logotipo. Esquecer isto nao volta a ser silencioso. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c59548e311
commit
b5baf33a63
3 files changed
+34
-1
No files matched your search
@@ -30,6 +30,12 @@ const nextConfig: NextConfig = {
|
|||||||
source: "/.well-known/mta-sts.txt",
|
source: "/.well-known/mta-sts.txt",
|
||||||
destination: `${PROTOCOLS_SERVICE_URL}/.well-known/mta-sts.txt`,
|
destination: `${PROTOCOLS_SERVICE_URL}/.well-known/mta-sts.txt`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// Fetched by receiving mail providers evaluating a message, which
|
||||||
|
// hold no session and never will.
|
||||||
|
source: "/.well-known/bimi/default.svg",
|
||||||
|
destination: `${PROTOCOLS_SERVICE_URL}/.well-known/bimi/default.svg`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
source: "/.well-known/security.txt",
|
source: "/.well-known/security.txt",
|
||||||
destination: `${PROTOCOLS_SERVICE_URL}/.well-known/security.txt`,
|
destination: `${PROTOCOLS_SERVICE_URL}/.well-known/security.txt`,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const PROTOCOLS_SERVICE_URL = process.env.PROTOCOLS_SERVICE_URL ?? "http://proto
|
|||||||
* a session problem, and the reason to keep this list beside the services it
|
* a session problem, and the reason to keep this list beside the services it
|
||||||
* names.
|
* names.
|
||||||
*/
|
*/
|
||||||
const PROTOCOLS_ADMIN_AREAS = new Set(["dkim", "tls", "dns"]);
|
const PROTOCOLS_ADMIN_AREAS = new Set(["dkim", "tls", "dns", "bimi"]);
|
||||||
|
|
||||||
function upstreamFor(path: string[]): string {
|
function upstreamFor(path: string[]): string {
|
||||||
if (path[0] === "mail") return PROTOCOLS_SERVICE_URL;
|
if (path[0] === "mail") return PROTOCOLS_SERVICE_URL;
|
||||||
|
|||||||
@@ -32,3 +32,30 @@ describe("the MTA-STS policy senders fetch", () => {
|
|||||||
expect(config).not.toMatch(/redirects\(\)/);
|
expect(config).not.toMatch(/redirects\(\)/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Everything the protocols service owns has to be named twice: once where the
|
||||||
|
* route is registered, and once here where the proxy decides which upstream a
|
||||||
|
* request goes to. Adding it in only one place is silent - an admin route
|
||||||
|
* lands on the auth service and comes back "API endpoint not found", and a
|
||||||
|
* well-known document comes back as this app's own 404 page.
|
||||||
|
*/
|
||||||
|
describe("the routes the protocols service owns", () => {
|
||||||
|
const proxy = readFileSync(
|
||||||
|
resolve(process.cwd(), "src/app/api/v1/[...path]/route.ts"),
|
||||||
|
"utf8",
|
||||||
|
);
|
||||||
|
|
||||||
|
// Each of these is served by protocols because that process holds something
|
||||||
|
// the auth service does not.
|
||||||
|
it.each(["dkim", "tls", "dns", "bimi"])("routes /admin/%s to protocols", (area) => {
|
||||||
|
expect(proxy).toMatch(new RegExp(`PROTOCOLS_ADMIN_AREAS[\\s\\S]{0,120}"${area}"`));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fetched by receiving mail providers evaluating a message. They hold no
|
||||||
|
// session, so this one has to be reachable without any.
|
||||||
|
it("routes the BIMI logo to the service that stores it", () => {
|
||||||
|
expect(config).toContain("/.well-known/bimi/default.svg");
|
||||||
|
expect(config).toMatch(/bimi\/default\.svg[\s\S]{0,200}PROTOCOLS_SERVICE_URL/);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in new issue
Block a user