Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[licensor]: remove limits on licence user numbers and feature sets #15583

Merged
merged 1 commit into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions components/licensor/ee/pkg/licensor/licensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ type licensePayload struct {
type LicenseLevel int

const (
// LevelTeam is the default license level,
// which is the free tier
// This exists for historical reasons - it is now the same as LevelEnterprise
LevelTeam LicenseLevel = 0

// LevelEnterprise enables enterprise features,
Expand Down Expand Up @@ -140,7 +139,7 @@ func (lvl LicenseLevel) allowance() allowance {
// Fallback license is used when the instance exceeds the number of licenses - it allows limited access
var fallbackLicense = LicensePayload{
ID: "fallback-license",
Level: LevelTeam,
Level: LevelEnterprise,
Seats: 0,
// Domain, ValidUntil are free for all
}
Expand All @@ -149,7 +148,7 @@ var fallbackLicense = LicensePayload{
var defaultLicense = LicensePayload{
ID: "default-license",
Level: LevelEnterprise,
Seats: 10,
Seats: 0,
// Domain, ValidUntil are free for all
}

Expand Down
32 changes: 25 additions & 7 deletions components/licensor/ee/pkg/licensor/licensor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,23 @@ func TestSeats(t *testing.T) {
{"Gitpod: invalid license", 50, 50, false, false, true, LicenseTypeGitpod, false},
{"Gitpod: within default license seats", 0, 7, true, true, false, LicenseTypeGitpod, false},
{"Gitpod: within default license seats (edge)", 0, 10, true, true, false, LicenseTypeGitpod, false},
{"Gitpod: beyond default license seats", 0, 11, false, true, false, LicenseTypeGitpod, false},
{"Gitpod: beyond default license seats", 0, 11, true, true, false, LicenseTypeGitpod, false},

// correctly missing the default license tests as Replicated always has a license
{"Replicated: unlimited seats", 0, 1000, true, false, false, LicenseTypeReplicated, false},
{"Replicated: within limited seats", 50, 40, true, false, false, LicenseTypeReplicated, false},
{"Replicated: within limited seats (edge)", 50, 50, true, false, false, LicenseTypeReplicated, false},
{"Replicated: beyond limited seats", 50, 150, false, false, false, LicenseTypeReplicated, false},
{"Replicated: beyond limited seats (edge)", 50, 51, false, false, false, LicenseTypeReplicated, false},
{"Replicated: invalid license", 50, 50, false, false, true, LicenseTypeReplicated, false},
{"Replicated: beyond default license seats", 0, 11, false, true, false, LicenseTypeReplicated, false},
{"Replicated: invalid license", 50, 50, true, false, true, LicenseTypeReplicated, false},
{"Replicated: beyond default license seats", 0, 11, true, true, false, LicenseTypeReplicated, false},

{"Replicated: unlimited seats", 0, 1000, true, false, false, LicenseTypeReplicated, true},
{"Replicated: within limited seats", 50, 40, true, false, false, LicenseTypeReplicated, true},
{"Replicated: within limited seats (edge)", 50, 50, true, false, false, LicenseTypeReplicated, true},
{"Replicated: beyond limited seats", 50, 150, false, false, false, LicenseTypeReplicated, true},
{"Replicated: beyond limited seats (edge)", 50, 51, false, false, false, LicenseTypeReplicated, true},
{"Replicated: invalid license", 50, 50, false, false, true, LicenseTypeReplicated, true},
{"Replicated: invalid license", 50, 50, true, false, true, LicenseTypeReplicated, true},
{"Replicated: beyond default license seats", 0, 11, false, true, false, LicenseTypeReplicated, true},
{"Replicated: invalid license within default seats", 50, 5, true, false, true, LicenseTypeReplicated, false},
}
Expand Down Expand Up @@ -238,7 +238,13 @@ func TestFeatures(t *testing.T) {
FeaturePrebuild,
}, LicenseTypeGitpod, seats, nil},

{"Gitpod (over seats): no license", true, LicenseLevel(0), []Feature{FeatureAdminDashboard}, LicenseTypeGitpod, 11, nil},
{"Gitpod (over seats): no license", true, LicenseLevel(0), []Feature{
FeatureAdminDashboard,
FeatureSetTimeout,
FeatureWorkspaceSharing,
FeatureSnapshot,
FeaturePrebuild,
}, LicenseTypeGitpod, 11, nil},
{"Gitpod (over seats): invalid license level", false, LicenseLevel(666), []Feature{}, LicenseTypeGitpod, seats + 1, nil},
{"Gitpod (over seats): enterprise license", false, LevelEnterprise, []Feature{}, LicenseTypeGitpod, seats + 1, nil},

Expand Down Expand Up @@ -272,8 +278,20 @@ func TestFeatures(t *testing.T) {
FeaturePrebuild,
}, LicenseTypeReplicated, seats + 1, &replicatedPaid},

{"Replicated (over seats - fallback): invalid license level", false, LicenseLevel(666), []Feature{FeatureAdminDashboard}, LicenseTypeReplicated, seats + 1, &replicatedCommunity},
{"Replicated (over seats - fallback): enterprise license", false, LevelEnterprise, []Feature{FeatureAdminDashboard}, LicenseTypeReplicated, seats + 1, &replicatedCommunity},
{"Replicated (over seats - fallback): invalid license level", false, LicenseLevel(666), []Feature{
FeatureAdminDashboard,
FeatureSetTimeout,
FeatureWorkspaceSharing,
FeatureSnapshot,
FeaturePrebuild,
}, LicenseTypeReplicated, seats + 1, &replicatedCommunity},
{"Replicated (over seats - fallback): enterprise license", false, LevelEnterprise, []Feature{
FeatureAdminDashboard,
FeatureSetTimeout,
FeatureWorkspaceSharing,
FeatureSnapshot,
FeaturePrebuild,
}, LicenseTypeReplicated, seats + 1, &replicatedCommunity},
}

for _, test := range tests {
Expand Down
2 changes: 2 additions & 0 deletions components/licensor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Licensed under the GNU Affero General Public License (AGPL).
// See License.AGPL.txt in the project root for license information.

// @deprecated

package main

import "github.com/gitpod-io/gitpod/licensor/ee/cmd"
Expand Down