Skip to content

Commit 5662954

Browse files
committed
tweak impersonateQuery tests
1 parent b5f03ab commit 5662954

File tree

1 file changed

+12
-32
lines changed

1 file changed

+12
-32
lines changed

test/integration/data-connect.spec.ts

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ interface DeleteResponse {
105105
}
106106

107107
const connectorConfig: ConnectorConfig = {
108-
location: 'us-west2',
108+
location: 'us-central1',
109109
serviceId: 'my-service',
110110
connector: 'example'
111111
};
@@ -473,15 +473,10 @@ describe('getDataConnect()', () => {
473473
).should.eventually.be.rejected.and.has.property('code', 'data-connect/unauthenticated');
474474
});
475475

476-
it('should successfully execute a query with @auth(level: NO_ACCESS)', async () => {
477-
const resp = await getDataConnect(connectorConfig).impersonateQuery<ListUsersResponse, undefined>(
476+
it('should fail to successfully execute a query with @auth(level: NO_ACCESS)', async () => {
477+
return getDataConnect(connectorConfig).impersonateQuery<ListUsersResponse, undefined>(
478478
{ ...optsUnauthorizedClaims, operationName: 'ListUsersNoAccess' }
479-
);
480-
expect(resp.data.users).to.be.not.empty;
481-
expect(resp.data.users.length).to.be.greaterThan(1);
482-
resp.data.users.forEach((user) => {
483-
expect(expectedUserIds).to.include(user.id);
484-
});
479+
).should.eventually.be.rejected.and.has.property('code', 'data-connect/permission-denied');
485480
});
486481
});
487482

@@ -520,15 +515,10 @@ describe('getDataConnect()', () => {
520515
).should.eventually.be.rejected.and.has.property('code', 'data-connect/unauthenticated');
521516
});
522517

523-
it('should successfully execute a query with @auth(level: NO_ACCESS)', async () => {
524-
const resp = await getDataConnect(connectorConfig).impersonateQuery<ListUsersResponse, undefined>(
518+
it('should fail to successfully execute a query with @auth(level: NO_ACCESS)', async () => {
519+
return getDataConnect(connectorConfig).impersonateQuery<ListUsersResponse, undefined>(
525520
{ ...optsAuthorizedFredAnonClaims, operationName: 'ListUsersNoAccess' }
526-
);
527-
expect(resp.data.users).to.not.be.empty;
528-
expect(resp.data.users.length).to.be.greaterThan(1);
529-
resp.data.users.forEach(user => {
530-
expect(expectedUserIds).to.include(user.id);
531-
});
521+
).should.eventually.be.rejected.and.has.property('code', 'data-connect/permission-denied');
532522
});
533523

534524
it("should use the impersonated user's auth.uid", async () => {
@@ -581,15 +571,10 @@ describe('getDataConnect()', () => {
581571
).should.eventually.be.rejected.and.has.property('code', 'data-connect/unauthenticated');
582572
});
583573

584-
it('should successfully execute a query with @auth(level: NO_ACCESS)', async () => {
585-
const resp = await getDataConnect(connectorConfig).impersonateQuery<ListUsersResponse, undefined>(
574+
it('should fail to successfully execute a query with @auth(level: NO_ACCESS)', async () => {
575+
return getDataConnect(connectorConfig).impersonateQuery<ListUsersResponse, undefined>(
586576
{ ...optsAuthorizedFredClaims, operationName: 'ListUsersNoAccess' }
587-
);
588-
expect(resp.data.users).to.not.be.empty;
589-
expect(resp.data.users.length).to.be.greaterThan(1);
590-
resp.data.users.forEach(user => {
591-
expect(expectedUserIds).to.include(user.id);
592-
});
577+
).should.eventually.be.rejected.and.has.property('code', 'data-connect/permission-denied');
593578
});
594579

595580
it("should use the impersonated user's auth.uid", async () => {
@@ -648,14 +633,9 @@ describe('getDataConnect()', () => {
648633
});
649634

650635
it('should successfully execute a query with @auth(level: NO_ACCESS)', async () => {
651-
const resp = await getDataConnect(connectorConfig).impersonateQuery<ListUsersResponse, undefined>(
636+
return getDataConnect(connectorConfig).impersonateQuery<ListUsersResponse, undefined>(
652637
{ ...optsAuthorizedFredVerifiedClaims, operationName: 'ListUsersNoAccess' }
653-
);
654-
expect(resp.data.users).to.not.be.empty;
655-
expect(resp.data.users.length).to.be.greaterThan(1);
656-
resp.data.users.forEach(user => {
657-
expect(expectedUserIds).to.include(user.id);
658-
});
638+
).should.eventually.be.rejected.and.has.property('code', 'data-connect/permission-denied');
659639
});
660640

661641
it("should use the impersonated user's auth.uid", async () => {

0 commit comments

Comments
 (0)