diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:20:35 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-27 11:02:23 -0400 |
commit | 134a4083953270e8a11430395357fb70a29047ad (patch) | |
tree | dd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/client_encrypt/lib | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/client_encrypt/lib')
-rw-r--r-- | jstests/client_encrypt/lib/fle_command_line_explicit_encryption.js | 143 | ||||
-rw-r--r-- | jstests/client_encrypt/lib/mock_kms.js | 10 |
2 files changed, 76 insertions, 77 deletions
diff --git a/jstests/client_encrypt/lib/fle_command_line_explicit_encryption.js b/jstests/client_encrypt/lib/fle_command_line_explicit_encryption.js index 0ca10b2057c..da83d69c87b 100644 --- a/jstests/client_encrypt/lib/fle_command_line_explicit_encryption.js +++ b/jstests/client_encrypt/lib/fle_command_line_explicit_encryption.js @@ -1,84 +1,83 @@ /** -* Check the functionality of encrypt and decrypt functions in KeyVault.js. This test is run by -* jstests/fle/fle_command_line_encryption.js. -*/ + * Check the functionality of encrypt and decrypt functions in KeyVault.js. This test is run by + * jstests/fle/fle_command_line_encryption.js. + */ load("jstests/client_encrypt/lib/mock_kms.js"); (function() { - "use strict"; - - const mock_kms = new MockKMSServer(); - mock_kms.start(); - - const shell = Mongo(); - const keyVault = shell.getKeyVault(); - - const test = shell.getDB("test"); - const collection = test.coll; - - const randomAlgorithm = "AEAD_AES_256_CBC_HMAC_SHA_512-Random"; - const deterministicAlgorithm = "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"; - const encryptionAlgorithms = [randomAlgorithm, deterministicAlgorithm]; - - const passTestCases = [ - "mongo", - NumberLong(13), - NumberInt(23), - UUID(), - ISODate(), - new Date('December 17, 1995 03:24:00'), - BinData(2, '1234'), - new Timestamp(1, 2), - new ObjectId(), - new DBPointer("mongo", new ObjectId()), - /test/ - ]; - - const failDeterministic = [ - true, - false, - 12, - NumberDecimal(0.1234), - ["this is an array"], - {"value": "mongo"}, - Code("function() { return true; }") - ]; - - const failTestCases = [null, undefined, MinKey(), MaxKey(), DBRef("test", "test", "test")]; - - // Testing for every combination of (algorithm, javascriptVariable) - for (const encryptionAlgorithm of encryptionAlgorithms) { - collection.drop(); - - assert.writeOK( - keyVault.createKey("aws", "arn:aws:kms:us-east-1:fake:fake:fake", ['mongoKey'])); - const keyId = keyVault.getKeyByAltName("mongoKey").toArray()[0]._id; - - let pass; - let fail; - if (encryptionAlgorithm === randomAlgorithm) { - pass = [...passTestCases, ...failDeterministic]; - fail = failTestCases; - } else if (encryptionAlgorithm === deterministicAlgorithm) { - pass = passTestCases; - fail = [...failTestCases, ...failDeterministic]; - } +"use strict"; + +const mock_kms = new MockKMSServer(); +mock_kms.start(); + +const shell = Mongo(); +const keyVault = shell.getKeyVault(); + +const test = shell.getDB("test"); +const collection = test.coll; + +const randomAlgorithm = "AEAD_AES_256_CBC_HMAC_SHA_512-Random"; +const deterministicAlgorithm = "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"; +const encryptionAlgorithms = [randomAlgorithm, deterministicAlgorithm]; + +const passTestCases = [ + "mongo", + NumberLong(13), + NumberInt(23), + UUID(), + ISODate(), + new Date('December 17, 1995 03:24:00'), + BinData(2, '1234'), + new Timestamp(1, 2), + new ObjectId(), + new DBPointer("mongo", new ObjectId()), + /test/ +]; + +const failDeterministic = [ + true, + false, + 12, + NumberDecimal(0.1234), + ["this is an array"], + {"value": "mongo"}, + Code("function() { return true; }") +]; + +const failTestCases = [null, undefined, MinKey(), MaxKey(), DBRef("test", "test", "test")]; + +// Testing for every combination of (algorithm, javascriptVariable) +for (const encryptionAlgorithm of encryptionAlgorithms) { + collection.drop(); + + assert.writeOK(keyVault.createKey("aws", "arn:aws:kms:us-east-1:fake:fake:fake", ['mongoKey'])); + const keyId = keyVault.getKeyByAltName("mongoKey").toArray()[0]._id; + + let pass; + let fail; + if (encryptionAlgorithm === randomAlgorithm) { + pass = [...passTestCases, ...failDeterministic]; + fail = failTestCases; + } else if (encryptionAlgorithm === deterministicAlgorithm) { + pass = passTestCases; + fail = [...failTestCases, ...failDeterministic]; + } - for (const passTestCase of pass) { - const encPassTestCase = shell.encrypt(keyId, passTestCase, encryptionAlgorithm); - assert.eq(passTestCase, shell.decrypt(encPassTestCase)); + for (const passTestCase of pass) { + const encPassTestCase = shell.encrypt(keyId, passTestCase, encryptionAlgorithm); + assert.eq(passTestCase, shell.decrypt(encPassTestCase)); - if (encryptionAlgorithm == deterministicAlgorithm) { - assert.eq(encPassTestCase, shell.encrypt(keyId, passTestCase, encryptionAlgorithm)); - } + if (encryptionAlgorithm == deterministicAlgorithm) { + assert.eq(encPassTestCase, shell.encrypt(keyId, passTestCase, encryptionAlgorithm)); } + } - for (const failTestCase of fail) { - assert.throws(shell.encrypt, [keyId, failTestCase, encryptionAlgorithm]); - } + for (const failTestCase of fail) { + assert.throws(shell.encrypt, [keyId, failTestCase, encryptionAlgorithm]); } +} - mock_kms.stop(); - print("Test completed with no errors."); +mock_kms.stop(); +print("Test completed with no errors."); }());
\ No newline at end of file diff --git a/jstests/client_encrypt/lib/mock_kms.js b/jstests/client_encrypt/lib/mock_kms.js index a7f34c37312..25556379c4a 100644 --- a/jstests/client_encrypt/lib/mock_kms.js +++ b/jstests/client_encrypt/lib/mock_kms.js @@ -18,11 +18,11 @@ const ENABLE_FAULTS = "enable_faults"; class MockKMSServer { /** - * Create a new webserver. - * - * @param {string} fault_type - * @param {bool} disableFaultsOnStartup optionally disable fault on startup - */ + * Create a new webserver. + * + * @param {string} fault_type + * @param {bool} disableFaultsOnStartup optionally disable fault on startup + */ constructor(fault_type, disableFaultsOnStartup) { this.python = "python3"; this.disableFaultsOnStartup = disableFaultsOnStartup || false; |