@@ -233,6 +233,50 @@ func TestWorkspaceQuota(t *testing.T) {
233
233
verifyQuota (ctx , t , client , 4 , 4 )
234
234
require .Equal (t , codersdk .WorkspaceStatusRunning , build .Status )
235
235
})
236
+
237
+ // Ensures allowance from everyone groups only counts if you are an org member.
238
+ // This was a bug where the group "Everyone" was being counted for all users,
239
+ // regardless of membership.
240
+ t .Run ("AllowanceEveryone" , func (t * testing.T ) {
241
+ t .Parallel ()
242
+
243
+ dv := coderdtest .DeploymentValues (t )
244
+ dv .Experiments = []string {string (codersdk .ExperimentMultiOrganization )}
245
+ owner , first := coderdenttest .New (t , & coderdenttest.Options {
246
+ Options : & coderdtest.Options {
247
+ DeploymentValues : dv ,
248
+ },
249
+ LicenseOptions : & coderdenttest.LicenseOptions {
250
+ Features : license.Features {
251
+ codersdk .FeatureTemplateRBAC : 1 ,
252
+ codersdk .FeatureMultipleOrganizations : 1 ,
253
+ },
254
+ },
255
+ })
256
+ member , _ := coderdtest .CreateAnotherUser (t , owner , first .OrganizationID )
257
+
258
+ // Create a second organization
259
+ second := coderdenttest .CreateOrganization (t , owner , coderdenttest.CreateOrganizationOptions {})
260
+
261
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
262
+ defer cancel ()
263
+
264
+ // update everyone quotas
265
+ _ , err := owner .PatchGroup (ctx , first .OrganizationID , codersdk.PatchGroupRequest {
266
+ QuotaAllowance : ptr .Ref (30 ),
267
+ })
268
+ require .NoError (t , err )
269
+
270
+ _ , err = owner .PatchGroup (ctx , second .ID , codersdk.PatchGroupRequest {
271
+ QuotaAllowance : ptr .Ref (15 ),
272
+ })
273
+ require .NoError (t , err )
274
+
275
+ verifyQuota (ctx , t , member , 0 , 30 )
276
+ // This currently reports the total site wide quotas. We might want to
277
+ // org scope this api call in the future.
278
+ verifyQuota (ctx , t , owner , 0 , 45 )
279
+ })
236
280
}
237
281
238
282
func planWithCost (cost int32 ) []* proto.Response {
0 commit comments