File: addKeyAltName.yml

package info (click to toggle)
golang-mongodb-mongo-driver 1.17.1%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 25,988 kB
  • sloc: perl: 533; ansic: 491; python: 432; sh: 327; makefile: 174
file content (194 lines) | stat: -rw-r--r-- 6,687 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
description: addKeyAltName

schemaVersion: "1.8"

runOnRequirements:
  - csfle: true

createEntities:
  - client:
      id: &client0 client0
      observeEvents:
        - commandStartedEvent
  - clientEncryption:
      id: &clientEncryption0 clientEncryption0
      clientEncryptionOpts:
        keyVaultClient: *client0
        keyVaultNamespace: keyvault.datakeys
        kmsProviders:
          local: { key: { $$placeholder: 1 } }
  - database:
      id: &database0 database0
      client: *client0
      databaseName: &database0Name keyvault
  - collection:
      id: &collection0 collection0
      database: *database0
      collectionName: &collection0Name datakeys

initialData:
  - databaseName: *database0Name
    collectionName: *collection0Name
    documents:
      - &local_key_doc
        _id: &local_key_id { $binary: { base64: bG9jYWxrZXlsb2NhbGtleQ==, subType: "04" } }
        keyMaterial: { $binary: { base64: ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==, subType: "00" } }
        creationDate: { $date: { $numberLong: "1641024000000" } }
        updateDate: { $date: { $numberLong: "1641024000000" } }
        status: 1
        masterKey:
          provider: local

tests:
  - description: add keyAltName to non-existent data key
    operations:
      - name: addKeyAltName
        object: *clientEncryption0
        arguments:
          # First 3 letters of local_key_id replaced with 'A' (value: "#alkeylocalkey").
          id: &non_existent_id { $binary: { base64: AAAjYWxrZXlsb2NhbGtleQ==, subType: "04" } }
          keyAltName: new_key_alt_name
        expectResult: { $$unsetOrMatches: null }
    expectEvents:
      - client: *client0
        events:
          - commandStartedEvent:
              databaseName: *database0Name
              command:
                findAndModify: *collection0Name
                query: { _id: *non_existent_id }
                update: { $addToSet: { keyAltNames: new_key_alt_name } }
                writeConcern: { w: majority }
    outcome:
      - collectionName: *collection0Name
        databaseName: *database0Name
        documents:
          - *local_key_doc

  - description: add new keyAltName to data key with no keyAltNames
    operations:
      - name: addKeyAltName
        object: *clientEncryption0
        arguments:
          id: *local_key_id
          keyAltName: local_key
        expectResult: *local_key_doc
      - name: find
        object: *collection0
        arguments:
          filter: {}
          projection: { _id: 0, keyAltNames: 1 }
        expectResult:
          - keyAltNames: [local_key]
    expectEvents:
      - client: *client0
        events:
          - commandStartedEvent:
              databaseName: *database0Name
              command:
                findAndModify: *collection0Name
                query: { _id: *local_key_id }
                update: { $addToSet: { keyAltNames: local_key } }
                writeConcern: { w: majority }
          - commandStartedEvent: { commandName: find }

  - description: add existing keyAltName to existing data key
    operations:
      - name: addKeyAltName
        object: *clientEncryption0
        arguments:
          id: *local_key_id
          keyAltName: local_key
        expectResult: *local_key_doc
      - name: addKeyAltName
        # Attempting to add a duplicate keyAltName to the data key should not be an error.
        object: *clientEncryption0
        arguments:
          id: *local_key_id
          keyAltName: local_key
        expectResult:
          _id: *local_key_id
          keyAltNames: [local_key]
          keyMaterial: { $$type: binData }
          creationDate: { $$type: date }
          updateDate: { $$type: date }
          status: 1
          masterKey:
            provider: local
      - name: find
        object: *collection0
        arguments:
          filter: {}
          projection: { _id: 0, keyAltNames: 1 }
        expectResult:
          - keyAltNames: [local_key]
    expectEvents:
      - client: *client0
        events:
          - commandStartedEvent:
              databaseName: *database0Name
              command:
                findAndModify: *collection0Name
                query: { _id: *local_key_id }
                update: { $addToSet: { keyAltNames: local_key } }
                writeConcern: { w: majority }
          - commandStartedEvent:
              databaseName: *database0Name
              command:
                findAndModify: *collection0Name
                query: { _id: *local_key_id }
                update: { $addToSet: { keyAltNames: local_key } }
                writeConcern: { w: majority }
          - commandStartedEvent: { commandName: find }

  - description: add new keyAltName to data key with keyAltNames
    operations:
      - name: addKeyAltName
        object: *clientEncryption0
        arguments:
          id: *local_key_id
          keyAltName: local_key
        expectResult: *local_key_doc
      - name: addKeyAltName
        object: *clientEncryption0
        arguments:
          id: *local_key_id
          keyAltName: another_name
        expectResult:
          _id: *local_key_id
          keyAltNames: [local_key]
          keyMaterial: { $$type: binData }
          creationDate: { $$type: date }
          updateDate: { $$type: date }
          status: 1
          masterKey:
            provider: local
      - name: aggregate
        object: *collection0
        arguments:
          pipeline:
            # Ensure keyAltNames are in deterministically sorted order.
            - $project: { _id: 0, keyAltNames: $keyAltNames }
            - $unwind: $keyAltNames
            - $sort: { keyAltNames: 1 }
        expectResult:
          - keyAltNames: another_name
          - keyAltNames: local_key
    expectEvents:
      - client: *client0
        events:
          - commandStartedEvent:
              databaseName: *database0Name
              command:
                findAndModify: *collection0Name
                query: { _id: *local_key_id }
                update: { $addToSet: { keyAltNames: local_key } }
                writeConcern: { w: majority }
          - commandStartedEvent:
              databaseName: *database0Name
              command:
                findAndModify: *collection0Name
                query: { _id: *local_key_id }
                update: { $addToSet: { keyAltNames: another_name } }
                writeConcern: { w: majority }
          - commandStartedEvent: { commandName: aggregate }