fix: custom userID not being added when specified in zitadel.org.v2.AddOrganizationRequest.AddOrganization() request (#9334)

# Which Problems Are Solved

When specifying a `user_id` as a human admin in
`zitadel.org.v2.AddOrganizationRequest.AddOrganization()` the `user_id`
specified in the request should have been used, before it was being
ignored, this has been fixed with this PR

# Additional Context
- Closes https://github.com/zitadel/zitadel/issues/9308

---------

Co-authored-by: Iraq Jaber <IraqJaber@gmail.com>
This commit is contained in:
Iraq
2025-02-13 09:17:05 +00:00
committed by GitHub
parent bd4e53314d
commit 66296db971
3 changed files with 19 additions and 8 deletions

View File

@@ -43,6 +43,7 @@ func TestMain(m *testing.M) {
func TestServer_AddOrganization(t *testing.T) {
idpResp := Instance.AddGenericOAuthProvider(CTX, Instance.DefaultOrg.Id)
userId := "userID"
tests := []struct {
name string
@@ -81,7 +82,7 @@ func TestServer_AddOrganization(t *testing.T) {
wantErr: true,
},
{
name: "admin with init",
name: "admin with init with userID passed for Human admin",
ctx: CTX,
req: &org.AddOrganizationRequest{
Name: gofakeit.AppName(),
@@ -89,6 +90,7 @@ func TestServer_AddOrganization(t *testing.T) {
{
UserType: &org.AddOrganizationRequest_Admin_Human{
Human: &user.AddHumanUserRequest{
UserId: &userId,
Profile: &user.SetHumanProfile{
GivenName: "firstname",
FamilyName: "lastname",
@@ -108,7 +110,7 @@ func TestServer_AddOrganization(t *testing.T) {
OrganizationId: integration.NotEmpty,
CreatedAdmins: []*org.AddOrganizationResponse_CreatedAdmin{
{
UserId: integration.NotEmpty,
UserId: userId,
EmailCode: gu.Ptr(integration.NotEmpty),
PhoneCode: nil,
},
@@ -140,7 +142,7 @@ func TestServer_AddOrganization(t *testing.T) {
IdpLinks: []*user.IDPLink{
{
IdpId: idpResp.Id,
UserId: "userID",
UserId: userId,
UserName: "username",
},
},

View File

@@ -57,6 +57,7 @@ func addOrganizationRequestAdminToCommand(admin *org.AddOrganizationRequest_Admi
if err != nil {
return nil, err
}
return &command.OrgSetupAdmin{
Human: human,
Roles: admin.GetRoles(),