@@ -102,6 +102,34 @@ func TestEntitlements(t *testing.T) {
102
102
fmt .Sprintf ("%s is enabled but your license for this feature is expired." , codersdk .FeatureAuditLog .Humanize ()),
103
103
)
104
104
})
105
+ t .Run ("Expiration warning" , func (t * testing.T ) {
106
+ t .Parallel ()
107
+ db := dbfake .New ()
108
+ db .InsertLicense (context .Background (), database.InsertLicenseParams {
109
+ JWT : coderdenttest .GenerateLicense (t , coderdenttest.LicenseOptions {
110
+ Features : license.Features {
111
+ codersdk .FeatureUserLimit : 100 ,
112
+ codersdk .FeatureAuditLog : 1 ,
113
+ },
114
+
115
+ GraceAt : time .Now ().Add (- time .Hour ),
116
+ ExpiresAt : time .Now ().AddDate (0 , 0 , 2 ),
117
+ }),
118
+ Exp : time .Now ().Add (time .Hour ),
119
+ })
120
+
121
+ entitlements , err := license .Entitlements (context .Background (), db , slog.Logger {}, 1 , 1 , coderdenttest .Keys , all )
122
+
123
+ require .NoError (t , err )
124
+ require .True (t , entitlements .HasLicense )
125
+ require .False (t , entitlements .Trial )
126
+
127
+ require .Equal (t , codersdk .EntitlementGracePeriod , entitlements .Features [codersdk .FeatureAuditLog ].Entitlement )
128
+ require .Contains (
129
+ t , entitlements .Warnings ,
130
+ "Your license expires in 2 days." ,
131
+ )
132
+ })
105
133
t .Run ("SingleLicenseNotEntitled" , func (t * testing.T ) {
106
134
t .Parallel ()
107
135
db := dbfake .New ()
0 commit comments