Skip to content

Commit

Permalink
fix: validate subjects before mapping (#1039)
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl committed Sep 29, 2022
1 parent 3724528 commit 71b30c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/relationtuple/uuid_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ func (m *Mapper) FromTuple(ctx context.Context, ts ...*ketoapi.RelationTuple) (r
}
i := len(res)

if err := t.Validate(); err != nil {
return nil, err
}
if t.SubjectID != nil {
s = append(s, *t.SubjectID)
onSuccess.do(func() {
Expand Down
11 changes: 11 additions & 0 deletions internal/relationtuple/uuid_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ func TestMapper(t *testing.T) {
},
},
},
{
name: "relation tuple without subject",
rts: []*ketoapi.RelationTuple{
{
Namespace: nspace.Name,
Object: "object",
Relation: "relation",
},
},
err: ketoapi.ErrNilSubject,
},
{
name: "many relation tuples",
rts: func() []*ketoapi.RelationTuple {
Expand Down

0 comments on commit 71b30c4

Please sign in to comment.