Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
skutner committed Nov 23, 2022
1 parent 35b18b5 commit d48027c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/secrets/checkSecretsFileIsEncrypted.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require("../../../../psknode/bundles/testsRuntime");
const dc = require("double-check");
const assert = dc.assert;
const path = require("path");
const fs = require("fs");
const config = require("../../config");
const serverRootFolder = "../../../../../apihub-root"
const crypto = require("opendsu").loadAPI("crypto");
const secretsFolderPath = path.join(serverRootFolder, config.getConfig("externalStorage"), "secrets");
const demiurgeSecretsFilePath = path.join(secretsFolderPath, "Demiurge.secret");
const env = require("../../../../../env.json");
const encryptedSecrets = fs.readFileSync(demiurgeSecretsFilePath);
let encryptionKey = env.SSO_SECRETS_ENCRYPTION_KEY.split(",")[0];
encryptionKey = $$.Buffer.from(encryptionKey, "base64");
let decryptedSecrets;
let error;
try {
decryptedSecrets = crypto.decrypt(encryptedSecrets, encryptionKey);
} catch (e) {
error = e;
}

assert.equal(error, undefined, "Error should be undefined");
assert.true(decryptedSecrets !== undefined);

0 comments on commit d48027c

Please # to comment.