Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cli/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import {
const PROVIDERS = new Set(['generic-hmac', 'twilio', 'telnyx', 'vonage', 'plivo']);

function parseArgs(argv) {
const options = { command: argv[0] || 'help' };
for (let index = 1; index < argv.length; index += 1) {
const first = argv[0] || 'help';
const firstIsOption = first.startsWith('-');
const options = { command: firstIsOption ? 'help' : first };
for (let index = firstIsOption ? 0 : 1; index < argv.length; index += 1) {
const arg = argv[index];
if (!arg.startsWith('--')) continue;
const [rawKey, inlineValue] = arg.slice(2).split('=', 2);
Expand Down Expand Up @@ -295,7 +297,7 @@ async function main() {
const args = parseArgs(process.argv.slice(2));
if (args.command !== 'test') {
help();
process.exitCode = args.command === 'help' || args.help ? 0 : 1;
process.exitCode = args.command === 'help' || args.help || args.h ? 0 : 1;
return;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
},
"bin": {
"secure-sms-webhook": "./cli/tester.js"
"secure-sms-webhook": "cli/tester.js"
},
"files": [
"src",
Expand Down
6 changes: 6 additions & 0 deletions tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ test('CLI refuses public targets before making a request', () => {
assert.match(run.stderr, /Remote targets are disabled/);
});

test('CLI help exits successfully', () => {
const run = spawnSync(process.execPath, ['cli/tester.js', '--help'], { encoding: 'utf8' });
assert.equal(run.status, 0);
assert.match(run.stdout, /Secure SMS Webhook Validator/);
});

test('documentation site is static, disclosed, and contains no secret form fields', () => {
const html = readFileSync('site/index.html', 'utf8');
assert.match(html, /Secure SMS Webhook Validator/);
Expand Down
Loading