@@ -40,9 +40,7 @@ describe('getLocalCryptographicMaterialsCache', () => {
40
40
41
41
it ( 'putEncryptionResponse' , ( ) => {
42
42
const key = 'some encryption key'
43
- const response : any = {
44
- material : encryptionMaterial
45
- }
43
+ const response : any = encryptionMaterial
46
44
47
45
putEncryptionResponse ( key , response , 1 )
48
46
const test = getEncryptionResponse ( key , 1 )
@@ -54,9 +52,7 @@ describe('getLocalCryptographicMaterialsCache', () => {
54
52
} )
55
53
56
54
it ( 'Precondition: putEncryptionResponse plaintextLength can not be negative.' , ( ) => {
57
- const response : any = {
58
- material : encryptionMaterial
59
- }
55
+ const response : any = encryptionMaterial
60
56
const u : any = undefined
61
57
const s : any = 'not-number'
62
58
const n = - 1
@@ -67,9 +63,7 @@ describe('getLocalCryptographicMaterialsCache', () => {
67
63
68
64
it ( 'Postcondition: Only return EncryptionMaterial.' , ( ) => {
69
65
const key = 'some decryption key'
70
- const response : any = {
71
- material : decryptionMaterial
72
- }
66
+ const response : any = decryptionMaterial
73
67
74
68
putDecryptionResponse ( key , response )
75
69
expect ( ( ) => getEncryptionResponse ( key , 1 ) ) . to . throw ( )
@@ -78,18 +72,14 @@ describe('getLocalCryptographicMaterialsCache', () => {
78
72
it ( 'Precondition: Only cache EncryptionMaterial that is cacheSafe.' , ( ) => {
79
73
const key = 'some encryption key'
80
74
const suite = new NodeAlgorithmSuite ( AlgorithmSuiteIdentifier . ALG_AES128_GCM_IV12_TAG16 )
81
- const response : any = {
82
- material : new NodeEncryptionMaterial ( suite , { } )
83
- }
75
+ const response : any = new NodeEncryptionMaterial ( suite , { } )
84
76
85
77
expect ( ( ) => putEncryptionResponse ( key , response , 1 ) ) . to . throw ( )
86
78
} )
87
79
88
80
it ( 'putDecryptionResponse' , ( ) => {
89
81
const key = 'some decryption key'
90
- const response : any = {
91
- material : decryptionMaterial
92
- }
82
+ const response : any = decryptionMaterial
93
83
94
84
putDecryptionResponse ( key , response )
95
85
const test = getDecryptionResponse ( key )
@@ -102,19 +92,15 @@ describe('getLocalCryptographicMaterialsCache', () => {
102
92
103
93
it ( 'Precondition: Only cache DecryptionMaterial.' , ( ) => {
104
94
const key = 'some decryption key'
105
- const response : any = {
106
- material : 'not material'
107
- }
95
+ const response : any = 'not material'
108
96
109
97
expect ( ( ) => putDecryptionResponse ( key , response ) ) . to . throw ( )
110
98
} )
111
99
112
100
it ( 'Precondition: Only cache DecryptionMaterial that is cacheSafe.' , ( ) => {
113
101
const key = 'some decryption key'
114
102
const suite = new NodeAlgorithmSuite ( AlgorithmSuiteIdentifier . ALG_AES128_GCM_IV12_TAG16 )
115
- const response : any = {
116
- material : new NodeEncryptionMaterial ( suite , { } )
117
- }
103
+ const response : any = new NodeEncryptionMaterial ( suite , { } )
118
104
119
105
expect ( ( ) => putDecryptionResponse ( key , response ) ) . to . throw ( )
120
106
} )
@@ -135,9 +121,7 @@ describe('getLocalCryptographicMaterialsCache', () => {
135
121
136
122
it ( 'Precondition: Only cache EncryptionMaterial.' , ( ) => {
137
123
const key = 'some encryption key'
138
- const response : any = {
139
- material : 'not material'
140
- }
124
+ const response : any = 'not material'
141
125
142
126
expect ( ( ) => putEncryptionResponse ( key , response , 1 ) ) . to . throw ( )
143
127
} )
@@ -149,9 +133,7 @@ describe('getLocalCryptographicMaterialsCache', () => {
149
133
150
134
it ( 'Postcondition: Only return DecryptionMaterial.' , ( ) => {
151
135
const key = 'some encryption key'
152
- const response : any = {
153
- material : encryptionMaterial
154
- }
136
+ const response : any = encryptionMaterial
155
137
156
138
putEncryptionResponse ( key , response , 1 )
157
139
expect ( ( ) => getDecryptionResponse ( key ) )
@@ -163,9 +145,7 @@ describe('getLocalCryptographicMaterialsCache', () => {
163
145
164
146
it ( 'zero is an acceptable plaintextLength' , ( ) => {
165
147
const key = 'some encryption key'
166
- const response : any = {
167
- material : encryptionMaterial
168
- }
148
+ const response : any = encryptionMaterial
169
149
170
150
putEncryptionResponse ( key , response , 0 )
171
151
const test = getEncryptionResponse ( key , 0 )
@@ -186,9 +166,7 @@ describe('cache eviction', () => {
186
166
187
167
const key1 = 'key lost'
188
168
const key2 = 'key replace'
189
- const response : any = {
190
- material : decryptionMaterial
191
- }
169
+ const response : any = decryptionMaterial
192
170
193
171
putDecryptionResponse ( key1 , response )
194
172
putDecryptionResponse ( key2 , response )
@@ -206,9 +184,7 @@ describe('cache eviction', () => {
206
184
} = getLocalCryptographicMaterialsCache ( 1 )
207
185
208
186
const key = 'key deleted'
209
- const response : any = {
210
- material : decryptionMaterial
211
- }
187
+ const response : any = decryptionMaterial
212
188
213
189
putDecryptionResponse ( key , response )
214
190
del ( key )
@@ -223,9 +199,7 @@ describe('cache eviction', () => {
223
199
} = getLocalCryptographicMaterialsCache ( 1 , 10 )
224
200
225
201
const key = 'key lost'
226
- const response : any = {
227
- material : decryptionMaterial
228
- }
202
+ const response : any = decryptionMaterial
229
203
230
204
putDecryptionResponse ( key , response , 1 )
231
205
await new Promise ( resolve => setTimeout ( resolve , 20 ) )
@@ -241,9 +215,7 @@ describe('cache eviction', () => {
241
215
242
216
const key1 = 'key lost'
243
217
const key2 = 'key replace'
244
- const response : any = {
245
- material : encryptionMaterial
246
- }
218
+ const response : any = encryptionMaterial
247
219
248
220
putEncryptionResponse ( key1 , response , 0 )
249
221
putEncryptionResponse ( key2 , response , 0 )
@@ -261,9 +233,7 @@ describe('cache eviction', () => {
261
233
} = getLocalCryptographicMaterialsCache ( 1 , 10 )
262
234
263
235
const key = 'key lost'
264
- const response : any = {
265
- material : encryptionMaterial
266
- }
236
+ const response : any = encryptionMaterial
267
237
268
238
putEncryptionResponse ( key , response , 1 , 1 )
269
239
del ( key )
@@ -278,9 +248,7 @@ describe('cache eviction', () => {
278
248
} = getLocalCryptographicMaterialsCache ( 1 , 10 )
279
249
280
250
const key = 'key lost'
281
- const response : any = {
282
- material : encryptionMaterial
283
- }
251
+ const response : any = encryptionMaterial
284
252
285
253
putEncryptionResponse ( key , response , 1 , 1 )
286
254
await new Promise ( resolve => setTimeout ( resolve , 20 ) )
0 commit comments