Skip to content

Commit 0726016

Browse files
authored
DRIVERS-2406 add Rewrap prose test (#1287)
1 parent 3200d46 commit 0726016

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

source/client-side-encryption/tests/README.rst

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,3 +2012,105 @@ the environment.
20122012
.. _Automatic AWS Credentials: ../client-side-encryption.rst#automatic-aws-credentials
20132013
.. _ClientEncryption: ../client-side-encryption.rst#clientencryption
20142014
.. _auth-aws: ../../auth/auth.rst#obtaining-credentials
2015+
2016+
16. Rewrap
2017+
~~~~~~~~~~
2018+
2019+
Case 1: Rewrap with separate ClientEncryption
2020+
`````````````````````````````````````````````
2021+
2022+
When the following test case requests setting ``masterKey``, use the following values based on the KMS provider:
2023+
2024+
For "aws":
2025+
2026+
.. code:: javascript
2027+
2028+
{
2029+
"region": "us-east-1",
2030+
"key": "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0"
2031+
}
2032+
2033+
For "azure":
2034+
2035+
.. code:: javascript
2036+
2037+
{
2038+
"keyVaultEndpoint": "key-vault-csfle.vault.azure.net",
2039+
"keyName": "key-name-csfle"
2040+
}
2041+
2042+
For "gcp":
2043+
2044+
.. code:: javascript
2045+
2046+
{
2047+
"projectId": "devprod-drivers",
2048+
"location": "global",
2049+
"keyRing": "key-ring-csfle",
2050+
"keyName": "key-name-csfle"
2051+
}
2052+
2053+
For "kmip":
2054+
2055+
.. code:: javascript
2056+
2057+
{}
2058+
2059+
For "local", do not set a masterKey document.
2060+
2061+
Run the following test case for each pair of KMS providers (referred to as ``srcProvider`` and ``dstProvider``).
2062+
Include pairs where ``srcProvider`` equals ``dstProvider``.
2063+
2064+
1. Drop the collection ``keyvault.datakeys``.
2065+
2066+
2. Create a ``ClientEncryption`` object named ``clientEncryption1`` with these options:
2067+
.. code:: typescript
2068+
2069+
ClientEncryptionOpts {
2070+
keyVaultClient: <new MongoClient>;
2071+
keyVaultNamespace: "keyvault.datakeys";
2072+
kmsProviders: <all KMS providers>
2073+
}
2074+
2075+
3. Call ``clientEncryption1.createDataKey`` with ``srcProvider`` and these options:
2076+
.. code:: typescript
2077+
2078+
class DataKeyOpts {
2079+
masterKey: <depends on srcProvider>
2080+
}
2081+
2082+
Store the return value in ``keyID``.
2083+
2084+
4. Call ``clientEncryption1.encrypt`` with the value "test" and these options:
2085+
.. code:: typescript
2086+
2087+
class EncryptOpts {
2088+
keyId : keyID,
2089+
algorithm: "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
2090+
}
2091+
2092+
Store the return value in ``ciphertext``.
2093+
2094+
5. Create a ``ClientEncryption`` object named ``clientEncryption2`` with these options:
2095+
.. code:: typescript
2096+
2097+
ClientEncryptionOpts {
2098+
keyVaultClient: <new MongoClient>;
2099+
keyVaultNamespace: "keyvault.datakeys";
2100+
kmsProviders: <all KMS providers>
2101+
}
2102+
2103+
6. Call ``clientEncryption2.rewrapManyDataKey`` with an empty ``filter`` and these options:
2104+
2105+
.. code:: typescript
2106+
2107+
class RewrapManyDataKeyOpts {
2108+
provider: dstProvider
2109+
masterKey: <depends on dstProvider>
2110+
}
2111+
2112+
Assert that the returned ``RewrapManyDataKeyResult.bulkWriteResult.modifiedCount`` is 1.
2113+
2114+
7. Call ``clientEncryption1.decrypt`` with the ``ciphertext``. Assert the return value is "test".
2115+
2116+
8. Call ``clientEncryption2.decrypt`` with the ``ciphertext``. Assert the return value is "test".

0 commit comments

Comments
 (0)