Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: rename feature rbac to template_rbac#4486

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bpmct merged 3 commits intomainfromdean/rename-feature-rbac
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
4 changes: 2 additions & 2 deletionscodersdk/features.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@ const (
FeatureBrowserOnly = "browser_only"
FeatureSCIM = "scim"
FeatureWorkspaceQuota = "workspace_quota"
FeatureRBAC= "rbac"
FeatureTemplateRBAC = "template_rbac"
)

var FeatureNames = []string{
Expand All@@ -29,7 +29,7 @@ var FeatureNames = []string{
FeatureBrowserOnly,
FeatureSCIM,
FeatureWorkspaceQuota,
FeatureRBAC,
FeatureTemplateRBAC,
}

type Feature struct {
Expand Down
2 changes: 1 addition & 1 deletionenterprise/cli/features_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,7 +68,7 @@ func TestFeaturesList(t *testing.T) {
assert.Equal(t, codersdk.EntitlementNotEntitled,
entitlements.Features[codersdk.FeatureWorkspaceQuota].Entitlement)
assert.Equal(t, codersdk.EntitlementNotEntitled,
entitlements.Features[codersdk.FeatureRBAC].Entitlement)
entitlements.Features[codersdk.FeatureTemplateRBAC].Entitlement)
assert.Equal(t, codersdk.EntitlementNotEntitled,
entitlements.Features[codersdk.FeatureSCIM].Entitlement)
assert.False(t, entitlements.HasLicense)
Expand Down
2 changes: 1 addition & 1 deletionenterprise/coderd/authorize_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ func TestCheckACLPermissions(t *testing.T) {
// Create adminClient, member, and org adminClient
adminUser := coderdtest.CreateFirstUser(t, adminClient)
_ = coderdenttest.AddLicense(t, adminClient, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})

memberClient := coderdtest.CreateAnotherUser(t, adminClient, adminUser.OrganizationID)
Expand Down
6 changes: 3 additions & 3 deletionsenterprise/coderd/coderd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,7 @@ func New(ctx context.Context, options *Options) (*API, error) {

r.Route("/templates/{template}/acl", func(r chi.Router) {
r.Use(
api.rbacEnabledMW,
api.templateRBACEnabledMW,
apiKeyMiddleware,
httpmw.ExtractTemplateParam(api.Database),
)
Expand All@@ -80,7 +80,7 @@ func New(ctx context.Context, options *Options) (*API, error) {

r.Route("/groups/{group}", func(r chi.Router) {
r.Use(
api.rbacEnabledMW,
api.templateRBACEnabledMW,
apiKeyMiddleware,
httpmw.ExtractGroupParam(api.Database),
)
Expand DownExpand Up@@ -157,7 +157,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
codersdk.FeatureBrowserOnly: api.BrowserOnly,
codersdk.FeatureSCIM: len(api.SCIMAPIKey) != 0,
codersdk.FeatureWorkspaceQuota: api.UserWorkspaceQuota != 0,
codersdk.FeatureRBAC: api.RBACEnabled,
codersdk.FeatureTemplateRBAC: api.RBACEnabled,
})
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletionsenterprise/coderd/coderd_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,9 +41,9 @@ func TestEntitlements(t *testing.T) {
})
_ = coderdtest.CreateFirstUser(t, client)
coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
UserLimit: 100,
AuditLog: true,
RBACEnabled: true,
UserLimit:100,
AuditLog:true,
TemplateRBACEnabled: true,
})
res, err := client.Entitlements(context.Background())
require.NoError(t, err)
Expand Down
32 changes: 16 additions & 16 deletionsenterprise/coderd/coderdenttest/coderdenttest.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -87,18 +87,18 @@ func NewWithAPI(t *testing.T, options *Options) (*codersdk.Client, io.Closer, *c
}

type LicenseOptions struct {
AccountType string
AccountID string
Trial bool
AllFeatures bool
GraceAt time.Time
ExpiresAt time.Time
UserLimit int64
AuditLog bool
BrowserOnly bool
SCIM bool
WorkspaceQuota bool
RBACEnabled bool
AccountTypestring
AccountIDstring
Trialbool
AllFeaturesbool
GraceAttime.Time
ExpiresAttime.Time
UserLimitint64
AuditLogbool
BrowserOnlybool
SCIMbool
WorkspaceQuotabool
TemplateRBACEnabled bool
}

// AddLicense generates a new license with the options provided and inserts it.
Expand DownExpand Up@@ -135,9 +135,9 @@ func GenerateLicense(t *testing.T, options LicenseOptions) string {
workspaceQuota = 1
}

rbac := int64(0)
if options.RBACEnabled {
rbac = 1
rbacEnabled := int64(0)
if options.TemplateRBACEnabled {
rbacEnabled = 1
}

c := &license.Claims{
Expand All@@ -159,7 +159,7 @@ func GenerateLicense(t *testing.T, options LicenseOptions) string {
BrowserOnly: browserOnly,
SCIM: scim,
WorkspaceQuota: workspaceQuota,
RBAC: rbac,
TemplateRBAC:rbacEnabled,
},
}
tok := jwt.NewWithClaims(jwt.SigningMethodEdDSA, c)
Expand Down
2 changes: 1 addition & 1 deletionenterprise/coderd/coderdenttest/coderdenttest_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
ctx, _ := testutil.Context(t)
admin := coderdtest.CreateFirstUser(t, client)
license := coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
group, err := client.CreateGroup(ctx, admin.OrganizationID, codersdk.CreateGroupRequest{
Name: "testgroup",
Expand Down
36 changes: 18 additions & 18 deletionsenterprise/coderd/groups_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func TestCreateGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
ctx, _ := testutil.Context(t)
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
Expand All@@ -43,7 +43,7 @@ func TestCreateGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
ctx, _ := testutil.Context(t)
_, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
Expand All@@ -67,7 +67,7 @@ func TestCreateGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
ctx, _ := testutil.Context(t)
_, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
Expand All@@ -90,7 +90,7 @@ func TestPatchGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
ctx, _ := testutil.Context(t)
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
Expand All@@ -112,7 +112,7 @@ func TestPatchGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
_, user2 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
_, user3 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
Expand All@@ -138,7 +138,7 @@ func TestPatchGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
_, user2 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
_, user3 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
Expand DownExpand Up@@ -173,7 +173,7 @@ func TestPatchGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
ctx, _ := testutil.Context(t)
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
Expand All@@ -197,7 +197,7 @@ func TestPatchGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
ctx, _ := testutil.Context(t)
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
Expand All@@ -221,7 +221,7 @@ func TestPatchGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
_, user2 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
ctx, _ := testutil.Context(t)
Expand All@@ -247,7 +247,7 @@ func TestPatchGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
ctx, _ := testutil.Context(t)
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
Expand DownExpand Up@@ -276,7 +276,7 @@ func TestGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
ctx, _ := testutil.Context(t)
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
Expand All@@ -296,7 +296,7 @@ func TestGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
_, user2 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
_, user3 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
Expand DownExpand Up@@ -326,7 +326,7 @@ func TestGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
client1, _ := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)

Expand All@@ -347,7 +347,7 @@ func TestGroup(t *testing.T) {
client := coderdenttest.New(t, nil)
user := coderdtest.CreateFirstUser(t, client)
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})

_, user1 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
Expand DownExpand Up@@ -380,7 +380,7 @@ func TestGroup(t *testing.T) {
client := coderdenttest.New(t, nil)
user := coderdtest.CreateFirstUser(t, client)
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})

_, user1 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
Expand DownExpand Up@@ -421,7 +421,7 @@ func TestGroups(t *testing.T) {
client := coderdenttest.New(t, nil)
user := coderdtest.CreateFirstUser(t, client)
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
_, user2 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
_, user3 := coderdtest.CreateAnotherUserWithUser(t, client, user.OrganizationID)
Expand DownExpand Up@@ -467,7 +467,7 @@ func TestDeleteGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
ctx, _ := testutil.Context(t)
group1, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
Expand All@@ -492,7 +492,7 @@ func TestDeleteGroup(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
RBACEnabled: true,
TemplateRBACEnabled: true,
})
ctx, _ := testutil.Context(t)
err := client.DeleteGroup(ctx, user.OrganizationID)
Expand Down
8 changes: 4 additions & 4 deletionsenterprise/coderd/license/license.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,10 +96,10 @@ func Entitlements(ctx context.Context, db database.Store, logger slog.Logger, ke
Enabled: enablements[codersdk.FeatureWorkspaceQuota],
}
}
if claims.Features.RBAC > 0 {
entitlements.Features[codersdk.FeatureRBAC] = codersdk.Feature{
if claims.Features.TemplateRBAC > 0 {
entitlements.Features[codersdk.FeatureTemplateRBAC] = codersdk.Feature{
Entitlement: entitlement,
Enabled: enablements[codersdk.FeatureRBAC],
Enabled: enablements[codersdk.FeatureTemplateRBAC],
}
}
if claims.AllFeatures {
Expand DownExpand Up@@ -176,7 +176,7 @@ type Features struct {
BrowserOnly int64 `json:"browser_only"`
SCIM int64 `json:"scim"`
WorkspaceQuota int64 `json:"workspace_quota"`
RBACint64 `json:"rbac"`
TemplateRBAC int64 `json:"template_rbac"`
}

type Claims struct {
Expand Down
30 changes: 15 additions & 15 deletionsenterprise/coderd/license/license_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func TestEntitlements(t *testing.T) {
codersdk.FeatureBrowserOnly: true,
codersdk.FeatureSCIM: true,
codersdk.FeatureWorkspaceQuota: true,
codersdk.FeatureRBAC: true,
codersdk.FeatureTemplateRBAC: true,
}

t.Run("Defaults", func(t *testing.T) {
Expand DownExpand Up@@ -60,12 +60,12 @@ func TestEntitlements(t *testing.T) {
db := databasefake.New()
db.InsertLicense(context.Background(), database.InsertLicenseParams{
JWT: coderdenttest.GenerateLicense(t, coderdenttest.LicenseOptions{
UserLimit: 100,
AuditLog: true,
BrowserOnly: true,
SCIM: true,
WorkspaceQuota: true,
RBACEnabled: true,
UserLimit:100,
AuditLog:true,
BrowserOnly:true,
SCIM:true,
WorkspaceQuota:true,
TemplateRBACEnabled: true,
}),
Exp: time.Now().Add(time.Hour),
})
Expand All@@ -82,14 +82,14 @@ func TestEntitlements(t *testing.T) {
db := databasefake.New()
db.InsertLicense(context.Background(), database.InsertLicenseParams{
JWT: coderdenttest.GenerateLicense(t, coderdenttest.LicenseOptions{
UserLimit: 100,
AuditLog: true,
BrowserOnly: true,
SCIM: true,
WorkspaceQuota: true,
RBACEnabled: true,
GraceAt: time.Now().Add(-time.Hour),
ExpiresAt: time.Now().Add(time.Hour),
UserLimit:100,
AuditLog:true,
BrowserOnly:true,
SCIM:true,
WorkspaceQuota:true,
TemplateRBACEnabled: true,
GraceAt:time.Now().Add(-time.Hour),
ExpiresAt:time.Now().Add(time.Hour),
}),
Exp: time.Now().Add(time.Hour),
})
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp