Skip to content

Commit

Permalink
roles: add SSC admin role (#60)
Browse files Browse the repository at this point in the history
Adds SSC admin role to SDK
## Test plan
CI
  • Loading branch information
jac authored Aug 27, 2024
1 parent d6a8a50 commit 8ac8aea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
14 changes: 12 additions & 2 deletions roles/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ func (r Role) Parse() (_ ParsedRole, valid bool) {
}, true
}

// services.Dotcom
var (
// services.Dotcom

// Dotcom site admin
RoleDotcomSiteAdmin = ToRole(services.Dotcom, "site_admin")

Expand All @@ -78,6 +77,16 @@ var (
}
)

// services.SSC
var (
// SSC admin
RoleSSCAdmin = ToRole(services.SSC, "admin")

sscRoles = []Role{
RoleSSCAdmin,
}
)

// AllowedRoles is a concrete list of allowed roles that can be granted to a user.
type AllowedRoles []Role

Expand All @@ -91,6 +100,7 @@ func Allowed() AllowedRoles {
}

appendRoles(dotcomRoles)
appendRoles(sscRoles)
// 👉 ADD YOUR ROLES HERE

return allowed
Expand Down
2 changes: 1 addition & 1 deletion roles/roles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestAllowedGoldenList(t *testing.T) {
autogold.Expect(AllowedRoles{Role("dotcom::site_admin")}).Equal(t, Allowed())
autogold.Expect(AllowedRoles{Role("dotcom::site_admin"), Role("ssc::admin")}).Equal(t, Allowed())
}

func TestAllowedContains(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const (
SAMS Service = "sams"
TelemetryGateway Service = "telemetry_gateway"
EnterprisePortal Service = "enterprise_portal"
SSC Service = "ssc"
)

var serviceNames = map[Service]string{
Expand All @@ -18,6 +19,7 @@ var serviceNames = map[Service]string{
SAMS: "Sourcegraph Accounts Management System",
TelemetryGateway: "Telemetry Gateway",
EnterprisePortal: "Enterprise Portal",
SSC: "Self Serve Cody",
}

func (s Service) DisplayName() string {
Expand Down

0 comments on commit 8ac8aea

Please sign in to comment.