mirror of
https://github.com/gravitational/teleport.git
synced 2026-09-24 16:17:11 +08:00
new license fields (#14279)
* new license fields * remove monthly active users field from license
This commit is contained in:
@@ -86,6 +86,11 @@ type License interface {
|
||||
// SetSupportsResourceAccessRequests sets resource access requests support flag
|
||||
SetSupportsResourceAccessRequests(Bool)
|
||||
|
||||
// GetTrial returns the trial flag
|
||||
GetTrial() Bool
|
||||
// SetTrial sets the trial flag
|
||||
SetTrial(Bool)
|
||||
|
||||
// SetLabels sets metadata labels
|
||||
SetLabels(labels map[string]string)
|
||||
|
||||
@@ -329,12 +334,25 @@ func (c *LicenseV3) SetSupportsResourceAccessRequests(value Bool) {
|
||||
c.Spec.SupportsResourceAccessRequests = value
|
||||
}
|
||||
|
||||
// GetTrial returns the trial flag
|
||||
func (c *LicenseV3) GetTrial() Bool {
|
||||
return c.Spec.Trial
|
||||
}
|
||||
|
||||
// SetTrial sets the trial flag
|
||||
func (c *LicenseV3) SetTrial(value Bool) {
|
||||
c.Spec.Trial = value
|
||||
}
|
||||
|
||||
// String represents a human readable version of license enabled features
|
||||
func (c *LicenseV3) String() string {
|
||||
var features []string
|
||||
if !c.Expiry().IsZero() {
|
||||
features = append(features, fmt.Sprintf("expires at %v", c.Expiry()))
|
||||
}
|
||||
if c.GetTrial() {
|
||||
features = append(features, "is trial")
|
||||
}
|
||||
if c.GetReportsUsage() {
|
||||
features = append(features, "reports usage")
|
||||
}
|
||||
@@ -401,4 +419,6 @@ type LicenseSpecV3 struct {
|
||||
SupportsMachineID Bool `json:"machine_id,omitempty"`
|
||||
// SupportsResourceAccessRequests turns resource access request support on or off
|
||||
SupportsResourceAccessRequests Bool `json:"resource_access_requests,omitempty"`
|
||||
// Trial is true for trial licenses
|
||||
Trial Bool `json:"trial,omitempty"`
|
||||
}
|
||||
|
||||
@@ -34,6 +34,9 @@ func TestLicenseSettersAndGetters(t *testing.T) {
|
||||
License.GetSupportsDatabaseAccess,
|
||||
License.GetSupportsDesktopAccess,
|
||||
License.GetSupportsModeratedSessions,
|
||||
License.GetSupportsMachineID,
|
||||
License.GetSupportsResourceAccessRequests,
|
||||
License.GetTrial,
|
||||
}
|
||||
|
||||
// unsetFields returns a list of license fields getters minus
|
||||
@@ -96,6 +99,24 @@ func TestLicenseSettersAndGetters(t *testing.T) {
|
||||
getter: License.GetSupportsModeratedSessions,
|
||||
unsetFields: unsetFields(License.GetSupportsModeratedSessions),
|
||||
},
|
||||
{
|
||||
name: "Set Machine ID Support",
|
||||
setter: License.SetSupportsMachineID,
|
||||
getter: License.GetSupportsMachineID,
|
||||
unsetFields: unsetFields(License.GetSupportsMachineID),
|
||||
},
|
||||
{
|
||||
name: "Set Resource Access Request Support",
|
||||
setter: License.SetSupportsResourceAccessRequests,
|
||||
getter: License.GetSupportsResourceAccessRequests,
|
||||
unsetFields: unsetFields(License.GetSupportsResourceAccessRequests),
|
||||
},
|
||||
{
|
||||
name: "Set Trial Support",
|
||||
setter: License.SetTrial,
|
||||
getter: License.GetTrial,
|
||||
unsetFields: unsetFields(License.GetTrial),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tt {
|
||||
@@ -123,6 +144,9 @@ func TestLicenseSettersAndGetters(t *testing.T) {
|
||||
require.False(t, bool(license.GetSupportsDatabaseAccess()))
|
||||
require.False(t, bool(license.GetSupportsDesktopAccess()))
|
||||
require.False(t, bool(license.GetSupportsModeratedSessions()))
|
||||
require.False(t, bool(license.GetSupportsMachineID()))
|
||||
require.False(t, bool(license.GetSupportsResourceAccessRequests()))
|
||||
require.False(t, bool(license.GetTrial()))
|
||||
}
|
||||
|
||||
func fnName(i interface{}) string {
|
||||
|
||||
Reference in New Issue
Block a user