...

Text file src/go.mongodb.org/mongo-driver/testdata/client-side-encryption/unified/removeKeyAltName.json

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

     1{
     2  "description": "removeKeyAltName",
     3  "schemaVersion": "1.8",
     4  "runOnRequirements": [
     5    {
     6      "csfle": true
     7    }
     8  ],
     9  "createEntities": [
    10    {
    11      "client": {
    12        "id": "client0",
    13        "observeEvents": [
    14          "commandStartedEvent"
    15        ]
    16      }
    17    },
    18    {
    19      "clientEncryption": {
    20        "id": "clientEncryption0",
    21        "clientEncryptionOpts": {
    22          "keyVaultClient": "client0",
    23          "keyVaultNamespace": "keyvault.datakeys",
    24          "kmsProviders": {
    25            "local": {
    26              "key": {
    27                "$$placeholder": 1
    28              }
    29            }
    30          }
    31        }
    32      }
    33    },
    34    {
    35      "database": {
    36        "id": "database0",
    37        "client": "client0",
    38        "databaseName": "keyvault"
    39      }
    40    },
    41    {
    42      "collection": {
    43        "id": "collection0",
    44        "database": "database0",
    45        "collectionName": "datakeys"
    46      }
    47    }
    48  ],
    49  "initialData": [
    50    {
    51      "databaseName": "keyvault",
    52      "collectionName": "datakeys",
    53      "documents": [
    54        {
    55          "_id": {
    56            "$binary": {
    57              "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
    58              "subType": "04"
    59            }
    60          },
    61          "keyAltNames": [
    62            "alternate_name",
    63            "local_key"
    64          ],
    65          "keyMaterial": {
    66            "$binary": {
    67              "base64": "ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==",
    68              "subType": "00"
    69            }
    70          },
    71          "creationDate": {
    72            "$date": {
    73              "$numberLong": "1641024000000"
    74            }
    75          },
    76          "updateDate": {
    77            "$date": {
    78              "$numberLong": "1641024000000"
    79            }
    80          },
    81          "status": 1,
    82          "masterKey": {
    83            "provider": "local"
    84          }
    85        }
    86      ]
    87    }
    88  ],
    89  "tests": [
    90    {
    91      "description": "remove keyAltName from non-existent data key",
    92      "operations": [
    93        {
    94          "name": "removeKeyAltName",
    95          "object": "clientEncryption0",
    96          "arguments": {
    97            "id": {
    98              "$binary": {
    99                "base64": "AAAjYWxrZXlsb2NhbGtleQ==",
   100                "subType": "04"
   101              }
   102            },
   103            "keyAltName": "does_not_exist"
   104          },
   105          "expectResult": {
   106            "$$unsetOrMatches": null
   107          }
   108        }
   109      ],
   110      "expectEvents": [
   111        {
   112          "client": "client0",
   113          "events": [
   114            {
   115              "commandStartedEvent": {
   116                "databaseName": "keyvault",
   117                "command": {
   118                  "findAndModify": "datakeys",
   119                  "query": {
   120                    "_id": {
   121                      "$binary": {
   122                        "base64": "AAAjYWxrZXlsb2NhbGtleQ==",
   123                        "subType": "04"
   124                      }
   125                    }
   126                  },
   127                  "update": [
   128                    {
   129                      "$set": {
   130                        "keyAltNames": {
   131                          "$cond": [
   132                            {
   133                              "$eq": [
   134                                "$keyAltNames",
   135                                [
   136                                  "does_not_exist"
   137                                ]
   138                              ]
   139                            },
   140                            "$$REMOVE",
   141                            {
   142                              "$filter": {
   143                                "input": "$keyAltNames",
   144                                "cond": {
   145                                  "$ne": [
   146                                    "$$this",
   147                                    "does_not_exist"
   148                                  ]
   149                                }
   150                              }
   151                            }
   152                          ]
   153                        }
   154                      }
   155                    }
   156                  ],
   157                  "writeConcern": {
   158                    "w": "majority"
   159                  }
   160                }
   161              }
   162            }
   163          ]
   164        }
   165      ],
   166      "outcome": [
   167        {
   168          "collectionName": "datakeys",
   169          "databaseName": "keyvault",
   170          "documents": [
   171            {
   172              "_id": {
   173                "$binary": {
   174                  "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   175                  "subType": "04"
   176                }
   177              },
   178              "keyAltNames": [
   179                "alternate_name",
   180                "local_key"
   181              ],
   182              "keyMaterial": {
   183                "$binary": {
   184                  "base64": "ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==",
   185                  "subType": "00"
   186                }
   187              },
   188              "creationDate": {
   189                "$date": {
   190                  "$numberLong": "1641024000000"
   191                }
   192              },
   193              "updateDate": {
   194                "$date": {
   195                  "$numberLong": "1641024000000"
   196                }
   197              },
   198              "status": 1,
   199              "masterKey": {
   200                "provider": "local"
   201              }
   202            }
   203          ]
   204        }
   205      ]
   206    },
   207    {
   208      "description": "remove non-existent keyAltName from existing data key",
   209      "operations": [
   210        {
   211          "name": "removeKeyAltName",
   212          "object": "clientEncryption0",
   213          "arguments": {
   214            "id": {
   215              "$binary": {
   216                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   217                "subType": "04"
   218              }
   219            },
   220            "keyAltName": "does_not_exist"
   221          },
   222          "expectResult": {
   223            "_id": {
   224              "$binary": {
   225                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   226                "subType": "04"
   227              }
   228            },
   229            "keyAltNames": [
   230              "alternate_name",
   231              "local_key"
   232            ],
   233            "keyMaterial": {
   234              "$binary": {
   235                "base64": "ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==",
   236                "subType": "00"
   237              }
   238            },
   239            "creationDate": {
   240              "$date": {
   241                "$numberLong": "1641024000000"
   242              }
   243            },
   244            "updateDate": {
   245              "$date": {
   246                "$numberLong": "1641024000000"
   247              }
   248            },
   249            "status": 1,
   250            "masterKey": {
   251              "provider": "local"
   252            }
   253          }
   254        }
   255      ],
   256      "expectEvents": [
   257        {
   258          "client": "client0",
   259          "events": [
   260            {
   261              "commandStartedEvent": {
   262                "databaseName": "keyvault",
   263                "command": {
   264                  "findAndModify": "datakeys",
   265                  "query": {
   266                    "_id": {
   267                      "$binary": {
   268                        "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   269                        "subType": "04"
   270                      }
   271                    }
   272                  },
   273                  "update": [
   274                    {
   275                      "$set": {
   276                        "keyAltNames": {
   277                          "$cond": [
   278                            {
   279                              "$eq": [
   280                                "$keyAltNames",
   281                                [
   282                                  "does_not_exist"
   283                                ]
   284                              ]
   285                            },
   286                            "$$REMOVE",
   287                            {
   288                              "$filter": {
   289                                "input": "$keyAltNames",
   290                                "cond": {
   291                                  "$ne": [
   292                                    "$$this",
   293                                    "does_not_exist"
   294                                  ]
   295                                }
   296                              }
   297                            }
   298                          ]
   299                        }
   300                      }
   301                    }
   302                  ],
   303                  "writeConcern": {
   304                    "w": "majority"
   305                  }
   306                }
   307              }
   308            }
   309          ]
   310        }
   311      ],
   312      "outcome": [
   313        {
   314          "collectionName": "datakeys",
   315          "databaseName": "keyvault",
   316          "documents": [
   317            {
   318              "_id": {
   319                "$binary": {
   320                  "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   321                  "subType": "04"
   322                }
   323              },
   324              "keyAltNames": [
   325                "alternate_name",
   326                "local_key"
   327              ],
   328              "keyMaterial": {
   329                "$binary": {
   330                  "base64": "ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==",
   331                  "subType": "00"
   332                }
   333              },
   334              "creationDate": {
   335                "$date": {
   336                  "$numberLong": "1641024000000"
   337                }
   338              },
   339              "updateDate": {
   340                "$date": {
   341                  "$numberLong": "1641024000000"
   342                }
   343              },
   344              "status": 1,
   345              "masterKey": {
   346                "provider": "local"
   347              }
   348            }
   349          ]
   350        }
   351      ]
   352    },
   353    {
   354      "description": "remove an existing keyAltName from an existing data key",
   355      "operations": [
   356        {
   357          "name": "removeKeyAltName",
   358          "object": "clientEncryption0",
   359          "arguments": {
   360            "id": {
   361              "$binary": {
   362                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   363                "subType": "04"
   364              }
   365            },
   366            "keyAltName": "alternate_name"
   367          },
   368          "expectResult": {
   369            "_id": {
   370              "$binary": {
   371                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   372                "subType": "04"
   373              }
   374            },
   375            "keyAltNames": [
   376              "alternate_name",
   377              "local_key"
   378            ],
   379            "keyMaterial": {
   380              "$binary": {
   381                "base64": "ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==",
   382                "subType": "00"
   383              }
   384            },
   385            "creationDate": {
   386              "$date": {
   387                "$numberLong": "1641024000000"
   388              }
   389            },
   390            "updateDate": {
   391              "$date": {
   392                "$numberLong": "1641024000000"
   393              }
   394            },
   395            "status": 1,
   396            "masterKey": {
   397              "provider": "local"
   398            }
   399          }
   400        },
   401        {
   402          "name": "find",
   403          "object": "collection0",
   404          "arguments": {
   405            "filter": {},
   406            "projection": {
   407              "_id": 0,
   408              "keyAltNames": 1
   409            }
   410          },
   411          "expectResult": [
   412            {
   413              "keyAltNames": [
   414                "local_key"
   415              ]
   416            }
   417          ]
   418        }
   419      ],
   420      "expectEvents": [
   421        {
   422          "client": "client0",
   423          "events": [
   424            {
   425              "commandStartedEvent": {
   426                "databaseName": "keyvault",
   427                "command": {
   428                  "findAndModify": "datakeys",
   429                  "query": {
   430                    "_id": {
   431                      "$binary": {
   432                        "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   433                        "subType": "04"
   434                      }
   435                    }
   436                  },
   437                  "update": [
   438                    {
   439                      "$set": {
   440                        "keyAltNames": {
   441                          "$cond": [
   442                            {
   443                              "$eq": [
   444                                "$keyAltNames",
   445                                [
   446                                  "alternate_name"
   447                                ]
   448                              ]
   449                            },
   450                            "$$REMOVE",
   451                            {
   452                              "$filter": {
   453                                "input": "$keyAltNames",
   454                                "cond": {
   455                                  "$ne": [
   456                                    "$$this",
   457                                    "alternate_name"
   458                                  ]
   459                                }
   460                              }
   461                            }
   462                          ]
   463                        }
   464                      }
   465                    }
   466                  ],
   467                  "writeConcern": {
   468                    "w": "majority"
   469                  }
   470                }
   471              }
   472            },
   473            {
   474              "commandStartedEvent": {
   475                "commandName": "find"
   476              }
   477            }
   478          ]
   479        }
   480      ]
   481    },
   482    {
   483      "description": "remove the last keyAltName from an existing data key",
   484      "operations": [
   485        {
   486          "name": "removeKeyAltName",
   487          "object": "clientEncryption0",
   488          "arguments": {
   489            "id": {
   490              "$binary": {
   491                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   492                "subType": "04"
   493              }
   494            },
   495            "keyAltName": "alternate_name"
   496          },
   497          "expectResult": {
   498            "_id": {
   499              "$binary": {
   500                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   501                "subType": "04"
   502              }
   503            },
   504            "keyAltNames": [
   505              "alternate_name",
   506              "local_key"
   507            ],
   508            "keyMaterial": {
   509              "$binary": {
   510                "base64": "ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==",
   511                "subType": "00"
   512              }
   513            },
   514            "creationDate": {
   515              "$date": {
   516                "$numberLong": "1641024000000"
   517              }
   518            },
   519            "updateDate": {
   520              "$date": {
   521                "$numberLong": "1641024000000"
   522              }
   523            },
   524            "status": 1,
   525            "masterKey": {
   526              "provider": "local"
   527            }
   528          }
   529        },
   530        {
   531          "name": "removeKeyAltName",
   532          "object": "clientEncryption0",
   533          "arguments": {
   534            "id": {
   535              "$binary": {
   536                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   537                "subType": "04"
   538              }
   539            },
   540            "keyAltName": "local_key"
   541          },
   542          "expectResult": {
   543            "_id": {
   544              "$binary": {
   545                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   546                "subType": "04"
   547              }
   548            },
   549            "keyAltNames": [
   550              "local_key"
   551            ],
   552            "keyMaterial": {
   553              "$$type": "binData"
   554            },
   555            "creationDate": {
   556              "$$type": "date"
   557            },
   558            "updateDate": {
   559              "$$type": "date"
   560            },
   561            "status": 1,
   562            "masterKey": {
   563              "provider": "local"
   564            }
   565          }
   566        }
   567      ],
   568      "expectEvents": [
   569        {
   570          "client": "client0",
   571          "events": [
   572            {
   573              "commandStartedEvent": {
   574                "databaseName": "keyvault",
   575                "command": {
   576                  "findAndModify": "datakeys",
   577                  "query": {
   578                    "_id": {
   579                      "$binary": {
   580                        "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   581                        "subType": "04"
   582                      }
   583                    }
   584                  },
   585                  "update": [
   586                    {
   587                      "$set": {
   588                        "keyAltNames": {
   589                          "$cond": [
   590                            {
   591                              "$eq": [
   592                                "$keyAltNames",
   593                                [
   594                                  "alternate_name"
   595                                ]
   596                              ]
   597                            },
   598                            "$$REMOVE",
   599                            {
   600                              "$filter": {
   601                                "input": "$keyAltNames",
   602                                "cond": {
   603                                  "$ne": [
   604                                    "$$this",
   605                                    "alternate_name"
   606                                  ]
   607                                }
   608                              }
   609                            }
   610                          ]
   611                        }
   612                      }
   613                    }
   614                  ],
   615                  "writeConcern": {
   616                    "w": "majority"
   617                  }
   618                }
   619              }
   620            },
   621            {
   622              "commandStartedEvent": {
   623                "databaseName": "keyvault",
   624                "command": {
   625                  "findAndModify": "datakeys",
   626                  "query": {
   627                    "_id": {
   628                      "$binary": {
   629                        "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   630                        "subType": "04"
   631                      }
   632                    }
   633                  },
   634                  "update": [
   635                    {
   636                      "$set": {
   637                        "keyAltNames": {
   638                          "$cond": [
   639                            {
   640                              "$eq": [
   641                                "$keyAltNames",
   642                                [
   643                                  "local_key"
   644                                ]
   645                              ]
   646                            },
   647                            "$$REMOVE",
   648                            {
   649                              "$filter": {
   650                                "input": "$keyAltNames",
   651                                "cond": {
   652                                  "$ne": [
   653                                    "$$this",
   654                                    "local_key"
   655                                  ]
   656                                }
   657                              }
   658                            }
   659                          ]
   660                        }
   661                      }
   662                    }
   663                  ]
   664                }
   665              }
   666            }
   667          ]
   668        }
   669      ]
   670    }
   671  ]
   672}

View as plain text