Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
asthamohta committed Feb 23, 2023
1 parent 21af00c commit 0479986
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions system-test/spanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,14 @@ describe('Spanner', () => {
await new Promise(resolve => setTimeout(resolve, 60000));
});

it('POSTGRESQL should create a user defined role', async function () {
if (IS_EMULATOR_ENABLED) {
this.skip();
}
await createUserDefinedDatabaseRole(PG_DATABASE, 'CREATE ROLE parent');
await new Promise(resolve => setTimeout(resolve, 60000));
});

const grantAccessToRole = async (
database,
createRoleQuery,
Expand Down Expand Up @@ -2196,6 +2204,18 @@ describe('Spanner', () => {
await new Promise(resolve => setTimeout(resolve, 60000));
});

it('POSTGRESQL should grant access to a user defined role', async function () {
if (IS_EMULATOR_ENABLED) {
this.skip();
}
await grantAccessToRole(
PG_DATABASE,
'CREATE ROLE child',
'GRANT SELECT ON TABLE Singers TO ROLE child'
);
await new Promise(resolve => setTimeout(resolve, 60000));
});

const userDefinedDatabaseRoleRevoked = async (
database,
createRoleQuery,
Expand Down Expand Up @@ -2238,6 +2258,19 @@ describe('Spanner', () => {
await new Promise(resolve => setTimeout(resolve, 60000));
});

it('POSTGRESQL should revoke permissions of a user defined role', async function () {
if (IS_EMULATOR_ENABLED) {
this.skip();
}
await userDefinedDatabaseRoleRevoked(
PG_DATABASE,
'CREATE ROLE orphan',
'GRANT SELECT ON TABLE Singers TO ROLE orphan',
'REVOKE SELECT ON TABLE Singers FROM ROLE orphan'
);
await new Promise(resolve => setTimeout(resolve, 60000));
});

const userDefinedDatabaseRoleDropped = async (
database,
createRoleQuery,
Expand Down Expand Up @@ -2277,6 +2310,18 @@ describe('Spanner', () => {
await new Promise(resolve => setTimeout(resolve, 60000));
});

it('POSTGRESQL should drop the user defined role', async function () {
if (IS_EMULATOR_ENABLED) {
this.skip();
}
await userDefinedDatabaseRoleDropped(
PG_DATABASE,
'CREATE ROLE new_parent',
'DROP ROLE new_parent'
);
await new Promise(resolve => setTimeout(resolve, 60000));
});

const grantAccessSuccess = (done, database) => {
const id = 7;
database.updateSchema(
Expand Down Expand Up @@ -2318,6 +2363,13 @@ describe('Spanner', () => {
grantAccessSuccess(done, DATABASE);
});

it('POSTGRESQL should run query with access granted', function (done) {
if (IS_EMULATOR_ENABLED) {
this.skip();
}
grantAccessSuccess(done, PG_DATABASE);
});

const grantAccessFailure = (done, database) => {
const id = 8;
database.updateSchema(
Expand Down Expand Up @@ -2359,6 +2411,13 @@ describe('Spanner', () => {
grantAccessFailure(done, DATABASE);
});

it('POSTGRESQL should fail run query due to no access granted', function (done) {
if (IS_EMULATOR_ENABLED) {
this.skip();
}
grantAccessFailure(done, PG_DATABASE);
});

const listDatabaseRoles = async database => {
const [updateRole] = await database.updateSchema([
'CREATE ROLE new_parent',
Expand All @@ -2383,6 +2442,13 @@ describe('Spanner', () => {
await listDatabaseRoles(DATABASE);
});

it('POSTGRESQL should list database roles', async function () {
if (IS_EMULATOR_ENABLED) {
this.skip();
}
await listDatabaseRoles(PG_DATABASE);
});

const getIamPolicy = (done, database) => {
database.getIamPolicy((err, policy) => {
assert.ifError(err);
Expand Down

0 comments on commit 0479986

Please sign in to comment.