diff --git a/pkg/authz/objecttype/spec.go b/pkg/authz/objecttype/spec.go index 9814565..156c3a9 100644 --- a/pkg/authz/objecttype/spec.go +++ b/pkg/authz/objecttype/spec.go @@ -44,7 +44,7 @@ type ObjectTypeSpec struct { type CreateObjectTypeSpec struct { Type string `json:"type" validate:"required,valid_object_type"` 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 CreateObjectTypeSpec) ToObjectType() (*ObjectType, error) { diff --git a/tests/v1/object-types-crud.json b/tests/v1/object-types-crud.json index 298e10e..350d9ca 100644 --- a/tests/v1/object-types-crud.json +++ b/tests/v1/object-types-crud.json @@ -4,7 +4,7 @@ ], "tests": [ { - "name": "failToCreateObjectWithoutRelations", + "name": "failToCreateObjectTypeWithoutRelations", "request": { "method": "POST", "url": "/v1/object-types", @@ -21,6 +21,34 @@ } } }, + { + "name": "createObjectTypeWithEmptyRelations", + "request": { + "method": "POST", + "url": "/v1/object-types", + "body": { + "type": "A", + "relations": {} + } + }, + "expectedResponse": { + "statusCode": 200, + "body": { + "type": "A", + "relations": {} + } + } + }, + { + "name": "deleteObjectTypeWithEmptyRelations", + "request": { + "method": "DELETE", + "url": "/v1/object-types/A" + }, + "expectedResponse": { + "statusCode": 200 + } + }, { "name": "createObjectTypeReport", "request": { @@ -342,4 +370,4 @@ } } ] -} \ No newline at end of file +} diff --git a/tests/v2/object-types-crud.json b/tests/v2/object-types-crud.json index 9371057..592276e 100644 --- a/tests/v2/object-types-crud.json +++ b/tests/v2/object-types-crud.json @@ -4,7 +4,7 @@ ], "tests": [ { - "name": "failToCreateObjectWithoutRelations", + "name": "failToCreateObjectTypeWithoutRelations", "request": { "method": "POST", "url": "/v2/object-types", @@ -21,6 +21,34 @@ } } }, + { + "name": "createObjectTypeWithEmptyRelations", + "request": { + "method": "POST", + "url": "/v2/object-types", + "body": { + "type": "A", + "relations": {} + } + }, + "expectedResponse": { + "statusCode": 200, + "body": { + "type": "A", + "relations": {} + } + } + }, + { + "name": "deleteObjectTypeWithEmptyRelations", + "request": { + "method": "DELETE", + "url": "/v2/object-types/A" + }, + "expectedResponse": { + "statusCode": 200 + } + }, { "name": "createObjectTypeReport", "request": {