Skip to content

Commit

Permalink
fix: remove check constraint
Browse files Browse the repository at this point in the history
Tests now use the new httpclient to properly handle empty strings vs
<nil> strings (where the value is omitted in the JSON request).
  • Loading branch information
hperl authored and aeneasr committed Sep 14, 2022
1 parent a22dd19 commit 54c00c3
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 132 deletions.
3 changes: 3 additions & 0 deletions .docker/Dockerfile-build
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ ADD go.sum go.sum
ADD proto/go.mod proto/go.mod
ADD proto/go.sum proto/go.sum

ADD internal/httpclient-next/go.mod internal/httpclient-next/go.mod
ADD internal/httpclient-next/go.sum internal/httpclient-next/go.sum

ENV CGO_ENABLED 1

RUN go mod download
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ replace (
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
github.com/mattn/go-sqlite3 => github.com/mattn/go-sqlite3 v1.14.10
github.com/oleiade/reflections => github.com/oleiade/reflections v1.0.1
github.com/ory/keto/internal/httpclient-next => ./internal/httpclient-next
github.com/ory/keto/proto => ./proto
github.com/soheilhy/cmux => github.com/soheilhy/cmux v0.1.5-0.20210114230657-cdd3331e3e7c
)
Expand All @@ -27,6 +28,7 @@ require (
github.com/ory/graceful v0.1.3
github.com/ory/herodot v0.9.13
github.com/ory/jsonschema/v3 v3.0.7
github.com/ory/keto/internal/httpclient-next v0.0.0-00010101000000-000000000000
github.com/ory/keto/proto v0.0.0-00010101000000-000000000000
github.com/ory/x v0.0.463
github.com/pelletier/go-toml v1.9.5
Expand Down
32 changes: 31 additions & 1 deletion internal/e2e/cases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,36 @@ func runCases(c client, m *namespaceTestManager) func(*testing.T) {
assert.True(t, c.check(t, tuple))
})

t.Run("case=creates tuple with empty IDs", func(t *testing.T) {
n := &namespace.Namespace{Name: t.Name()}
m.add(t, n)

tuples := []*ketoapi.RelationTuple{{
Namespace: n.Name,
Object: "",
Relation: "access",
SubjectID: x.Ptr(""),
}, {
Namespace: n.Name,
Object: "",
Relation: "access",
SubjectSet: &ketoapi.SubjectSet{
Namespace: n.Name,
Object: "",
Relation: "access",
},
}}

for _, tp := range tuples {
c.createTuple(t, tp)
// try the check API to see whether the tuple is interpreted correctly
assert.True(t, c.check(t, tp))
}

resp := c.queryTuple(t, &ketoapi.RelationQuery{Namespace: &n.Name})
assert.ElementsMatch(t, tuples, resp.RelationTuples)
})

t.Run("case=check subjectSet relations", func(t *testing.T) {
n := &namespace.Namespace{Name: t.Name()}
m.add(t, n)
Expand Down Expand Up @@ -216,7 +246,7 @@ func runCases(c client, m *namespaceTestManager) func(*testing.T) {

c.deleteAllTuples(t, q)
resp = c.queryTuple(t, q)
assert.Equal(t, len(resp.RelationTuples), 0)
assert.Equal(t, 0, len(resp.RelationTuples))
})

t.Run("case=returns error with status code on unknown namespace", func(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/e2e/full_suit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"testing"
"time"

"github.com/ory/keto/ketoapi"

"github.com/ory/herodot"
"github.com/ory/x/cmdx"
prometheus "github.com/ory/x/prometheusx"
Expand All @@ -21,6 +19,7 @@ import (
"github.com/ory/keto/internal/relationtuple"
"github.com/ory/keto/internal/x"
"github.com/ory/keto/internal/x/dbx"
"github.com/ory/keto/ketoapi"
)

type (
Expand Down
Loading

0 comments on commit 54c00c3

Please sign in to comment.