@@ -12,6 +12,7 @@ import (
12
12
13
13
"cdr.dev/slog/sloggers/slogtest"
14
14
15
+ "github.com/coder/coder/v2/codersdk"
15
16
"github.com/coder/coder/v2/enterprise/wsproxy"
16
17
"github.com/coder/coder/v2/enterprise/wsproxy/wsproxysdk"
17
18
"github.com/coder/coder/v2/testutil"
@@ -33,23 +34,23 @@ func TestCryptoKeyCache(t *testing.T) {
33
34
)
34
35
35
36
now := clock .Now ().UTC ()
36
- expected := wsproxysdk .CryptoKey {
37
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
37
+ expected := codersdk .CryptoKey {
38
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
38
39
Secret : "key2" ,
39
40
Sequence : 2 ,
40
41
StartsAt : now ,
41
42
}
42
43
43
- fc := newFakeCoderd (t , []wsproxysdk .CryptoKey {
44
+ fc := newFakeCoderd (t , []codersdk .CryptoKey {
44
45
{
45
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
46
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
46
47
Secret : "key1" ,
47
48
Sequence : 1 ,
48
49
StartsAt : now ,
49
50
},
50
51
// Should be ignored since it hasn't breached its starts_at time yet.
51
52
{
52
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
53
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
53
54
Secret : "key3" ,
54
55
Sequence : 3 ,
55
56
StartsAt : now .Add (time .Second * 2 ),
@@ -74,18 +75,18 @@ func TestCryptoKeyCache(t *testing.T) {
74
75
clock = quartz .NewMock (t )
75
76
)
76
77
77
- fc := newFakeCoderd (t , []wsproxysdk .CryptoKey {})
78
+ fc := newFakeCoderd (t , []codersdk .CryptoKey {})
78
79
79
80
cache , err := wsproxy .NewCryptoKeyCache (ctx , logger , wsproxysdk .New (fc .url ), withClock (clock ))
80
81
require .NoError (t , err )
81
82
82
- expected := wsproxysdk .CryptoKey {
83
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
83
+ expected := codersdk .CryptoKey {
84
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
84
85
Secret : "key1" ,
85
86
Sequence : 12 ,
86
87
StartsAt : clock .Now ().UTC (),
87
88
}
88
- fc .keys = []wsproxysdk .CryptoKey {expected }
89
+ fc .keys = []codersdk .CryptoKey {expected }
89
90
90
91
got , err := cache .Latest (ctx )
91
92
require .NoError (t , err )
@@ -110,17 +111,17 @@ func TestCryptoKeyCache(t *testing.T) {
110
111
clock = quartz .NewMock (t )
111
112
)
112
113
now := clock .Now ().UTC ()
113
- expected := wsproxysdk .CryptoKey {
114
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
114
+ expected := codersdk .CryptoKey {
115
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
115
116
Secret : "key1" ,
116
117
Sequence : 1 ,
117
118
StartsAt : clock .Now ().UTC (),
118
119
}
119
120
120
- fc := newFakeCoderd (t , []wsproxysdk .CryptoKey {
121
+ fc := newFakeCoderd (t , []codersdk .CryptoKey {
121
122
expected ,
122
123
{
123
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
124
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
124
125
Secret : "key2" ,
125
126
Sequence : 2 ,
126
127
StartsAt : now .Add (- time .Second ),
@@ -151,16 +152,16 @@ func TestCryptoKeyCache(t *testing.T) {
151
152
)
152
153
153
154
now := clock .Now ().UTC ()
154
- expected := wsproxysdk .CryptoKey {
155
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
155
+ expected := codersdk .CryptoKey {
156
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
156
157
Secret : "key1" ,
157
158
Sequence : 12 ,
158
159
StartsAt : now ,
159
160
}
160
- fc := newFakeCoderd (t , []wsproxysdk .CryptoKey {
161
+ fc := newFakeCoderd (t , []codersdk .CryptoKey {
161
162
expected ,
162
163
{
163
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
164
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
164
165
Secret : "key2" ,
165
166
Sequence : 13 ,
166
167
StartsAt : now ,
@@ -184,18 +185,18 @@ func TestCryptoKeyCache(t *testing.T) {
184
185
clock = quartz .NewMock (t )
185
186
)
186
187
187
- fc := newFakeCoderd (t , []wsproxysdk .CryptoKey {})
188
+ fc := newFakeCoderd (t , []codersdk .CryptoKey {})
188
189
189
190
cache , err := wsproxy .NewCryptoKeyCache (ctx , logger , wsproxysdk .New (fc .url ), withClock (clock ))
190
191
require .NoError (t , err )
191
192
192
- expected := wsproxysdk .CryptoKey {
193
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
193
+ expected := codersdk .CryptoKey {
194
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
194
195
Secret : "key1" ,
195
196
Sequence : 12 ,
196
197
StartsAt : clock .Now ().UTC (),
197
198
}
198
- fc .keys = []wsproxysdk .CryptoKey {expected }
199
+ fc .keys = []codersdk .CryptoKey {expected }
199
200
200
201
got , err := cache .Version (ctx , expected .Sequence )
201
202
require .NoError (t , err )
@@ -219,14 +220,14 @@ func TestCryptoKeyCache(t *testing.T) {
219
220
)
220
221
221
222
now := clock .Now ().UTC ()
222
- expected := wsproxysdk .CryptoKey {
223
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
223
+ expected := codersdk .CryptoKey {
224
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
224
225
Secret : "key1" ,
225
226
Sequence : 12 ,
226
227
StartsAt : now .Add (- time .Second ),
227
228
}
228
229
229
- fc := newFakeCoderd (t , []wsproxysdk .CryptoKey {
230
+ fc := newFakeCoderd (t , []codersdk .CryptoKey {
230
231
expected ,
231
232
})
232
233
@@ -249,15 +250,15 @@ func TestCryptoKeyCache(t *testing.T) {
249
250
)
250
251
251
252
now := clock .Now ().UTC ()
252
- expected := wsproxysdk .CryptoKey {
253
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
253
+ expected := codersdk .CryptoKey {
254
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
254
255
Secret : "key1" ,
255
256
Sequence : 12 ,
256
257
StartsAt : now .Add (- time .Second ),
257
258
DeletesAt : now ,
258
259
}
259
260
260
- fc := newFakeCoderd (t , []wsproxysdk .CryptoKey {
261
+ fc := newFakeCoderd (t , []codersdk .CryptoKey {
261
262
expected ,
262
263
})
263
264
@@ -282,14 +283,14 @@ func TestCryptoKeyCache(t *testing.T) {
282
283
trap := clock .Trap ().TickerFunc ()
283
284
284
285
now := clock .Now ().UTC ()
285
- expected := wsproxysdk .CryptoKey {
286
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
286
+ expected := codersdk .CryptoKey {
287
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
287
288
Secret : "key1" ,
288
289
Sequence : 12 ,
289
290
StartsAt : now ,
290
291
DeletesAt : now .Add (time .Minute * 10 ),
291
292
}
292
- fc := newFakeCoderd (t , []wsproxysdk .CryptoKey {
293
+ fc := newFakeCoderd (t , []codersdk .CryptoKey {
293
294
expected ,
294
295
})
295
296
@@ -303,13 +304,13 @@ func TestCryptoKeyCache(t *testing.T) {
303
304
304
305
wait := trap .MustWait (ctx )
305
306
306
- newKey := wsproxysdk .CryptoKey {
307
- Feature : wsproxysdk .CryptoKeyFeatureWorkspaceApp ,
307
+ newKey := codersdk .CryptoKey {
308
+ Feature : codersdk .CryptoKeyFeatureWorkspaceApp ,
308
309
Secret : "key2" ,
309
310
Sequence : 13 ,
310
311
StartsAt : now ,
311
312
}
312
- fc .keys = []wsproxysdk .CryptoKey {newKey }
313
+ fc .keys = []codersdk .CryptoKey {newKey }
313
314
314
315
wait .Release ()
315
316
@@ -332,12 +333,12 @@ func TestCryptoKeyCache(t *testing.T) {
332
333
333
334
type fakeCoderd struct {
334
335
server * httptest.Server
335
- keys []wsproxysdk .CryptoKey
336
+ keys []codersdk .CryptoKey
336
337
called int
337
338
url * url.URL
338
339
}
339
340
340
- func newFakeCoderd (t * testing.T , keys []wsproxysdk .CryptoKey ) * fakeCoderd {
341
+ func newFakeCoderd (t * testing.T , keys []codersdk .CryptoKey ) * fakeCoderd {
341
342
t .Helper ()
342
343
343
344
c := & fakeCoderd {
0 commit comments