forked from StateVoicesNational/Spoke
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge StateVoicesNational#1478 aflcio:scaling-feb20-3-messagej into s…
…tage-main for Spoke version 5.5
- Loading branch information
Showing
27 changed files
with
505 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import crypto from "../../../../src/server/api/lib/crypto"; | ||
|
||
beforeEach(() => { | ||
jest.resetModules(); | ||
}); | ||
|
||
it("encrypted value should be different", () => { | ||
const plaintext = "test_auth_token"; | ||
const encrypted = crypto.symmetricEncrypt(plaintext); | ||
expect(encrypted).not.toEqual(plaintext); | ||
}); | ||
|
||
it("decrypted value should match original", () => { | ||
const plaintext = "another_test_auth_token"; | ||
const encrypted = crypto.symmetricEncrypt(plaintext); | ||
const decrypted = crypto.symmetricDecrypt(encrypted); | ||
expect(decrypted).toEqual(plaintext); | ||
}); | ||
|
||
it("session secret must exist", () => { | ||
function encrypt() { | ||
delete global.SESSION_SECRET; | ||
const crypto2 = require("../../../../src/server/api/lib/crypto"); | ||
const plaintext = "foo"; | ||
const encrypted = crypto2.symmetricEncrypt(plaintext); | ||
} | ||
expect(encrypt).toThrowError( | ||
"The SESSION_SECRET environment variable must be set to use crypto functions!" | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Run this script from the top level directory to decrypt a value: | ||
// | ||
// node ./dev-tools/symmetric-decrypt.js ValueToBeDecrypted | ||
|
||
require("dotenv").config(); | ||
const { symmetricDecrypt } = require("../src/server/api/lib/crypto"); | ||
|
||
const result = symmetricDecrypt(process.argv[2]); | ||
console.log(result); | ||
process.exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Run this script from the top level directory to encrypt a value: | ||
// | ||
// node ./dev-tools/symmetric-encrypt.js ValueToBeEncrypted | ||
|
||
require("dotenv").config(); | ||
const { symmetricEncrypt } = require("../src/server/api/lib/crypto"); | ||
|
||
const result = symmetricEncrypt(process.argv[2]); | ||
console.log(result); | ||
process.exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.