MCPcopy Index your code
hub / github.com/coder/coder / TestBoundaryLicenseVerification

Function TestBoundaryLicenseVerification

enterprise/cli/boundary_test.go:45–234  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func TestBoundaryLicenseVerification(t *testing.T) {
46 t.Parallel()
47
48 t.Run("EntitledAndEnabled", func(t *testing.T) {
49 t.Parallel()
50
51 client, _ := coderdenttest.New(t, &coderdenttest.Options{
52 LicenseOptions: &coderdenttest.LicenseOptions{
53 Features: license.Features{
54 codersdk.FeatureBoundary: 1,
55 },
56 },
57 })
58
59 inv, conf := newCLI(t, "boundary", "--version")
60 //nolint:gocritic // requires owner
61 clitest.SetupConfig(t, client, conf)
62
63 ctx := testutil.Context(t, testutil.WaitShort)
64 err := inv.WithContext(ctx).Run()
65 // Should succeed - boundary --version should work with valid license.
66 require.NoError(t, err)
67 })
68
69 t.Run("NotEntitled", func(t *testing.T) {
70 t.Parallel()
71
72 // Create a proxy server that returns entitlements without boundary feature.
73 client, _ := coderdenttest.New(t, &coderdenttest.Options{
74 LicenseOptions: &coderdenttest.LicenseOptions{
75 Features: license.Features{
76 // No FeatureBoundary
77 },
78 },
79 })
80
81 proxy := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
82 if r.URL.Path == "/api/v2/entitlements" {
83 res := codersdk.Entitlements{
84 Features: map[codersdk.FeatureName]codersdk.Feature{},
85 Warnings: []string{},
86 Errors: []string{},
87 HasLicense: true,
88 Trial: false,
89 RequireTelemetry: false,
90 }
91 // Set boundary to not entitled, all other features to entitled.
92 for _, feature := range codersdk.FeatureNames {
93 if feature == codersdk.FeatureBoundary {
94 // Explicitly set boundary to not entitled.
95 res.Features[feature] = codersdk.Feature{
96 Entitlement: codersdk.EntitlementNotEntitled,
97 Enabled: false,
98 }
99 } else {
100 res.Features[feature] = codersdk.Feature{
101 Entitlement: codersdk.EntitlementEntitled,
102 Enabled: true,

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
NewFunction · 0.92
SetupConfigFunction · 0.92
ContextFunction · 0.92
WriteFunction · 0.92
NewFunction · 0.92
WithHTTPClientFunction · 0.92
NewIsolatedHTTPClientFunction · 0.92
NewFunction · 0.92
newCLIFunction · 0.85
WithContextMethod · 0.80
SetSessionTokenMethod · 0.80

Tested by

no test coverage detected