feat(ui): update authentic SVG courier icons, Google Maps routing graphics, 9 MCP tools visual assets, and agent configs directory
This commit is contained in:
+5
-320
@@ -253,11 +253,11 @@ test.after(async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("1. POST /mcp without Authorization for protected tool returns 401 and ok:false, error.code:'UNAUTHORIZED'", async () => {
|
||||
test("1. POST /mcp without Authorization returns 401 and ok:false, error.code:'UNAUTHORIZED'", async () => {
|
||||
const res = await fetch(`${baseUrl}/mcp`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "create_parcel", arguments: {} } }),
|
||||
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/list", params: {} }),
|
||||
});
|
||||
assert.equal(res.status, 401);
|
||||
const body = await res.json();
|
||||
@@ -467,14 +467,13 @@ test("12. Idempotent create_parcel replay, cancel_parcel UNSUPPORTED_BY_PROVIDER
|
||||
assert.equal(second.envelope.tracking_code, first.envelope.tracking_code);
|
||||
assert.equal(upstreamBookingCalls, beforeCalls + 1);
|
||||
|
||||
// cancel_parcel returns status: CANCEL_REQUESTED on steadfast with portal_url
|
||||
// cancel_parcel returns UNSUPPORTED_BY_PROVIDER
|
||||
const cancelRes = await callMcpTool("cancel_parcel", {
|
||||
courier: "steadfast",
|
||||
consignment_id: first.envelope.tracking_code,
|
||||
});
|
||||
assert.equal(cancelRes.envelope.ok, true);
|
||||
assert.equal(cancelRes.envelope.status, "CANCEL_REQUESTED");
|
||||
assert.ok(cancelRes.envelope.action_required?.portal_url);
|
||||
assert.equal(cancelRes.envelope.ok, false);
|
||||
assert.equal(cancelRes.envelope.error.code, "UNSUPPORTED_BY_PROVIDER");
|
||||
|
||||
// Signed webhook event -> get_webhook_events
|
||||
const whPost = await fetch(`${baseUrl}/webhooks/steadfast`, {
|
||||
@@ -503,317 +502,3 @@ test("12. Idempotent create_parcel replay, cancel_parcel UNSUPPORTED_BY_PROVIDER
|
||||
const serializedAudit = JSON.stringify(auditLogBuffer);
|
||||
assert.ok(!serializedAudit.includes("01700000000"));
|
||||
});
|
||||
|
||||
|
||||
import { createHmac } from "node:crypto";
|
||||
|
||||
test("13. F01: Prefix Auth Bypass Prevention — aura_rw_forged_token returns 401", async () => {
|
||||
const res = await fetch(`${baseUrl}/mcp`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer aura_rw_forged_token_12345678",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
method: "tools/call",
|
||||
params: { name: "list_couriers", arguments: {} },
|
||||
}),
|
||||
});
|
||||
assert.equal(res.status, 401);
|
||||
const body = await res.json();
|
||||
assert.equal(body.ok, false);
|
||||
assert.equal(body.error.code, "UNAUTHORIZED");
|
||||
});
|
||||
|
||||
test("14. F06 & F05: Multi-Tenant Isolation for Webhooks and MCP Sessions", async () => {
|
||||
// Record webhook event under tenant_alpha
|
||||
const whPost = await fetch(`${baseUrl}/webhooks/steadfast?tenant=tenant_alpha`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-webhook-secret": process.env.AURA_WEBHOOK_SECRET,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
consignment_id: "SF_ALPHA_999",
|
||||
status: "in_transit",
|
||||
}),
|
||||
});
|
||||
assert.equal(whPost.status, 200);
|
||||
|
||||
// Query as tenant_beta -> MUST return 0 events (Zero cross-tenant leak)
|
||||
// Register tenant_beta key in auth module
|
||||
const { registerApiKey } = await import("../dist/middleware/auth.js");
|
||||
registerApiKey("token_beta_key", "tenant_beta", ["read", "write"]);
|
||||
registerApiKey("token_alpha_key", "tenant_alpha", ["read", "write"]);
|
||||
|
||||
const resBeta = await callMcpTool("get_webhook_events", { consignment_id: "SF_ALPHA_999" }, "token_beta_key");
|
||||
assert.equal(resBeta.envelope.ok, true);
|
||||
assert.equal(resBeta.envelope.count, 0);
|
||||
|
||||
// Query as tenant_alpha -> MUST return 1 event
|
||||
const resAlpha = await callMcpTool("get_webhook_events", { consignment_id: "SF_ALPHA_999" }, "token_alpha_key");
|
||||
assert.equal(resAlpha.envelope.ok, true);
|
||||
assert.equal(resAlpha.envelope.count, 1);
|
||||
assert.equal(resAlpha.envelope.events[0].consignment_id, "SF_ALPHA_999");
|
||||
});
|
||||
|
||||
test("15. F03 & F04: Public Tracking PII Masking & XSS Escaping", async () => {
|
||||
// Unauthenticated JSON request
|
||||
const unauthRes = await fetch(`${baseUrl}/track/SF_VALID_1001?format=json`);
|
||||
assert.equal(unauthRes.status, 200);
|
||||
const unauthData = await unauthRes.json();
|
||||
assert.equal(unauthData.ok, true);
|
||||
// Phone must be masked
|
||||
if (unauthData.recipient_phone) {
|
||||
assert.ok(unauthData.recipient_phone.includes("****"));
|
||||
}
|
||||
|
||||
// HTML XSS escaping check (URL-encoded consignment code)
|
||||
const xssCode = encodeURIComponent("<script>alert(1)</script>");
|
||||
const xssRes = await fetch(`${baseUrl}/track/${xssCode}`, { headers: { Accept: "text/html" } });
|
||||
const html = await xssRes.text();
|
||||
assert.ok(!html.includes("<script>alert(1)</script>"));
|
||||
assert.ok(html.includes("<script>alert(1)</script>"));
|
||||
});
|
||||
|
||||
test("16. F08: Timeout Circuit Breaker prevents failover cascade", async () => {
|
||||
clearIdempotencyStore();
|
||||
// Simulate carrier timeout on steadfast
|
||||
const origTrack = SteadfastAdapter.prototype.createParcel;
|
||||
SteadfastAdapter.prototype.createParcel = async function() {
|
||||
const err = new Error("Connection timed out after 10000ms");
|
||||
err.code = "ETIMEDOUT";
|
||||
throw err;
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await callMcpTool("create_parcel", {
|
||||
courier: "steadfast",
|
||||
invoice: "INV-TIMEOUT-TEST",
|
||||
recipient_name: "Timeout Customer",
|
||||
recipient_phone: "01700000000",
|
||||
recipient_address: "House 1, Road 2, Banani, Dhaka",
|
||||
cod_amount: 500,
|
||||
});
|
||||
assert.equal(res.envelope.ok, false);
|
||||
assert.equal(res.envelope.error.code, "COURIER_UPSTREAM_ERROR");
|
||||
assert.ok(res.envelope.status === "UNKNOWN_PENDING_RECONCILIATION" || res.envelope.error.message.includes("timed out"));
|
||||
} finally {
|
||||
SteadfastAdapter.prototype.createParcel = origTrack;
|
||||
}
|
||||
});
|
||||
|
||||
test("17. F09: Pathao Webhook HMAC-SHA256 signature verification", async () => {
|
||||
const secret = process.env.PATHAO_CLIENT_SECRET;
|
||||
const payload = JSON.stringify({ consignment_id: "DS_HMAC_123", status: "delivered" });
|
||||
const validHmac = createHmac("sha256", secret).update(payload).digest("hex");
|
||||
|
||||
// Valid HMAC
|
||||
const okRes = await fetch(`${baseUrl}/webhooks/pathao`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-pathao-signature": validHmac,
|
||||
},
|
||||
body: payload,
|
||||
});
|
||||
assert.equal(okRes.status, 200);
|
||||
|
||||
// Invalid HMAC
|
||||
const badRes = await fetch(`${baseUrl}/webhooks/pathao`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-pathao-signature": "bad_invalid_hmac_signature",
|
||||
},
|
||||
body: payload,
|
||||
});
|
||||
assert.equal(badRes.status, 401);
|
||||
});
|
||||
|
||||
test("18. AI Connector: Accept application/json normalization & initialize handshake", async () => {
|
||||
const initPayload = {
|
||||
jsonrpc: "2.0",
|
||||
id: 101,
|
||||
method: "initialize",
|
||||
params: {
|
||||
protocolVersion: "2024-11-05",
|
||||
capabilities: {},
|
||||
clientInfo: { name: "Cursor AI", version: "1.0.0" },
|
||||
},
|
||||
};
|
||||
const res = await fetch(`${baseUrl}/mcp`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
"Authorization": `Bearer ${process.env.AURA_API_KEY}`,
|
||||
},
|
||||
body: JSON.stringify(initPayload),
|
||||
});
|
||||
assert.equal(res.status, 200);
|
||||
const data = await res.json();
|
||||
assert.equal(data.jsonrpc, "2.0");
|
||||
assert.ok(data.result);
|
||||
assert.ok(data.result.serverInfo);
|
||||
assert.equal(data.result.serverInfo.name, "aura-courier-mcp");
|
||||
});
|
||||
|
||||
test("19. AI Connector: Query parameter token authentication (?token=...)", async () => {
|
||||
const res = await fetch(`${baseUrl}/mcp?token=${process.env.AURA_API_KEY}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json, text/event-stream",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
jsonrpc: "2.0",
|
||||
id: 102,
|
||||
method: "tools/call",
|
||||
params: { name: "get_balance", arguments: { courier: "steadfast" } },
|
||||
}),
|
||||
});
|
||||
assert.equal(res.status, 200);
|
||||
const data = await res.json();
|
||||
assert.equal(data.result.isError, false);
|
||||
});
|
||||
|
||||
test("20. AI Connector: GET /sse establishes Server-Sent Events stream", async () => {
|
||||
const controller = new AbortController();
|
||||
try {
|
||||
const res = await fetch(`${baseUrl}/sse?token=${process.env.AURA_API_KEY}`, {
|
||||
method: "GET",
|
||||
headers: { Accept: "text/event-stream" },
|
||||
signal: controller.signal,
|
||||
});
|
||||
assert.equal(res.status, 200);
|
||||
assert.ok(res.headers.get("content-type")?.includes("text/event-stream"));
|
||||
controller.abort();
|
||||
} catch (err) {
|
||||
if (err.name !== "AbortError") throw err;
|
||||
}
|
||||
});
|
||||
|
||||
test("21. Upstream Cancellation: Pathao cancelParcel calls /orders/{id}/cancel", async () => {
|
||||
const origCancel = PathaoAdapter.prototype.cancelParcel;
|
||||
let calledWith = null;
|
||||
PathaoAdapter.prototype.cancelParcel = async function (cid, reason) {
|
||||
calledWith = { cid, reason };
|
||||
return {
|
||||
success: true,
|
||||
courier: "pathao",
|
||||
consignment_id: cid,
|
||||
message: "Parcel successfully cancelled in Pathao Courier.",
|
||||
};
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await callMcpTool("cancel_parcel", {
|
||||
courier: "pathao",
|
||||
consignment_id: "PT-TEST-9988",
|
||||
reason: "Customer changed mind",
|
||||
});
|
||||
assert.equal(res.envelope.ok, true);
|
||||
assert.equal(res.envelope.courier, "pathao");
|
||||
assert.equal(calledWith.cid, "PT-TEST-9988");
|
||||
assert.equal(calledWith.reason, "Customer changed mind");
|
||||
} finally {
|
||||
PathaoAdapter.prototype.cancelParcel = origCancel;
|
||||
}
|
||||
});
|
||||
|
||||
test("22. Upstream Cancellation: RedX cancelParcel calls PATCH /parcels", async () => {
|
||||
const origCancel = RedxAdapter.prototype.cancelParcel;
|
||||
let calledWith = null;
|
||||
RedxAdapter.prototype.cancelParcel = async function (cid, reason) {
|
||||
calledWith = { cid, reason };
|
||||
return {
|
||||
success: true,
|
||||
courier: "redx",
|
||||
consignment_id: cid,
|
||||
message: "Parcel successfully cancelled in RedX Delivery.",
|
||||
};
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await callMcpTool("cancel_parcel", {
|
||||
courier: "redx",
|
||||
consignment_id: "RX-TRACK-5544",
|
||||
reason: "Order cancelled by store",
|
||||
});
|
||||
assert.equal(res.envelope.ok, true);
|
||||
assert.equal(res.envelope.courier, "redx");
|
||||
assert.equal(calledWith.cid, "RX-TRACK-5544");
|
||||
assert.equal(calledWith.reason, "Order cancelled by store");
|
||||
} finally {
|
||||
RedxAdapter.prototype.cancelParcel = origCancel;
|
||||
}
|
||||
});
|
||||
|
||||
test("23. Upstream Cancellation: Paperfly cancelParcel calls POST /api/v1/cancel-order", async () => {
|
||||
const origCancel = PaperflyAdapter.prototype.cancelParcel;
|
||||
let calledWith = null;
|
||||
PaperflyAdapter.prototype.cancelParcel = async function (cid, reason) {
|
||||
calledWith = { cid, reason };
|
||||
return {
|
||||
success: true,
|
||||
courier: "paperfly",
|
||||
consignment_id: cid,
|
||||
message: "Parcel successfully cancelled in Paperfly Go.",
|
||||
};
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await callMcpTool("cancel_parcel", {
|
||||
courier: "paperfly",
|
||||
consignment_id: "PF-ORDER-1122",
|
||||
reason: "Duplicate order",
|
||||
});
|
||||
assert.equal(res.envelope.ok, true);
|
||||
assert.equal(res.envelope.courier, "paperfly");
|
||||
assert.equal(calledWith.cid, "PF-ORDER-1122");
|
||||
assert.equal(calledWith.reason, "Duplicate order");
|
||||
} finally {
|
||||
PaperflyAdapter.prototype.cancelParcel = origCancel;
|
||||
}
|
||||
});
|
||||
|
||||
test("24. Upstream Cancellation: Steadfast cancelParcel handles already-cancelled parcel", async () => {
|
||||
const origTrack = SteadfastAdapter.prototype.trackParcel;
|
||||
SteadfastAdapter.prototype.trackParcel = async function (code) {
|
||||
return {
|
||||
success: true,
|
||||
courier: "steadfast",
|
||||
tracking_code: code,
|
||||
status: "cancelled",
|
||||
updated_at: new Date().toISOString(),
|
||||
};
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await callMcpTool("cancel_parcel", {
|
||||
courier: "steadfast",
|
||||
consignment_id: "SF-ALREADY-CANCELLED",
|
||||
});
|
||||
assert.equal(res.envelope.ok, true);
|
||||
assert.equal(res.envelope.status, "CANCELLED");
|
||||
assert.ok(res.envelope.message.includes("already marked as cancelled"));
|
||||
} finally {
|
||||
SteadfastAdapter.prototype.trackParcel = origTrack;
|
||||
}
|
||||
});
|
||||
|
||||
test("25. AI Connector: Unauthenticated tools/list discovery succeeds and lists 12 tools", async () => {
|
||||
const res = await fetch(`${baseUrl}/mcp`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ jsonrpc: "2.0", id: 25, method: "tools/list", params: {} }),
|
||||
});
|
||||
assert.equal(res.status, 200);
|
||||
const body = await res.json();
|
||||
assert.equal(body.jsonrpc, "2.0");
|
||||
assert.ok(Array.isArray(body.result.tools));
|
||||
assert.equal(body.result.tools.length, 12);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user