homepage.js/test/genkey.js

19 lines
688 B
JavaScript
Raw Normal View History

2023-02-18 16:03:27 +01:00
const test = require('unit.js');
const execSync = require('child_process').execSync;
const fs = require('fs');
const path = require('path');
2023-02-18 16:29:32 +01:00
describe('Test generate key script', () => {
2023-02-18 16:03:27 +01:00
it('Check if key is generated properly', () => {
const stdout = execSync('node ./scripts/generate_key.js --key-only').toString('utf-8');
const key = Buffer.from(stdout, 'base64');
2023-02-18 16:29:32 +01:00
test.number(key.length).is(32);
2023-02-18 16:03:27 +01:00
});
it('Check if file is edited properly', () => {
const stdout = execSync('node ./scripts/generate_key.js -s').toString('utf-8');
const file = fs.readFileSync(path.resolve('.env'));
test.string(stdout).isNot(file);
});
});