Skip to content

Commit

Permalink
Allow object-type updates with an empty relations block (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkajla12 authored Apr 2, 2024
1 parent 0b7eb1b commit a5af6b7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/authz/objecttype/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (spec CreateObjectTypeSpec) ToObjectType() (*ObjectType, error) {
type UpdateObjectTypeSpec struct {
Type string `json:"type"` // NOTE: used internally for updates, but value from request is ignored
Source *Source `json:"source,omitempty"`
Relations map[string]RelationRule `json:"relations" validate:"required,min=1,dive"` // NOTE: map key = name of relation
Relations map[string]RelationRule `json:"relations" validate:"required,dive"` // NOTE: map key = name of relation
}

func (spec *UpdateObjectTypeSpec) ToObjectType(typeId string) (*ObjectType, error) {
Expand Down
18 changes: 18 additions & 0 deletions tests/v1/object-types-crud.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@
}
}
},
{
"name": "updateObjectTypeWithEmptyRelations",
"request": {
"method": "PUT",
"url": "/v1/object-types/A",
"body": {
"type": "A",
"relations": {}
}
},
"expectedResponse": {
"statusCode": 200,
"body": {
"type": "A",
"relations": {}
}
}
},
{
"name": "deleteObjectTypeWithEmptyRelations",
"request": {
Expand Down
18 changes: 18 additions & 0 deletions tests/v2/object-types-crud.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@
}
}
},
{
"name": "updateObjectTypeWithEmptyRelations",
"request": {
"method": "PUT",
"url": "/v2/object-types/A",
"body": {
"type": "A",
"relations": {}
}
},
"expectedResponse": {
"statusCode": 200,
"body": {
"type": "A",
"relations": {}
}
}
},
{
"name": "deleteObjectTypeWithEmptyRelations",
"request": {
Expand Down

0 comments on commit a5af6b7

Please sign in to comment.