6
6
"testing"
7
7
"time"
8
8
9
+ "github.com/coder/coder/coderd/authzquery"
10
+ "github.com/coder/coder/coderd/rbac"
11
+
9
12
"github.com/stretchr/testify/assert"
10
13
"github.com/stretchr/testify/require"
11
14
"go.uber.org/goleak"
@@ -100,7 +103,8 @@ func TestEntitlements(t *testing.T) {
100
103
require .NoError (t , err )
101
104
require .False (t , entitlements .HasLicense )
102
105
coderdtest .CreateFirstUser (t , client )
103
- _ , err = api .Database .InsertLicense (context .Background (), database.InsertLicenseParams {
106
+ ctx := authzquery .WithAuthorizeSystemContext (context .Background (), rbac .RolesAdminSystem ())
107
+ _ , err = api .Database .InsertLicense (ctx , database.InsertLicenseParams {
104
108
UploadedAt : database .Now (),
105
109
Exp : database .Now ().AddDate (1 , 0 , 0 ),
106
110
JWT : coderdenttest .GenerateLicense (t , coderdenttest.LicenseOptions {
@@ -128,7 +132,8 @@ func TestEntitlements(t *testing.T) {
128
132
require .False (t , entitlements .HasLicense )
129
133
coderdtest .CreateFirstUser (t , client )
130
134
// Valid
131
- _ , err = api .Database .InsertLicense (context .Background (), database.InsertLicenseParams {
135
+ ctx := authzquery .WithAuthorizeSystemContext (context .Background (), rbac .RolesAdminSystem ())
136
+ _ , err = api .Database .InsertLicense (ctx , database.InsertLicenseParams {
132
137
UploadedAt : database .Now (),
133
138
Exp : database .Now ().AddDate (1 , 0 , 0 ),
134
139
JWT : coderdenttest .GenerateLicense (t , coderdenttest.LicenseOptions {
@@ -139,7 +144,7 @@ func TestEntitlements(t *testing.T) {
139
144
})
140
145
require .NoError (t , err )
141
146
// Expired
142
- _ , err = api .Database .InsertLicense (context . Background () , database.InsertLicenseParams {
147
+ _ , err = api .Database .InsertLicense (ctx , database.InsertLicenseParams {
143
148
UploadedAt : database .Now (),
144
149
Exp : database .Now ().AddDate (- 1 , 0 , 0 ),
145
150
JWT : coderdenttest .GenerateLicense (t , coderdenttest.LicenseOptions {
@@ -148,7 +153,7 @@ func TestEntitlements(t *testing.T) {
148
153
})
149
154
require .NoError (t , err )
150
155
// Invalid
151
- _ , err = api .Database .InsertLicense (context . Background () , database.InsertLicenseParams {
156
+ _ , err = api .Database .InsertLicense (ctx , database.InsertLicenseParams {
152
157
UploadedAt : database .Now (),
153
158
Exp : database .Now ().AddDate (1 , 0 , 0 ),
154
159
JWT : "invalid" ,
0 commit comments