mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore!: allow CreateUser to accept multiple organizations (#14383)
* chore: allow CreateUser to accept multiple organizations In a multi-org deployment, it makes more sense to allow for multiple org memberships to be assigned at create. The legacy param will still be honored. * Handle sdk deprecation better by maintaining cli functions
This commit is contained in:
+20
-23
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/v2/cli/clitest"
|
||||
@@ -26,13 +27,12 @@ func TestUserDelete(t *testing.T) {
|
||||
pw, err := cryptorand.String(16)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = client.CreateUser(ctx, codersdk.CreateUserRequest{
|
||||
Email: "colin5@coder.com",
|
||||
Username: "coolin",
|
||||
Password: pw,
|
||||
UserLoginType: codersdk.LoginTypePassword,
|
||||
OrganizationID: owner.OrganizationID,
|
||||
DisableLogin: false,
|
||||
_, err = client.CreateUserWithOrgs(ctx, codersdk.CreateUserRequestWithOrgs{
|
||||
Email: "colin5@coder.com",
|
||||
Username: "coolin",
|
||||
Password: pw,
|
||||
UserLoginType: codersdk.LoginTypePassword,
|
||||
OrganizationIDs: []uuid.UUID{owner.OrganizationID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -57,13 +57,12 @@ func TestUserDelete(t *testing.T) {
|
||||
pw, err := cryptorand.String(16)
|
||||
require.NoError(t, err)
|
||||
|
||||
user, err := client.CreateUser(ctx, codersdk.CreateUserRequest{
|
||||
Email: "colin5@coder.com",
|
||||
Username: "coolin",
|
||||
Password: pw,
|
||||
UserLoginType: codersdk.LoginTypePassword,
|
||||
OrganizationID: owner.OrganizationID,
|
||||
DisableLogin: false,
|
||||
user, err := client.CreateUserWithOrgs(ctx, codersdk.CreateUserRequestWithOrgs{
|
||||
Email: "colin5@coder.com",
|
||||
Username: "coolin",
|
||||
Password: pw,
|
||||
UserLoginType: codersdk.LoginTypePassword,
|
||||
OrganizationIDs: []uuid.UUID{owner.OrganizationID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -88,13 +87,12 @@ func TestUserDelete(t *testing.T) {
|
||||
pw, err := cryptorand.String(16)
|
||||
require.NoError(t, err)
|
||||
|
||||
user, err := client.CreateUser(ctx, codersdk.CreateUserRequest{
|
||||
Email: "colin5@coder.com",
|
||||
Username: "coolin",
|
||||
Password: pw,
|
||||
UserLoginType: codersdk.LoginTypePassword,
|
||||
OrganizationID: owner.OrganizationID,
|
||||
DisableLogin: false,
|
||||
user, err := client.CreateUserWithOrgs(ctx, codersdk.CreateUserRequestWithOrgs{
|
||||
Email: "colin5@coder.com",
|
||||
Username: "coolin",
|
||||
Password: pw,
|
||||
UserLoginType: codersdk.LoginTypePassword,
|
||||
OrganizationIDs: []uuid.UUID{owner.OrganizationID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -121,13 +119,12 @@ func TestUserDelete(t *testing.T) {
|
||||
// pw, err := cryptorand.String(16)
|
||||
// require.NoError(t, err)
|
||||
|
||||
// toDelete, err := client.CreateUser(ctx, codersdk.CreateUserRequest{
|
||||
// toDelete, err := client.CreateUserWithOrgs(ctx, codersdk.CreateUserRequestWithOrgs{
|
||||
// Email: "colin5@coder.com",
|
||||
// Username: "coolin",
|
||||
// Password: pw,
|
||||
// UserLoginType: codersdk.LoginTypePassword,
|
||||
// OrganizationID: aUser.OrganizationID,
|
||||
// DisableLogin: false,
|
||||
// })
|
||||
// require.NoError(t, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user