chore: protect organization endpoints with license (#14001)

* chore: move multi-org endpoints into enterprise directory

All multi-organization features are gated behind "premium" licenses. Enterprise licenses can no longer
access organization CRUD.
This commit is contained in:
Steven Masley
2024-07-25 16:07:53 -05:00
committed by GitHub
parent 915f69080a
commit 7ea1a4c686
37 changed files with 2222 additions and 1678 deletions

View File

@ -9,7 +9,6 @@ import (
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/coderd/rbac"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/testutil"
)
@ -36,43 +35,6 @@ func TestListOrganizationMembers(t *testing.T) {
})
}
func TestAddOrganizationMembers(t *testing.T) {
t.Parallel()
t.Run("OK", func(t *testing.T) {
t.Parallel()
ownerClient := coderdtest.New(t, &coderdtest.Options{})
owner := coderdtest.CreateFirstUser(t, ownerClient)
_, user := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID)
ctx := testutil.Context(t, testutil.WaitMedium)
//nolint:gocritic // must be an owner, only owners can create orgs
otherOrg, err := ownerClient.CreateOrganization(ctx, codersdk.CreateOrganizationRequest{
Name: "Other",
DisplayName: "",
Description: "",
Icon: "",
})
require.NoError(t, err, "create another organization")
inv, root := clitest.New(t, "organization", "members", "add", "-O", otherOrg.ID.String(), user.Username)
//nolint:gocritic // must be an owner
clitest.SetupConfig(t, ownerClient, root)
buf := new(bytes.Buffer)
inv.Stdout = buf
err = inv.WithContext(ctx).Run()
require.NoError(t, err)
//nolint:gocritic // must be an owner
members, err := ownerClient.OrganizationMembers(ctx, otherOrg.ID)
require.NoError(t, err)
require.Len(t, members, 2)
})
}
func TestRemoveOrganizationMembers(t *testing.T) {
t.Parallel()