Skip to content

Updating ACL tests to sync up changes with Dgraph v1.2 #103

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

Merged
merged 1 commit into from
Jan 30, 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
33 changes: 19 additions & 14 deletions tests/integration/acl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ const DEV_GROUP = "dev";
// tslint:disable-next-line mocha-no-side-effect-code
const execute = promisify(exec);

// tslint:disable-next-line mocha-no-side-effect-code
const QUERY_PERMISSION_DENIED = new Error("7 PERMISSION_DENIED:\
unauthorized to query the predicate: unauthorized to do Read on predicate name");
// tslint:disable-next-line mocha-no-side-effect-code
const MUTATE_PERMISSION_DENIED = new Error("7 PERMISSION_DENIED:\
unauthorized to mutate the predicate: unauthorized to do Write on predicate name");
const MUTATE_PERMISSION_DENIED = new Error(`7 PERMISSION_DENIED:\
unauthorized to mutate following predicates: ${PRED} \n`);
// tslint:disable-next-line mocha-no-side-effect-code
const ALTER_PERMISSION_DENIED = new Error("7 PERMISSION_DENIED:\
unauthorized to alter the predicate: unauthorized to do Modify on predicate name");
const ALTER_PERMISSION_DENIED = new Error(`7 PERMISSION_DENIED:\
unauthorized to alter following predicates: ${PRED} \n`);

async function cmd(command: string) {
try {
Expand Down Expand Up @@ -104,17 +101,18 @@ async function tryReading(): Promise<Boolean> {
const txn = aclClient.newTxn();
const query = `{
me(func: has(${PRED})) {
uid
${PRED}
}
}`;
try {
const res: dgraph.Response = await txn.query(query);
expect(res.getJson().me).not.toHaveLength(0);
success = true;
} catch (e) {
expect(e).toEqual(QUERY_PERMISSION_DENIED);

const res: dgraph.Response = await txn.query(query);
const data = res.getJson();
if (data.me === undefined) {
expect(data).toEqual({});
success = false;
} else {
expect(data.me).not.toHaveLength(0);
success = true;
}
return success;
}
Expand Down Expand Up @@ -156,6 +154,13 @@ async function tryAltering(): Promise<Boolean> {
}

describe("ACL tests", () => {
it("has no access", async () => {
await aclSetup();
await expect(tryReading()).resolves.toBe(false);
await expect(tryWriting()).resolves.toBe(false);
await expect(tryAltering()).resolves.toBe(false);
});

it("only has read access", async () => {
await aclSetup();
await changePermission(4);
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/delete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe("delete", () => {
schools {
name
}
friends {
friends (orderasc: name) {
name
age
}
Expand Down