Files
ced4568 b38c46aaec test(phase5c): permanent regression suite + enrollment/activation dress rehearsal
- platform/test/e2e-phase5c.js (29 checks): activation-vs-confirmation routing,
  duplicate/concurrent webhook idempotency, temporary/permanent/exhausted retry
  classification, resend/regenerate token invalidation, activation/reset single-use and
  expiration, HTML-injection regression, production token-secrecy gating via a real container
  recreate with COOKIE_SECURE=1, minor/contact-email resolution, RBAC scoping, metrics/audit
  hygiene, and a real Platform API restart.
- infra/scripts/drills/test-phase5c-enrollment-activation.js (10 checks): one continuous
  story — website enrollment through a real rendered/extracted activation email, a real Lab
  launch and scenario completion, a second enrollment's confirmation email, a full
  password-reset round trip, and the minor/no-email contact-email path.
- infra/scripts/gws-email-test.js: the opt-in (RUN_GWS_EMAIL_TEST=true) live Google Workspace
  delivery test — does nothing without the explicit flag, sends exactly one message to one
  operator-configured recipient when enabled.
2026-08-25 14:44:25 -05:00

52 lines
2.6 KiB
JavaScript
Executable File

#!/usr/bin/env node
// Phase 5C §24 — the OPTIONAL, opt-in Google Workspace live-delivery test. Does NOTHING unless
// explicitly enabled — no test/regression run ever sends real email by accident.
//
// Usage (only when you actually have real Workspace credentials configured):
// RUN_GWS_EMAIL_TEST=true \
// [email protected] \
// GOOGLE_SERVICE_ACCOUNT_JSON='{"client_email":"...","private_key":"..."}' \
// [email protected] \
// EMAIL_FROM_NAME="RootNode Academy" \
// node infra/scripts/gws-email-test.js
//
// Sends exactly ONE clearly-marked test message to TEST_EMAIL_RECIPIENT — never a
// production/student address, never inferred from anything in the database. Run it once after
// setting up domain-wide delegation to confirm the adapter actually works against the real
// Gmail API, not as part of any regular regression pass (see docs/RUNBOOK_GOOGLE_WORKSPACE_EMAIL.md).
if (process.env.RUN_GWS_EMAIL_TEST !== 'true') {
console.log('Skipped: set RUN_GWS_EMAIL_TEST=true to actually send a live test email. Nothing was sent.');
process.exit(0);
}
const recipient = process.env.TEST_EMAIL_RECIPIENT;
if (!recipient) {
console.error('Set TEST_EMAIL_RECIPIENT to the ONE address this test should send to — it is never inferred from anything else.');
process.exit(1);
}
const provider = require('../../platform/api/src/email/gws-provider');
async function main() {
console.log(`Sending one live test message via the Gmail API adapter to ${recipient}...`);
const result = await provider.send({
to: recipient,
fromName: process.env.EMAIL_FROM_NAME || 'RootNode Academy',
fromAddress: process.env.EMAIL_FROM_ADDRESS,
replyTo: process.env.EMAIL_REPLY_TO,
subject: '[RootNode Academy] Google Workspace adapter test',
text: `This is a one-off test of RootNode Academy's Google Workspace email adapter (Gmail API, service account domain-wide delegation). If you received this, live delivery is working. Sent at ${new Date().toISOString()}.`,
html: `<p>This is a one-off test of RootNode Academy's Google Workspace email adapter (Gmail API, service account domain-wide delegation).</p><p>If you received this, live delivery is working. Sent at ${new Date().toISOString()}.</p>`,
});
console.log('Provider accepted the message.');
console.log('Provider message ID:', result.providerMessageId);
console.log('\nGWS LIVE DELIVERY TEST: PASSED');
}
main().catch((e) => {
console.error('GWS LIVE DELIVERY TEST: FAILED');
console.error(` ${e.errorCode || 'error'}: ${e.message}`);
process.exit(1);
});