@@ -11,7 +11,6 @@ import (
11
11
"github.com/stretchr/testify/require"
12
12
"golang.org/x/exp/slices"
13
13
14
- "cdr.dev/slog"
15
14
"github.com/coder/coder/v2/coderd/database"
16
15
"github.com/coder/coder/v2/coderd/database/dbmem"
17
16
"github.com/coder/coder/v2/coderd/database/dbtime"
@@ -32,7 +31,7 @@ func TestEntitlements(t *testing.T) {
32
31
t .Run ("Defaults" , func (t * testing.T ) {
33
32
t .Parallel ()
34
33
db := dbmem .New ()
35
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
34
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
36
35
require .NoError (t , err )
37
36
require .False (t , entitlements .HasLicense )
38
37
require .False (t , entitlements .Trial )
@@ -44,7 +43,7 @@ func TestEntitlements(t *testing.T) {
44
43
t .Run ("Always return the current user count" , func (t * testing.T ) {
45
44
t .Parallel ()
46
45
db := dbmem .New ()
47
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
46
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
48
47
require .NoError (t , err )
49
48
require .False (t , entitlements .HasLicense )
50
49
require .False (t , entitlements .Trial )
@@ -57,7 +56,7 @@ func TestEntitlements(t *testing.T) {
57
56
JWT : coderdenttest .GenerateLicense (t , coderdenttest.LicenseOptions {}),
58
57
Exp : time .Now ().Add (time .Hour ),
59
58
})
60
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , empty )
59
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , empty )
61
60
require .NoError (t , err )
62
61
require .True (t , entitlements .HasLicense )
63
62
require .False (t , entitlements .Trial )
@@ -81,7 +80,7 @@ func TestEntitlements(t *testing.T) {
81
80
}),
82
81
Exp : time .Now ().Add (time .Hour ),
83
82
})
84
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , empty )
83
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , empty )
85
84
require .NoError (t , err )
86
85
require .True (t , entitlements .HasLicense )
87
86
require .False (t , entitlements .Trial )
@@ -104,7 +103,7 @@ func TestEntitlements(t *testing.T) {
104
103
}),
105
104
Exp : time .Now ().Add (time .Hour ),
106
105
})
107
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
106
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
108
107
require .NoError (t , err )
109
108
require .True (t , entitlements .HasLicense )
110
109
require .False (t , entitlements .Trial )
@@ -131,7 +130,7 @@ func TestEntitlements(t *testing.T) {
131
130
Exp : time .Now ().AddDate (0 , 0 , 5 ),
132
131
})
133
132
134
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
133
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
135
134
136
135
require .NoError (t , err )
137
136
require .True (t , entitlements .HasLicense )
@@ -160,7 +159,7 @@ func TestEntitlements(t *testing.T) {
160
159
Exp : time .Now ().AddDate (0 , 0 , 5 ),
161
160
})
162
161
163
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
162
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
164
163
165
164
require .NoError (t , err )
166
165
require .True (t , entitlements .HasLicense )
@@ -190,7 +189,7 @@ func TestEntitlements(t *testing.T) {
190
189
Exp : time .Now ().AddDate (0 , 0 , 5 ),
191
190
})
192
191
193
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
192
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
194
193
195
194
require .NoError (t , err )
196
195
require .True (t , entitlements .HasLicense )
@@ -219,7 +218,7 @@ func TestEntitlements(t *testing.T) {
219
218
Exp : time .Now ().AddDate (0 , 0 , 5 ),
220
219
})
221
220
222
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
221
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
223
222
224
223
require .NoError (t , err )
225
224
require .True (t , entitlements .HasLicense )
@@ -239,7 +238,7 @@ func TestEntitlements(t *testing.T) {
239
238
JWT : coderdenttest .GenerateLicense (t , coderdenttest.LicenseOptions {}),
240
239
Exp : time .Now ().Add (time .Hour ),
241
240
})
242
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
241
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
243
242
require .NoError (t , err )
244
243
require .True (t , entitlements .HasLicense )
245
244
require .False (t , entitlements .Trial )
@@ -301,7 +300,7 @@ func TestEntitlements(t *testing.T) {
301
300
}),
302
301
Exp : time .Now ().Add (time .Hour ),
303
302
})
304
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , empty )
303
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , empty )
305
304
require .NoError (t , err )
306
305
require .True (t , entitlements .HasLicense )
307
306
require .Contains (t , entitlements .Warnings , "Your deployment has 2 active users but is only licensed for 1." )
@@ -329,7 +328,7 @@ func TestEntitlements(t *testing.T) {
329
328
}),
330
329
Exp : time .Now ().Add (60 * 24 * time .Hour ),
331
330
})
332
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , empty )
331
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , empty )
333
332
require .NoError (t , err )
334
333
require .True (t , entitlements .HasLicense )
335
334
require .Empty (t , entitlements .Warnings )
@@ -352,7 +351,7 @@ func TestEntitlements(t *testing.T) {
352
351
}),
353
352
})
354
353
355
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , empty )
354
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , empty )
356
355
require .NoError (t , err )
357
356
require .True (t , entitlements .HasLicense )
358
357
require .False (t , entitlements .Trial )
@@ -368,7 +367,7 @@ func TestEntitlements(t *testing.T) {
368
367
}),
369
368
})
370
369
require .NoError (t , err )
371
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
370
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
372
371
require .NoError (t , err )
373
372
require .True (t , entitlements .HasLicense )
374
373
require .False (t , entitlements .Trial )
@@ -399,7 +398,7 @@ func TestEntitlements(t *testing.T) {
399
398
}),
400
399
})
401
400
require .NoError (t , err )
402
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
401
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
403
402
require .NoError (t , err )
404
403
require .True (t , entitlements .HasLicense )
405
404
require .False (t , entitlements .Trial )
@@ -430,7 +429,7 @@ func TestEntitlements(t *testing.T) {
430
429
}),
431
430
})
432
431
require .NoError (t , err )
433
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
432
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
434
433
require .NoError (t , err )
435
434
require .True (t , entitlements .HasLicense )
436
435
require .False (t , entitlements .Trial )
@@ -451,7 +450,7 @@ func TestEntitlements(t *testing.T) {
451
450
AllFeatures : true ,
452
451
}),
453
452
})
454
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
453
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
455
454
require .NoError (t , err )
456
455
require .True (t , entitlements .HasLicense )
457
456
require .False (t , entitlements .Trial )
@@ -481,7 +480,7 @@ func TestEntitlements(t *testing.T) {
481
480
AllFeatures : true ,
482
481
}),
483
482
})
484
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , empty )
483
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , empty )
485
484
require .NoError (t , err )
486
485
require .True (t , entitlements .HasLicense )
487
486
require .False (t , entitlements .Trial )
@@ -514,7 +513,7 @@ func TestEntitlements(t *testing.T) {
514
513
ExpiresAt : dbtime .Now ().Add (time .Hour ),
515
514
}),
516
515
})
517
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 1 , coderdenttest .Keys , all )
516
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 1 , coderdenttest .Keys , all )
518
517
require .NoError (t , err )
519
518
require .True (t , entitlements .HasLicense )
520
519
require .False (t , entitlements .Trial )
@@ -537,7 +536,7 @@ func TestEntitlements(t *testing.T) {
537
536
t .Run ("MultipleReplicasNoLicense" , func (t * testing.T ) {
538
537
t .Parallel ()
539
538
db := dbmem .New ()
540
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 2 , 1 , coderdenttest .Keys , all )
539
+ entitlements , err := license .Entitlements (context .Background (), db , 2 , 1 , coderdenttest .Keys , all )
541
540
require .NoError (t , err )
542
541
require .False (t , entitlements .HasLicense )
543
542
require .Len (t , entitlements .Errors , 1 )
@@ -555,7 +554,7 @@ func TestEntitlements(t *testing.T) {
555
554
},
556
555
}),
557
556
})
558
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 2 , 1 , coderdenttest .Keys , map [codersdk.FeatureName ]bool {
557
+ entitlements , err := license .Entitlements (context .Background (), db , 2 , 1 , coderdenttest .Keys , map [codersdk.FeatureName ]bool {
559
558
codersdk .FeatureHighAvailability : true ,
560
559
})
561
560
require .NoError (t , err )
@@ -577,7 +576,7 @@ func TestEntitlements(t *testing.T) {
577
576
}),
578
577
Exp : time .Now ().Add (time .Hour ),
579
578
})
580
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 2 , 1 , coderdenttest .Keys , map [codersdk.FeatureName ]bool {
579
+ entitlements , err := license .Entitlements (context .Background (), db , 2 , 1 , coderdenttest .Keys , map [codersdk.FeatureName ]bool {
581
580
codersdk .FeatureHighAvailability : true ,
582
581
})
583
582
require .NoError (t , err )
@@ -589,7 +588,7 @@ func TestEntitlements(t *testing.T) {
589
588
t .Run ("MultipleGitAuthNoLicense" , func (t * testing.T ) {
590
589
t .Parallel ()
591
590
db := dbmem .New ()
592
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 2 , coderdenttest .Keys , all )
591
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 2 , coderdenttest .Keys , all )
593
592
require .NoError (t , err )
594
593
require .False (t , entitlements .HasLicense )
595
594
require .Len (t , entitlements .Errors , 1 )
@@ -607,7 +606,7 @@ func TestEntitlements(t *testing.T) {
607
606
},
608
607
}),
609
608
})
610
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 2 , coderdenttest .Keys , map [codersdk.FeatureName ]bool {
609
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 2 , coderdenttest .Keys , map [codersdk.FeatureName ]bool {
611
610
codersdk .FeatureMultipleExternalAuth : true ,
612
611
})
613
612
require .NoError (t , err )
@@ -629,7 +628,7 @@ func TestEntitlements(t *testing.T) {
629
628
}),
630
629
Exp : time .Now ().Add (time .Hour ),
631
630
})
632
- entitlements , err := license .Entitlements (context .Background (), db , slog. Logger {}, 1 , 2 , coderdenttest .Keys , map [codersdk.FeatureName ]bool {
631
+ entitlements , err := license .Entitlements (context .Background (), db , 1 , 2 , coderdenttest .Keys , map [codersdk.FeatureName ]bool {
633
632
codersdk .FeatureMultipleExternalAuth : true ,
634
633
})
635
634
require .NoError (t , err )
0 commit comments