feat: set metadata field in UpdateUser endpoint (#11747)

# Which Problems Are Solved

To be able to update metadata via the `UpdateUser` endpoint.

# How the Problems Are Solved
This is achieved by:
* adding the `Metadata` field to `UpdateUserRequest`
* update the server layer to convert/set metadata fields to domain layer
metadata
* update the command layer to handle metadata updates

# Additional Changes

N/A

# Additional Context
- Related to https://github.com/zitadel/zitadel/issues/11369,
https://github.com/zitadel/zitadel/issues/11759
- Follow-up for PR https://github.com/zitadel/zitadel/pull/11719

---------

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Gayathri Vijayan
2026-03-09 10:47:32 +01:00
committed by GitHub
co-authored by Copilot
parent 5b12690757
commit 282b2486d9
14 changed files with 896 additions and 165 deletions
+22 -1
View File
@@ -20,6 +20,7 @@ func Test_patchHumanUserToCommand(t *testing.T) {
userId string
userName *string
human *user.UpdateUserRequest_Human
metadata []*user.Metadata
}
tests := []struct {
name string
@@ -81,6 +82,16 @@ func Test_patchHumanUserToCommand(t *testing.T) {
},
},
},
metadata: []*user.Metadata{
{
Key: "key1",
Value: []byte("value1"),
},
{
Key: "key2",
Value: []byte("value2"),
},
},
},
want: &command.ChangeHuman{
ID: "userId",
@@ -106,6 +117,16 @@ func Test_patchHumanUserToCommand(t *testing.T) {
Password: "newPassword",
ChangeRequired: true,
},
Metadata: []*domain.Metadata{
{
Key: "key1",
Value: []byte("value1"),
},
{
Key: "key2",
Value: []byte("value2"),
},
},
},
wantErr: assert.NoError,
}, {
@@ -242,7 +263,7 @@ func Test_patchHumanUserToCommand(t *testing.T) {
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := updateHumanUserToCommand(tt.args.userId, tt.args.userName, tt.args.human)
got, err := updateHumanUserToCommand(tt.args.userId, tt.args.userName, tt.args.human, tt.args.metadata)
if !tt.wantErr(t, err, fmt.Sprintf("patchHumanUserToCommand(%v, %v, %v)", tt.args.userId, tt.args.userName, tt.args.human)) {
return
}