Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ACL Query): Fixes queries which use variable at the top level (#6… #6298

Merged
merged 1 commit into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions edgraph/access_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,10 @@ func parsePredsFromQuery(gqls []*gql.GraphQuery) predsAndvars {
}
preds := make([]string, 0, len(predsMap))
for pred := range predsMap {
if _, found := varsMap[pred]; !found {
preds = append(preds, pred)
if len(pred) > 0 {
if _, found := varsMap[pred]; !found {
preds = append(preds, pred)
}
}
}

Expand Down
22 changes: 22 additions & 0 deletions ee/acl/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,28 @@ func TestValQueryWithACLPermissions(t *testing.T) {
`{"q1":[{"name":"RandomGuy","age":23},{"name":"RandomGuy2","age":25}],
"q2":[{"name":"RandomGuy2","val(n)":"RandomGuy2","val(a)":25},{"name":"RandomGuy","val(n)":"RandomGuy","val(a)":23}]}`,
},
{
`{
f as q1(func: has(name), orderasc: name) {
name
age
}
q2(func: uid(f), orderasc: name) {
name
age
}
}`,
"alice doesn't have access to name or age",
`{"q2":[]}`,

`alice has access to name`,
`{"q1":[{"name":"RandomGuy"},{"name":"RandomGuy2"}],
"q2":[{"name":"RandomGuy"},{"name":"RandomGuy2"}]}`,

"alice has access to name and age",
`{"q1":[{"name":"RandomGuy","age":23},{"name":"RandomGuy2","age":25}],
"q2":[{"name":"RandomGuy2","age":25},{"name":"RandomGuy","age":23}]}`,
},
}

userClient, err := testutil.DgraphClient(testutil.SockAddr)
Expand Down