...

Text file src/go.mongodb.org/mongo-driver/testdata/client-side-encryption/legacy/fle2v2-Update.yml

Documentation: go.mongodb.org/mongo-driver/testdata/client-side-encryption/legacy

     1# Requires libmongocrypt 1.8.0.
     2runOn:
     3  - minServerVersion: "7.0.0"
     4    # Skip QEv2 (also referred to as FLE2v2) tests on Serverless. Unskip once Serverless enables the QEv2 protocol.
     5    # FLE 2 Encrypted collections are not supported on standalone.
     6    topology: [ "replicaset", "sharded", "load-balanced" ]
     7database_name: &database_name "default"
     8collection_name: &collection_name "default"
     9data: []
    10encrypted_fields: &encrypted_fields {'fields': [{'keyId': {'$binary': {'base64': 'EjRWeBI0mHYSNBI0VniQEg==', 'subType': '04'}}, 'path': 'encryptedIndexed', 'bsonType': 'string', 'queries': {'queryType': 'equality', 'contention': {'$numberLong': '0'}}}, {'keyId': {'$binary': {'base64': 'q83vqxI0mHYSNBI0VniQEg==', 'subType': '04'}}, 'path': 'encryptedUnindexed', 'bsonType': 'string'}]}
    11key_vault_data: [ {'_id': {'$binary': {'base64': 'EjRWeBI0mHYSNBI0VniQEg==', 'subType': '04'}}, 'keyMaterial': {'$binary': {'base64': 'sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==', 'subType': '00'}}, 'creationDate': {'$date': {'$numberLong': '1648914851981'}}, 'updateDate': {'$date': {'$numberLong': '1648914851981'}}, 'status': {'$numberInt': '0'}, 'masterKey': {'provider': 'local'}} ]
    12tests:
    13  - description: "Update can query an FLE2 indexed field"
    14    clientOptions:
    15      autoEncryptOpts:
    16        kmsProviders:
    17          local: {'key': {'$binary': {'base64': 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk', 'subType': '00'}}}
    18    operations:
    19      - name: insertOne
    20        arguments:
    21          document: {"_id": 1, "encryptedIndexed": "value123" }
    22      - name: updateOne
    23        arguments:
    24          filter: { "encryptedIndexed": "value123" }
    25          update: { "$set": { "foo": "bar"}}
    26        result:
    27          matchedCount: 1
    28          modifiedCount: 1
    29          upsertedCount: 0
    30    expectations:
    31      - command_started_event:
    32          command:
    33            listCollections: 1
    34            filter:
    35              name: *collection_name
    36          command_name: listCollections
    37      - command_started_event:
    38          command:
    39            find: datakeys
    40            filter: {
    41                  "$or": [
    42                      {
    43                          "_id": {
    44                              "$in": [
    45                                  {'$binary': {'base64': 'EjRWeBI0mHYSNBI0VniQEg==', 'subType': '04'}}
    46                              ]
    47                          }
    48                      },
    49                      {
    50                          "keyAltNames": {
    51                              "$in": []
    52                          }
    53                      }
    54                  ]
    55              }
    56            $db: keyvault
    57            readConcern: { level: "majority" }
    58          command_name: find
    59      - command_started_event:
    60          command:
    61            insert: *collection_name
    62            documents:
    63              - { "_id": 1, "encryptedIndexed": { $$type: "binData" } }
    64            ordered: true
    65            encryptionInformation:
    66              type: 1
    67              schema:
    68                "default.default":
    69                  # libmongocrypt applies escCollection and ecocCollection to outgoing command.
    70                  escCollection: "enxcol_.default.esc"
    71                  ecocCollection: "enxcol_.default.ecoc"
    72                  <<: *encrypted_fields
    73
    74          command_name: insert
    75      - command_started_event:
    76          command:
    77            update: *collection_name
    78            updates:
    79              - {
    80                  "q": {
    81                    "encryptedIndexed": { 
    82                      "$eq": {
    83                        "$binary": {
    84                            "base64": "DIkAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVsACAAAAAAaZ9s3G+4znfxStxeOZwcZy1OhzjMGc5hjmdMN+b/w6kSY20AAAAAAAAAAAAA",
    85                            "subType": "06"
    86                        }
    87                      }
    88                    }
    89                  },
    90                  "u": { "$set": { "foo": "bar"} }
    91                }
    92            ordered: true
    93            encryptionInformation:
    94              type: 1
    95              schema:
    96                "default.default":
    97                  # libmongocrypt applies escCollection and ecocCollection to outgoing command.
    98                  escCollection: "enxcol_.default.esc"
    99                  ecocCollection: "enxcol_.default.ecoc"
   100                  <<: *encrypted_fields
   101
   102          command_name: update
   103    outcome:
   104      collection:
   105        data:
   106          - { "_id": 1, "encryptedIndexed": { "$$type": "binData" }, "foo": "bar", "__safeContent__": [{ "$binary" : { "base64" : "ThpoKfQ8AkOzkFfNC1+9PF0pY2nIzfXvRdxQgjkNbBw=", "subType" : "00" } }] }
   107  - description: "Update can modify an FLE2 indexed field"
   108    clientOptions:
   109      autoEncryptOpts:
   110        kmsProviders:
   111          local: {'key': {'$binary': {'base64': 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk', 'subType': '00'}}}
   112    operations:
   113      - name: insertOne
   114        arguments:
   115          document: {"_id": 1, "encryptedIndexed": "value123" }
   116      - name: updateOne
   117        arguments:
   118          filter: { "encryptedIndexed": "value123" }
   119          update: { "$set": { "encryptedIndexed": "value456"}}
   120        result:
   121          matchedCount: 1
   122          modifiedCount: 1
   123          upsertedCount: 0
   124      - name: find
   125        arguments:
   126          filter: { "_id": 1}
   127        result:
   128          [ "encryptedIndexed": "value456" ]
   129    expectations:
   130      - command_started_event:
   131          command:
   132            listCollections: 1
   133            filter:
   134              name: *collection_name
   135          command_name: listCollections
   136      - command_started_event:
   137          command:
   138            find: datakeys
   139            filter: {
   140                  "$or": [
   141                      {
   142                          "_id": {
   143                              "$in": [
   144                                  {'$binary': {'base64': 'EjRWeBI0mHYSNBI0VniQEg==', 'subType': '04'}}
   145                              ]
   146                          }
   147                      },
   148                      {
   149                          "keyAltNames": {
   150                              "$in": []
   151                          }
   152                      }
   153                  ]
   154              }
   155            $db: keyvault
   156            readConcern: { level: "majority" }
   157          command_name: find
   158      - command_started_event:
   159          command:
   160            insert: *collection_name
   161            documents:
   162              - { "_id": 1, "encryptedIndexed": { $$type: "binData" } }
   163            ordered: true
   164            encryptionInformation:
   165              type: 1
   166              schema:
   167                "default.default":
   168                  # libmongocrypt applies escCollection and ecocCollection to outgoing command.
   169                  escCollection: "enxcol_.default.esc"
   170                  ecocCollection: "enxcol_.default.ecoc"
   171                  <<: *encrypted_fields
   172
   173          command_name: insert
   174      - command_started_event:
   175          command:
   176            update: *collection_name
   177            updates:
   178              - {
   179                  "q": {
   180                    "encryptedIndexed": { 
   181                      "$eq": {
   182                        "$binary": {
   183                            "base64": "DIkAAAAFZAAgAAAAAPtVteJQAlgb2YMa/+7YWH00sbQPyt7L6Rb8OwBdMmL2BXMAIAAAAAAd44hgVKnEnTFlwNVC14oyc9OZOTspeymusqkRQj57nAVsACAAAAAAaZ9s3G+4znfxStxeOZwcZy1OhzjMGc5hjmdMN+b/w6kSY20AAAAAAAAAAAAA",
   184                            "subType": "06"
   185                        }
   186                      }
   187                    }
   188                  },
   189                  "u": { "$set": { "encryptedIndexed": { "$$type": "binData" }} }
   190                }
   191            ordered: true
   192            encryptionInformation:
   193              type: 1
   194              schema:
   195                "default.default":
   196                  # libmongocrypt applies escCollection and ecocCollection to outgoing command.
   197                  escCollection: "enxcol_.default.esc"
   198                  ecocCollection: "enxcol_.default.ecoc"
   199                  <<: *encrypted_fields
   200
   201          command_name: update
   202      - command_started_event:
   203          command:
   204            find: *collection_name
   205            filter: { "_id": { "$eq": 1 }}
   206          command_name: find
   207    outcome:
   208      collection:
   209        data:
   210          - { "_id": 1, "encryptedIndexed": { "$$type": "binData" }, "__safeContent__": [{ "$binary" : { "base64" : "rhe7/w8Ob8Unl44rGr/moScx6m5VODQnscDhF4Nkn6g=", "subType" : "00" } }] }

View as plain text