Skip to content

Commit

Permalink
Have Checks return true if the start and goal relations are the same,…
Browse files Browse the repository at this point in the history
… or if we get to the same relation via a computed userset
  • Loading branch information
josephschorr committed May 20, 2021
1 parent b35f569 commit 412ce5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 14 additions & 0 deletions internal/graph/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ func onrEqual(lhs, rhs *pb.ObjectAndRelation) bool {
}

func (cc *concurrentChecker) check(ctx context.Context, req CheckRequest, relation *pb.Relation) ReduceableCheckFunc {
if req.Goal.Namespace == req.Start.Namespace && req.Goal.Relation == req.Start.Relation &&
req.Goal.ObjectId == req.Start.ObjectId {
return func(ctx context.Context, resultChan chan<- CheckResult) {
resultChan <- CheckResult{true, nil}
}
}

if relation.UsersetRewrite == nil {
return cc.checkDirect(ctx, req)
}
Expand Down Expand Up @@ -130,6 +137,13 @@ func (cc *concurrentChecker) checkComputedUserset(req CheckRequest, cu *pb.Compu
}
}

if req.Goal.Namespace == start.Namespace && req.Goal.Relation == cu.Relation &&
req.Goal.ObjectId == start.ObjectId {
return func(ctx context.Context, resultChan chan<- CheckResult) {
resultChan <- CheckResult{true, nil}
}
}

return cc.dispatch(CheckRequest{
Start: &pb.ObjectAndRelation{
Namespace: start.Namespace,
Expand Down
5 changes: 0 additions & 5 deletions internal/services/consistency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,6 @@ func TestConsistency(t *testing.T) {

// Ensure that every returned object Checks.
for _, resolvedObjectId := range result.ResolvedObjectIds {
// TODO: REMOVE ME ONCE WE FIGURE OUT THE #manager
if subject.Relation != "..." {
continue
}

checkResp, err := srv.Check(context.Background(), &api.CheckRequest{
TestUserset: &api.ObjectAndRelation{
Namespace: nsDef.Name,
Expand Down

0 comments on commit 412ce5e

Please sign in to comment.