@@ -23,7 +23,7 @@ import (
23
23
func TestCryptoKeyCache (t * testing.T ) {
24
24
t .Parallel ()
25
25
26
- t .Run ("Latest " , func (t * testing.T ) {
26
+ t .Run ("Signing " , func (t * testing.T ) {
27
27
t .Parallel ()
28
28
29
29
t .Run ("HitsCache" , func (t * testing.T ) {
@@ -138,9 +138,27 @@ func TestCryptoKeyCache(t *testing.T) {
138
138
require .Equal (t , expected , got )
139
139
require .Equal (t , 1 , fc .called )
140
140
})
141
+
142
+ t .Run ("KeyNotFound" , func (t * testing.T ) {
143
+ t .Parallel ()
144
+
145
+ var (
146
+ ctx = testutil .Context (t , testutil .WaitShort )
147
+ logger = slogtest .Make (t , nil )
148
+ clock = quartz .NewMock (t )
149
+ )
150
+
151
+ fc := newFakeCoderd (t , []codersdk.CryptoKey {})
152
+
153
+ cache , err := wsproxy .NewCryptoKeyCache (ctx , logger , wsproxysdk .New (fc .url ), withClock (clock ))
154
+ require .NoError (t , err )
155
+
156
+ _ , err = cache .Verifying (ctx , 1 )
157
+ require .ErrorIs (t , err , cryptokeys .ErrKeyNotFound )
158
+ })
141
159
})
142
160
143
- t .Run ("Version " , func (t * testing.T ) {
161
+ t .Run ("Verifying " , func (t * testing.T ) {
144
162
t .Parallel ()
145
163
146
164
t .Run ("HitsCache" , func (t * testing.T ) {
@@ -241,7 +259,7 @@ func TestCryptoKeyCache(t *testing.T) {
241
259
require .Equal (t , 1 , fc .called )
242
260
})
243
261
244
- t .Run ("NoInvalid " , func (t * testing.T ) {
262
+ t .Run ("KeyInvalid " , func (t * testing.T ) {
245
263
t .Parallel ()
246
264
247
265
var (
@@ -267,9 +285,27 @@ func TestCryptoKeyCache(t *testing.T) {
267
285
require .NoError (t , err )
268
286
269
287
_ , err = cache .Verifying (ctx , expected .Sequence )
270
- require .Error (t , err )
288
+ require .ErrorIs (t , err , cryptokeys . ErrKeyInvalid )
271
289
require .Equal (t , 1 , fc .called )
272
290
})
291
+
292
+ t .Run ("KeyNotFound" , func (t * testing.T ) {
293
+ t .Parallel ()
294
+
295
+ var (
296
+ ctx = testutil .Context (t , testutil .WaitShort )
297
+ logger = slogtest .Make (t , nil )
298
+ clock = quartz .NewMock (t )
299
+ )
300
+
301
+ fc := newFakeCoderd (t , []codersdk.CryptoKey {})
302
+
303
+ cache , err := wsproxy .NewCryptoKeyCache (ctx , logger , wsproxysdk .New (fc .url ), withClock (clock ))
304
+ require .NoError (t , err )
305
+
306
+ _ , err = cache .Verifying (ctx , 1 )
307
+ require .ErrorIs (t , err , cryptokeys .ErrKeyNotFound )
308
+ })
273
309
})
274
310
275
311
t .Run ("CacheRefreshes" , func (t * testing.T ) {
@@ -342,11 +378,10 @@ func TestCryptoKeyCache(t *testing.T) {
342
378
343
379
now := clock .Now ()
344
380
expected := codersdk.CryptoKey {
345
- Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
346
- Secret : "key1" ,
347
- Sequence : 12 ,
348
- StartsAt : now ,
349
- DeletesAt : now .Add (time .Minute * 10 ),
381
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
382
+ Secret : "key1" ,
383
+ Sequence : 12 ,
384
+ StartsAt : now ,
350
385
}
351
386
fc := newFakeCoderd (t , []codersdk.CryptoKey {
352
387
expected ,
0 commit comments