@@ -0,0 +1,38 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import crypto from 'node:crypto';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
const release = JSON.parse(await fs.readFile('compras-release.json', 'utf8'));
|
||||
const base = 'https://compras.tempo.co.mz';
|
||||
const entry = await fetch(base+'/', { redirect: 'manual', signal: AbortSignal.timeout(15000) });
|
||||
assert.equal(entry.status, 302);
|
||||
assert.equal(new URL(entry.headers.get('location'), base).pathname, '/login');
|
||||
const queue = Object.entries(release.frontend.files);
|
||||
let checked = 0;
|
||||
await Promise.all(Array.from({ length: 4 }, async () => {
|
||||
for (;;) {
|
||||
const entry = queue.shift();
|
||||
if (!entry) return;
|
||||
const [name, expected] = entry;
|
||||
const response = await fetch(base+'/build/'+name, { signal: AbortSignal.timeout(20000) });
|
||||
assert.equal(response.status, 200, name);
|
||||
assert.equal(crypto.createHash('sha256').update(new Uint8Array(await response.arrayBuffer())).digest('hex'), expected, name);
|
||||
checked++;
|
||||
}
|
||||
}));
|
||||
for (const [path, component] of [['/', 'auth/login'], ['/login', 'auth/login'], ['/apresentacao', 'home']]) {
|
||||
const response = await fetch(base+path, { signal: AbortSignal.timeout(15000) });
|
||||
assert.equal(response.status, 200);
|
||||
const html = await response.text();
|
||||
assert.ok(html.includes(release.frontend.entry));
|
||||
const bootstrap = html.match(/<script data-page="app" type="application\/json">([\s\S]*?)<\/script>/);
|
||||
assert.ok(bootstrap);
|
||||
const page = JSON.parse(bootstrap[1]);
|
||||
assert.equal(page.component, component);
|
||||
assert.equal(page.props.auth.user, null);
|
||||
assert.deepEqual(page.props.commonFinanceNavigation, { payments: false, ledger: false, configuration: false });
|
||||
}
|
||||
const proof = { state: 'passed', product: 'compras', release_id: release.release_id, public_url: base,
|
||||
assets_verified: checked, real_product_entry: true, login_entry: true, anonymous_private_identity_or_financial_access: false };
|
||||
await fs.writeFile('docs/proofs/compras-release-http.json', JSON.stringify(proof, null, 2)+'\n');
|
||||
console.log(JSON.stringify(proof));
|
||||
Reference in New Issue
Block a user