VAULT-15840: Allow updates of only entity-alias custom-metadata (#20368)

* allow updates of only custom metadata

* add changelog
This commit is contained in:
miagilepner 2023-05-01 12:42:30 +02:00 committed by GitHub
parent 190783a87f
commit 4cd982554e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 2 deletions

3
changelog/20368.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
core/identity: Allow updates of only the custom-metadata for entity alias.
```

View File

@ -211,8 +211,9 @@ func (i *IdentityStore) handleAliasCreateUpdate() framework.OperationFunc {
}
switch {
case mountAccessor == "" && name == "":
// Just a canonical ID update, maybe
if canonicalID == "" {
// Check if the canonicalID or the customMetadata are being
// updated
if canonicalID == "" && !customMetadataExists {
// Nothing to do, so be idempotent
return nil, nil
}

View File

@ -461,6 +461,46 @@ func TestIdentityStore_AliasUpdate(t *testing.T) {
"custom_metadata": map[string]string{},
},
},
{
name: "only-metadata",
createData: map[string]interface{}{
"name": "only",
"mount_accessor": githubAccessor,
"custom_metadata": map[string]string{
"foo": "bar",
},
},
updateData: map[string]interface{}{
"custom_metadata": map[string]string{
"bar": "baz",
},
},
},
{
name: "only-metadata-clear",
createData: map[string]interface{}{
"name": "only-clear",
"mount_accessor": githubAccessor,
"custom_metadata": map[string]string{
"foo": "bar",
},
},
updateData: map[string]interface{}{
"custom_metadata": map[string]string{},
},
},
{
name: "only-metadata-none-before",
createData: map[string]interface{}{
"name": "no-metadata",
"mount_accessor": githubAccessor,
},
updateData: map[string]interface{}{
"custom_metadata": map[string]string{
"foo": "bar",
},
},
},
}
handleRequest := func(t *testing.T, req *logical.Request) *logical.Response {