...

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

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

     1{
     2  "description": "addKeyAltName",
     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          "keyMaterial": {
    62            "$binary": {
    63              "base64": "ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==",
    64              "subType": "00"
    65            }
    66          },
    67          "creationDate": {
    68            "$date": {
    69              "$numberLong": "1641024000000"
    70            }
    71          },
    72          "updateDate": {
    73            "$date": {
    74              "$numberLong": "1641024000000"
    75            }
    76          },
    77          "status": 1,
    78          "masterKey": {
    79            "provider": "local"
    80          }
    81        }
    82      ]
    83    }
    84  ],
    85  "tests": [
    86    {
    87      "description": "add keyAltName to non-existent data key",
    88      "operations": [
    89        {
    90          "name": "addKeyAltName",
    91          "object": "clientEncryption0",
    92          "arguments": {
    93            "id": {
    94              "$binary": {
    95                "base64": "AAAjYWxrZXlsb2NhbGtleQ==",
    96                "subType": "04"
    97              }
    98            },
    99            "keyAltName": "new_key_alt_name"
   100          },
   101          "expectResult": {
   102            "$$unsetOrMatches": null
   103          }
   104        }
   105      ],
   106      "expectEvents": [
   107        {
   108          "client": "client0",
   109          "events": [
   110            {
   111              "commandStartedEvent": {
   112                "databaseName": "keyvault",
   113                "command": {
   114                  "findAndModify": "datakeys",
   115                  "query": {
   116                    "_id": {
   117                      "$binary": {
   118                        "base64": "AAAjYWxrZXlsb2NhbGtleQ==",
   119                        "subType": "04"
   120                      }
   121                    }
   122                  },
   123                  "update": {
   124                    "$addToSet": {
   125                      "keyAltNames": "new_key_alt_name"
   126                    }
   127                  },
   128                  "writeConcern": {
   129                    "w": "majority"
   130                  }
   131                }
   132              }
   133            }
   134          ]
   135        }
   136      ],
   137      "outcome": [
   138        {
   139          "collectionName": "datakeys",
   140          "databaseName": "keyvault",
   141          "documents": [
   142            {
   143              "_id": {
   144                "$binary": {
   145                  "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   146                  "subType": "04"
   147                }
   148              },
   149              "keyMaterial": {
   150                "$binary": {
   151                  "base64": "ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==",
   152                  "subType": "00"
   153                }
   154              },
   155              "creationDate": {
   156                "$date": {
   157                  "$numberLong": "1641024000000"
   158                }
   159              },
   160              "updateDate": {
   161                "$date": {
   162                  "$numberLong": "1641024000000"
   163                }
   164              },
   165              "status": 1,
   166              "masterKey": {
   167                "provider": "local"
   168              }
   169            }
   170          ]
   171        }
   172      ]
   173    },
   174    {
   175      "description": "add new keyAltName to data key with no keyAltNames",
   176      "operations": [
   177        {
   178          "name": "addKeyAltName",
   179          "object": "clientEncryption0",
   180          "arguments": {
   181            "id": {
   182              "$binary": {
   183                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   184                "subType": "04"
   185              }
   186            },
   187            "keyAltName": "local_key"
   188          },
   189          "expectResult": {
   190            "_id": {
   191              "$binary": {
   192                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   193                "subType": "04"
   194              }
   195            },
   196            "keyMaterial": {
   197              "$binary": {
   198                "base64": "ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==",
   199                "subType": "00"
   200              }
   201            },
   202            "creationDate": {
   203              "$date": {
   204                "$numberLong": "1641024000000"
   205              }
   206            },
   207            "updateDate": {
   208              "$date": {
   209                "$numberLong": "1641024000000"
   210              }
   211            },
   212            "status": 1,
   213            "masterKey": {
   214              "provider": "local"
   215            }
   216          }
   217        },
   218        {
   219          "name": "find",
   220          "object": "collection0",
   221          "arguments": {
   222            "filter": {},
   223            "projection": {
   224              "_id": 0,
   225              "keyAltNames": 1
   226            }
   227          },
   228          "expectResult": [
   229            {
   230              "keyAltNames": [
   231                "local_key"
   232              ]
   233            }
   234          ]
   235        }
   236      ],
   237      "expectEvents": [
   238        {
   239          "client": "client0",
   240          "events": [
   241            {
   242              "commandStartedEvent": {
   243                "databaseName": "keyvault",
   244                "command": {
   245                  "findAndModify": "datakeys",
   246                  "query": {
   247                    "_id": {
   248                      "$binary": {
   249                        "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   250                        "subType": "04"
   251                      }
   252                    }
   253                  },
   254                  "update": {
   255                    "$addToSet": {
   256                      "keyAltNames": "local_key"
   257                    }
   258                  },
   259                  "writeConcern": {
   260                    "w": "majority"
   261                  }
   262                }
   263              }
   264            },
   265            {
   266              "commandStartedEvent": {
   267                "commandName": "find"
   268              }
   269            }
   270          ]
   271        }
   272      ]
   273    },
   274    {
   275      "description": "add existing keyAltName to existing data key",
   276      "operations": [
   277        {
   278          "name": "addKeyAltName",
   279          "object": "clientEncryption0",
   280          "arguments": {
   281            "id": {
   282              "$binary": {
   283                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   284                "subType": "04"
   285              }
   286            },
   287            "keyAltName": "local_key"
   288          },
   289          "expectResult": {
   290            "_id": {
   291              "$binary": {
   292                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   293                "subType": "04"
   294              }
   295            },
   296            "keyMaterial": {
   297              "$binary": {
   298                "base64": "ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==",
   299                "subType": "00"
   300              }
   301            },
   302            "creationDate": {
   303              "$date": {
   304                "$numberLong": "1641024000000"
   305              }
   306            },
   307            "updateDate": {
   308              "$date": {
   309                "$numberLong": "1641024000000"
   310              }
   311            },
   312            "status": 1,
   313            "masterKey": {
   314              "provider": "local"
   315            }
   316          }
   317        },
   318        {
   319          "name": "addKeyAltName",
   320          "object": "clientEncryption0",
   321          "arguments": {
   322            "id": {
   323              "$binary": {
   324                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   325                "subType": "04"
   326              }
   327            },
   328            "keyAltName": "local_key"
   329          },
   330          "expectResult": {
   331            "_id": {
   332              "$binary": {
   333                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   334                "subType": "04"
   335              }
   336            },
   337            "keyAltNames": [
   338              "local_key"
   339            ],
   340            "keyMaterial": {
   341              "$$type": "binData"
   342            },
   343            "creationDate": {
   344              "$$type": "date"
   345            },
   346            "updateDate": {
   347              "$$type": "date"
   348            },
   349            "status": 1,
   350            "masterKey": {
   351              "provider": "local"
   352            }
   353          }
   354        },
   355        {
   356          "name": "find",
   357          "object": "collection0",
   358          "arguments": {
   359            "filter": {},
   360            "projection": {
   361              "_id": 0,
   362              "keyAltNames": 1
   363            }
   364          },
   365          "expectResult": [
   366            {
   367              "keyAltNames": [
   368                "local_key"
   369              ]
   370            }
   371          ]
   372        }
   373      ],
   374      "expectEvents": [
   375        {
   376          "client": "client0",
   377          "events": [
   378            {
   379              "commandStartedEvent": {
   380                "databaseName": "keyvault",
   381                "command": {
   382                  "findAndModify": "datakeys",
   383                  "query": {
   384                    "_id": {
   385                      "$binary": {
   386                        "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   387                        "subType": "04"
   388                      }
   389                    }
   390                  },
   391                  "update": {
   392                    "$addToSet": {
   393                      "keyAltNames": "local_key"
   394                    }
   395                  },
   396                  "writeConcern": {
   397                    "w": "majority"
   398                  }
   399                }
   400              }
   401            },
   402            {
   403              "commandStartedEvent": {
   404                "databaseName": "keyvault",
   405                "command": {
   406                  "findAndModify": "datakeys",
   407                  "query": {
   408                    "_id": {
   409                      "$binary": {
   410                        "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   411                        "subType": "04"
   412                      }
   413                    }
   414                  },
   415                  "update": {
   416                    "$addToSet": {
   417                      "keyAltNames": "local_key"
   418                    }
   419                  },
   420                  "writeConcern": {
   421                    "w": "majority"
   422                  }
   423                }
   424              }
   425            },
   426            {
   427              "commandStartedEvent": {
   428                "commandName": "find"
   429              }
   430            }
   431          ]
   432        }
   433      ]
   434    },
   435    {
   436      "description": "add new keyAltName to data key with keyAltNames",
   437      "operations": [
   438        {
   439          "name": "addKeyAltName",
   440          "object": "clientEncryption0",
   441          "arguments": {
   442            "id": {
   443              "$binary": {
   444                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   445                "subType": "04"
   446              }
   447            },
   448            "keyAltName": "local_key"
   449          },
   450          "expectResult": {
   451            "_id": {
   452              "$binary": {
   453                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   454                "subType": "04"
   455              }
   456            },
   457            "keyMaterial": {
   458              "$binary": {
   459                "base64": "ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==",
   460                "subType": "00"
   461              }
   462            },
   463            "creationDate": {
   464              "$date": {
   465                "$numberLong": "1641024000000"
   466              }
   467            },
   468            "updateDate": {
   469              "$date": {
   470                "$numberLong": "1641024000000"
   471              }
   472            },
   473            "status": 1,
   474            "masterKey": {
   475              "provider": "local"
   476            }
   477          }
   478        },
   479        {
   480          "name": "addKeyAltName",
   481          "object": "clientEncryption0",
   482          "arguments": {
   483            "id": {
   484              "$binary": {
   485                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   486                "subType": "04"
   487              }
   488            },
   489            "keyAltName": "another_name"
   490          },
   491          "expectResult": {
   492            "_id": {
   493              "$binary": {
   494                "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   495                "subType": "04"
   496              }
   497            },
   498            "keyAltNames": [
   499              "local_key"
   500            ],
   501            "keyMaterial": {
   502              "$$type": "binData"
   503            },
   504            "creationDate": {
   505              "$$type": "date"
   506            },
   507            "updateDate": {
   508              "$$type": "date"
   509            },
   510            "status": 1,
   511            "masterKey": {
   512              "provider": "local"
   513            }
   514          }
   515        },
   516        {
   517          "name": "aggregate",
   518          "object": "collection0",
   519          "arguments": {
   520            "pipeline": [
   521              {
   522                "$project": {
   523                  "_id": 0,
   524                  "keyAltNames": "$keyAltNames"
   525                }
   526              },
   527              {
   528                "$unwind": "$keyAltNames"
   529              },
   530              {
   531                "$sort": {
   532                  "keyAltNames": 1
   533                }
   534              }
   535            ]
   536          },
   537          "expectResult": [
   538            {
   539              "keyAltNames": "another_name"
   540            },
   541            {
   542              "keyAltNames": "local_key"
   543            }
   544          ]
   545        }
   546      ],
   547      "expectEvents": [
   548        {
   549          "client": "client0",
   550          "events": [
   551            {
   552              "commandStartedEvent": {
   553                "databaseName": "keyvault",
   554                "command": {
   555                  "findAndModify": "datakeys",
   556                  "query": {
   557                    "_id": {
   558                      "$binary": {
   559                        "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   560                        "subType": "04"
   561                      }
   562                    }
   563                  },
   564                  "update": {
   565                    "$addToSet": {
   566                      "keyAltNames": "local_key"
   567                    }
   568                  },
   569                  "writeConcern": {
   570                    "w": "majority"
   571                  }
   572                }
   573              }
   574            },
   575            {
   576              "commandStartedEvent": {
   577                "databaseName": "keyvault",
   578                "command": {
   579                  "findAndModify": "datakeys",
   580                  "query": {
   581                    "_id": {
   582                      "$binary": {
   583                        "base64": "bG9jYWxrZXlsb2NhbGtleQ==",
   584                        "subType": "04"
   585                      }
   586                    }
   587                  },
   588                  "update": {
   589                    "$addToSet": {
   590                      "keyAltNames": "another_name"
   591                    }
   592                  },
   593                  "writeConcern": {
   594                    "w": "majority"
   595                  }
   596                }
   597              }
   598            },
   599            {
   600              "commandStartedEvent": {
   601                "commandName": "aggregate"
   602              }
   603            }
   604          ]
   605        }
   606      ]
   607    }
   608  ]
   609}

View as plain text