Skip to content

Commit 96f0b2d

Browse files
committed
premium license has multi-org enabled
1 parent 1bc8288 commit 96f0b2d

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

codersdk/deployment.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ func (n FeatureName) Humanize() string {
110110
}
111111

112112
// AlwaysEnable returns if the feature is always enabled if entitled.
113-
// Warning: We don't know if we need this functionality.
114-
// This method may disappear at any time.
113+
// This is required because some features are only enabled if they are entitled
114+
// and not required.
115+
// E.g: "multiple-organizations" is disabled by default in AGPL and enterprise
116+
// deployments. This feature should only be enabled for premium deployments
117+
// when it is entitled.
115118
func (n FeatureName) AlwaysEnable() bool {
116119
return map[FeatureName]bool{
117120
FeatureMultipleExternalAuth: true,
@@ -120,6 +123,7 @@ func (n FeatureName) AlwaysEnable() bool {
120123
FeatureWorkspaceBatchActions: true,
121124
FeatureHighAvailability: true,
122125
FeatureCustomRoles: true,
126+
FeatureMultipleOrganizations: true,
123127
}[n]
124128
}
125129

enterprise/coderd/coderd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ func (api *API) updateEntitlements(ctx context.Context) error {
582582
codersdk.FeatureUserRoleManagement: true,
583583
codersdk.FeatureAccessControl: true,
584584
codersdk.FeatureControlSharedPorts: true,
585-
codersdk.FeatureMultipleOrganizations: true,
586585
})
587586
if err != nil {
588587
return err

enterprise/coderd/license/license_test.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,18 @@ func TestLicenseEntitlements(t *testing.T) {
679679
DeploymentIDs: nil,
680680
Trial: false,
681681
FeatureSet: codersdk.FeatureSetEnterprise,
682-
AllFeatures: false,
682+
AllFeatures: true,
683+
}).Valid(time.Now())
684+
}
685+
686+
premiumLicense := func() *coderdenttest.LicenseOptions {
687+
return (&coderdenttest.LicenseOptions{
688+
AccountType: "salesforce",
689+
AccountID: "Charlie",
690+
DeploymentIDs: nil,
691+
Trial: false,
692+
FeatureSet: codersdk.FeatureSetPremium,
693+
AllFeatures: true,
683694
}).Valid(time.Now())
684695
}
685696

@@ -789,6 +800,30 @@ func TestLicenseEntitlements(t *testing.T) {
789800
assert.Equalf(t, int64(50), *userFeature.Actual, "user count")
790801
},
791802
},
803+
{
804+
Name: "EnterpriseDisabledMultiOrg",
805+
Licenses: []*coderdenttest.LicenseOptions{
806+
enterpriseLicense().UserLimit(100),
807+
},
808+
Enablements: defaultEnablements,
809+
Arguments: license.FeatureArguments{},
810+
ExpectedErrorContains: "",
811+
AssertEntitlements: func(t *testing.T, entitlements codersdk.Entitlements) {
812+
assert.False(t, entitlements.Features[codersdk.FeatureMultipleOrganizations].Enabled, "multi-org only enabled for premium")
813+
},
814+
},
815+
{
816+
Name: "PremiumEnabledMultiOrg",
817+
Licenses: []*coderdenttest.LicenseOptions{
818+
premiumLicense().UserLimit(100),
819+
},
820+
Enablements: defaultEnablements,
821+
Arguments: license.FeatureArguments{},
822+
ExpectedErrorContains: "",
823+
AssertEntitlements: func(t *testing.T, entitlements codersdk.Entitlements) {
824+
assert.True(t, entitlements.Features[codersdk.FeatureMultipleOrganizations].Enabled, "multi-org enabled for premium")
825+
},
826+
},
792827
}
793828

794829
for _, tc := range testCases {

0 commit comments

Comments
 (0)