diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 203ba153b..d1b63086e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -80,11 +80,6 @@ updates: slack: patterns: - "@slack/*" - dev-sinon: - dependency-type: "development" - patterns: - - "@types/sinon" - - "sinon" dev-chai: dependency-type: "development" patterns: diff --git a/package-lock.json b/package-lock.json index f199b1663..f5f19564a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5358,9 +5358,7 @@ "jsonwebtoken": "^9" }, "devDependencies": { - "@types/sinon": "^22.0.2", - "rewiremock": "^3", - "sinon": "^22.1.0" + "rewiremock": "^3" }, "engines": { "node": ">=20", diff --git a/packages/oauth/package.json b/packages/oauth/package.json index 50c22fea1..4d99a2b76 100644 --- a/packages/oauth/package.json +++ b/packages/oauth/package.json @@ -47,8 +47,6 @@ "jsonwebtoken": "^9" }, "devDependencies": { - "@types/sinon": "^22.0.2", - "rewiremock": "^3", - "sinon": "^22.1.0" + "rewiremock": "^3" } } diff --git a/packages/oauth/src/callback-options.test.ts b/packages/oauth/src/callback-options.test.ts index 6cedc4928..51f8a3926 100644 --- a/packages/oauth/src/callback-options.test.ts +++ b/packages/oauth/src/callback-options.test.ts @@ -1,7 +1,7 @@ import assert from 'node:assert/strict'; import { IncomingMessage, ServerResponse } from 'node:http'; +import { Socket } from 'node:net'; import { describe, it } from 'node:test'; -import sinon from 'sinon'; import { type CallbackOptions, escapeHtml } from './callback-options'; import { MissingStateError } from './errors'; @@ -43,8 +43,8 @@ describe('CallbackOptions', async () => { const options = { scopes: ['commands', 'chat:write'], }; - const req = sinon.createStubInstance(IncomingMessage) as IncomingMessage; - const resp = sinon.createStubInstance(ServerResponse) as ServerResponse; + const req = new IncomingMessage(new Socket()); + const resp = new ServerResponse(req); callbackOptions.success?.(installation, options, req, resp); const error = new MissingStateError(); diff --git a/packages/oauth/src/install-path-options.test.ts b/packages/oauth/src/install-path-options.test.ts index aca6c993c..805a447d3 100644 --- a/packages/oauth/src/install-path-options.test.ts +++ b/packages/oauth/src/install-path-options.test.ts @@ -1,7 +1,7 @@ import assert from 'node:assert/strict'; import { IncomingMessage, ServerResponse } from 'node:http'; +import { Socket } from 'node:net'; import { describe, it } from 'node:test'; -import sinon from 'sinon'; import type { InstallPathOptions } from './install-path-options'; @@ -16,8 +16,8 @@ describe('InstallPathOptions', async () => { }, }; assert.ok(installPathOptions); - const req = sinon.createStubInstance(IncomingMessage) as IncomingMessage; - const resp = sinon.createStubInstance(ServerResponse) as ServerResponse; + const req = new IncomingMessage(new Socket()); + const resp = new ServerResponse(req); const options = { scopes: ['commands', 'chat:write'] }; const result = await installPathOptions.beforeRedirection?.(req, resp, options); assert.strictEqual(result, false); diff --git a/packages/oauth/src/install-provider.test.ts b/packages/oauth/src/install-provider.test.ts index 90bc6fab6..1077af17e 100644 --- a/packages/oauth/src/install-provider.test.ts +++ b/packages/oauth/src/install-provider.test.ts @@ -1,9 +1,8 @@ import assert from 'node:assert/strict'; -import { beforeEach, describe, it } from 'node:test'; +import { beforeEach, describe, it, mock } from 'node:test'; import url from 'node:url'; import type { OAuthV2AccessArguments, OauthV2AccessResponse, WebClientOptions } from '@slack/web-api'; import rewiremock from 'rewiremock'; -import sinon from 'sinon'; import { type AuthorizationError, ErrorCode, @@ -20,10 +19,10 @@ rewiremock(() => require('@slack/web-api')).with({ // @ts-expect-error: missing some irrelevant class properties in this mock WebClient: class { auth = { - test: sinon.fake.resolves({ bot_id: '' }), + test: async () => ({ bot_id: '' }), }; oauth = { - access: sinon.fake.resolves({ + access: async () => ({ team_id: 'fake-v1-team-id', team_name: 'fake-team-name', access_token: 'token', @@ -51,6 +50,13 @@ rewiremock.disable(); const webClientOptions: WebClientOptions = { timeout: 1000 }; +function createFakeStateStore() { + return { + generateStateParam: mock.fn(async () => 'fakeState'), + verifyStateParam: mock.fn(async () => ({ scopes: [] })), + }; +} + async function mockedV2AccessResp(options: OAuthV2AccessArguments): Promise { const mockedResp: OauthV2AccessResponse = { ok: true, @@ -225,10 +231,7 @@ describe('InstallProvider', async () => { it('should build a default installer given a clientID, client secret and state store', async () => { // stateStore for testing - const fakeStateStore = { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({}), - }; + const fakeStateStore = createFakeStateStore(); const installer = new InstallProvider({ clientId, clientSecret, stateStore: fakeStateStore, logger: noopLogger }); assert.ok(installer instanceof InstallProvider); @@ -313,10 +316,7 @@ describe('InstallProvider', async () => { clientId, clientSecret, installUrlOptions: undefined, - stateStore: { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({ scopes: [] }), - }, + stateStore: createFakeStateStore(), logger: noopLogger, }); const req = {}; @@ -355,10 +355,7 @@ describe('InstallProvider', async () => { clientSecret, installUrlOptions, directInstall: true, - stateStore: { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({ scopes: [] }), - }, + stateStore: createFakeStateStore(), logger: noopLogger, }); const req = {}; @@ -391,10 +388,7 @@ describe('InstallProvider', async () => { clientSecret, installUrlOptions, directInstall: true, - stateStore: { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({ scopes: [] }), - }, + stateStore: createFakeStateStore(), logger: noopLogger, }); const req = {}; @@ -432,10 +426,7 @@ describe('InstallProvider', async () => { describe('installer.generateInstallUrl', async () => { it('should return a generated v2 url', async () => { - const fakeStateStore = { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({}), - }; + const fakeStateStore = createFakeStateStore(); const installer = new InstallProvider({ clientId, clientSecret, stateStore: fakeStateStore, logger: noopLogger }); const scopes = ['channels:read']; const teamId = '1234Team'; @@ -452,9 +443,9 @@ describe('InstallProvider', async () => { try { const generatedUrl = await installer.generateInstallUrl(installUrlOptions, stateVerification); assert.ok(generatedUrl); - assert.strictEqual(fakeStateStore.generateStateParam.callCount, 1); - assert.strictEqual(fakeStateStore.verifyStateParam.callCount, 0); - assert.strictEqual(fakeStateStore.generateStateParam.calledWith(installUrlOptions), true); + assert.strictEqual(fakeStateStore.generateStateParam.mock.callCount(), 1); + assert.strictEqual(fakeStateStore.verifyStateParam.mock.callCount(), 0); + assert.deepEqual(fakeStateStore.generateStateParam.mock.calls[0].arguments[0], installUrlOptions); const parsedUrl = url.parse(generatedUrl, true); assert.strictEqual(parsedUrl.query.state, 'fakeState'); @@ -468,10 +459,7 @@ describe('InstallProvider', async () => { } }); it('should not call generate state param when state validation is false', async () => { - const fakeStateStore = { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({}), - }; + const fakeStateStore = createFakeStateStore(); const authorizationUrl = 'https://dev.slack.com/oauth/v2/authorize'; const installer = new InstallProvider({ clientId, @@ -495,17 +483,14 @@ describe('InstallProvider', async () => { try { const generatedUrl = await installer.generateInstallUrl(installUrlOptions, stateVerification); assert.ok(generatedUrl); - assert.strictEqual(fakeStateStore.generateStateParam.callCount, 0); - assert.strictEqual(fakeStateStore.verifyStateParam.callCount, 0); + assert.strictEqual(fakeStateStore.generateStateParam.mock.callCount(), 0); + assert.strictEqual(fakeStateStore.verifyStateParam.mock.callCount(), 0); } catch (error) { assert.fail((error as Error).message); } }); it('should return a generated url when passed a custom authorizationUrl', async () => { - const fakeStateStore = { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({}), - }; + const fakeStateStore = createFakeStateStore(); const authorizationUrl = 'https://dev.slack.com/oauth/v2/authorize'; const installer = new InstallProvider({ clientId, @@ -528,9 +513,9 @@ describe('InstallProvider', async () => { try { const generatedUrl = await installer.generateInstallUrl(installUrlOptions); assert.ok(generatedUrl); - assert.strictEqual(fakeStateStore.generateStateParam.callCount, 1); - assert.strictEqual(fakeStateStore.verifyStateParam.callCount, 0); - assert.strictEqual(fakeStateStore.generateStateParam.calledWith(installUrlOptions), true); + assert.strictEqual(fakeStateStore.generateStateParam.mock.callCount(), 1); + assert.strictEqual(fakeStateStore.verifyStateParam.mock.callCount(), 0); + assert.deepEqual(fakeStateStore.generateStateParam.mock.calls[0].arguments[0], installUrlOptions); const parsedUrl = url.parse(generatedUrl, true); assert.strictEqual(parsedUrl.query.state, 'fakeState'); @@ -546,10 +531,7 @@ describe('InstallProvider', async () => { }); it('should return a generated v1 url', async () => { - const fakeStateStore = { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({}), - }; + const fakeStateStore = createFakeStateStore(); const installer = new InstallProvider({ clientId, clientSecret, @@ -571,9 +553,9 @@ describe('InstallProvider', async () => { const generatedUrl = await installer.generateInstallUrl(installUrlOptions, stateVerification); assert.ok(generatedUrl); const parsedUrl = url.parse(generatedUrl, true); - assert.strictEqual(fakeStateStore.generateStateParam.callCount, 1); - assert.strictEqual(fakeStateStore.verifyStateParam.callCount, 0); - assert.strictEqual(fakeStateStore.generateStateParam.calledWith(installUrlOptions), true); + assert.strictEqual(fakeStateStore.generateStateParam.mock.callCount(), 1); + assert.strictEqual(fakeStateStore.verifyStateParam.mock.callCount(), 0); + assert.deepEqual(fakeStateStore.generateStateParam.mock.calls[0].arguments[0], installUrlOptions); assert.strictEqual(parsedUrl.pathname, '/oauth/authorize'); assert.strictEqual(parsedUrl.query.state, 'fakeState'); assert.strictEqual(scopes.join(','), parsedUrl.query.scope); @@ -655,7 +637,7 @@ describe('InstallProvider', async () => { }); describe('installer.handleCallback', async () => { - let fakeStateStore: StateStore; + let fakeStateStore: ReturnType; let sent = false; const res = { end: () => { @@ -664,10 +646,7 @@ describe('InstallProvider', async () => { setHeader: () => {}, }; beforeEach(() => { - fakeStateStore = { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({ scopes: [] }), - }; + fakeStateStore = createFakeStateStore(); sent = false; }); @@ -791,7 +770,7 @@ describe('InstallProvider', async () => { // @ts-expect-error req is not an instance of IncomingMessage, TODO: type or stub IncomingMessage for req properly await installer.handleCallback(req, res, successExpectedCallbackOptions); assert.strictEqual(sent, true); - assert.strictEqual((fakeStateStore.verifyStateParam as sinon.SinonSpy).callCount, 1); + assert.strictEqual(fakeStateStore.verifyStateParam.mock.callCount(), 1); }); it('should call the success callback for a v2 url', async () => { @@ -815,7 +794,7 @@ describe('InstallProvider', async () => { // @ts-expect-error req is not an instance of IncomingMessage, TODO: type or stub IncomingMessage for req properly await installer.handleCallback(req, res, successExpectedCallbackOptions); assert.strictEqual(sent, true); - assert.strictEqual((fakeStateStore.verifyStateParam as sinon.SinonSpy).callCount, 1); + assert.strictEqual(fakeStateStore.verifyStateParam.mock.callCount(), 1); }); it('should call the success callback for a v1 url', async () => { @@ -840,7 +819,7 @@ describe('InstallProvider', async () => { // @ts-expect-error req is not an instance of IncomingMessage, TODO: type or stub IncomingMessage for req properly await installer.handleCallback(req, res, successExpectedCallbackOptions); assert.strictEqual(sent, true); - assert.strictEqual((fakeStateStore.verifyStateParam as sinon.SinonSpy).callCount, 1); + assert.strictEqual(fakeStateStore.verifyStateParam.mock.callCount(), 1); }); it('should call the success callback for a v1 url', async () => { @@ -866,14 +845,11 @@ describe('InstallProvider', async () => { // @ts-expect-error req is not an instance of IncomingMessage, TODO: type or stub IncomingMessage for req properly await installer.handleCallback(req, res, successExpectedCallbackOptions); assert.strictEqual(sent, true); - assert.strictEqual((fakeStateStore.verifyStateParam as sinon.SinonSpy).callCount, 1); + assert.strictEqual(fakeStateStore.verifyStateParam.mock.callCount(), 1); }); it('should not verify state when stateVerification is false', async () => { - const fakeStateStore = { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({}), - }; + const fakeStateStore = createFakeStateStore(); const installer = new InstallProvider({ clientId, clientSecret, @@ -895,7 +871,7 @@ describe('InstallProvider', async () => { // @ts-expect-error req is not an instance of IncomingMessage, TODO: type or stub IncomingMessage for req properly await installer.handleCallback(req, res, successExpectedCallbackOptions); assert.strictEqual(sent, true); - assert.strictEqual(fakeStateStore.verifyStateParam.callCount, 0); + assert.strictEqual(fakeStateStore.verifyStateParam.mock.callCount(), 0); }); it('should terminate the processing when callbackOptions.beforeInstallation() returns false', async () => { @@ -1079,10 +1055,7 @@ describe('InstallProvider', async () => { }); it('should fail if the state value is not in cookies', async () => { - const fakeStateStore: StateStore = { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({ scopes: [] }), - }; + const fakeStateStore = createFakeStateStore(); const installer = new InstallProvider({ clientId, clientSecret, @@ -1107,10 +1080,7 @@ describe('InstallProvider', async () => { assert.strictEqual(sent, true); }); it('should fail if there is a different state value in cookies', async () => { - const fakeStateStore: StateStore = { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({ scopes: [] }), - }; + const fakeStateStore = createFakeStateStore(); const installer = new InstallProvider({ clientId, clientSecret, @@ -1135,10 +1105,7 @@ describe('InstallProvider', async () => { assert.strictEqual(sent, true); }); it('should not fail if no state cookie returned and legacyStateVerification is enabled', async () => { - const fakeStateStore = { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({}), - }; + const fakeStateStore = createFakeStateStore(); const installer = new InstallProvider({ clientId, clientSecret, @@ -1163,10 +1130,7 @@ describe('InstallProvider', async () => { assert.strictEqual(sent, true); }); it('should not fail if a different state cookie returned and legacyStateVerification is enabled', async () => { - const fakeStateStore: StateStore = { - generateStateParam: sinon.fake.resolves('fakeState'), - verifyStateParam: sinon.fake.resolves({ scopes: [] }), - }; + const fakeStateStore = createFakeStateStore(); const installer = new InstallProvider({ clientId, clientSecret, diff --git a/packages/oauth/src/installation-stores/file-store.test.ts b/packages/oauth/src/installation-stores/file-store.test.ts index 3e3d584ed..1dcec2d27 100644 --- a/packages/oauth/src/installation-stores/file-store.test.ts +++ b/packages/oauth/src/installation-stores/file-store.test.ts @@ -2,8 +2,7 @@ import assert from 'node:assert/strict'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { afterEach, beforeEach, describe, it } from 'node:test'; -import sinon from 'sinon'; +import { afterEach, beforeEach, describe, it, type Mock, mock } from 'node:test'; import type { InstallationQuery } from '../index'; import { InstallProvider } from '../index'; @@ -71,47 +70,46 @@ const _storedOrgInstallation = { isEnterpriseInstall: true, }; +type MockFunction = Mock<(...args: never[]) => unknown>; + +function callsTo(fn: MockFunction): unknown[][] { + return fn.mock.calls.map((call) => call.arguments); +} + describe('FileInstallationStore', async () => { - let fsMakeDirSync: sinon.SinonStub; - let fsWriteFileSync: sinon.SinonStub; - let fsReadFileSync: sinon.SinonStub; - let fsUnlinkSync: sinon.SinonStub; - let fsReaddirSync: sinon.SinonStub; + let fsWriteFileSync: MockFunction; + let fsReadFileSync: MockFunction; + let fsUnlinkSync: MockFunction; + let fsReaddirSync: MockFunction; beforeEach(() => { - // Note that these sinon stubs affect the `os` package behaviors - // in the tests in this file - fsMakeDirSync = sinon.stub(fs, 'mkdirSync').returns(undefined); - fsWriteFileSync = sinon.stub(fs, 'writeFileSync').returns(undefined); - fsReadFileSync = sinon.stub(fs, 'readFileSync').returns(Buffer.from(JSON.stringify(storedInstallation))); - fsUnlinkSync = sinon.stub(fs, 'unlinkSync').returns(undefined); - fsReaddirSync = sinon.stub(fs, 'readdirSync').returns(['app-latest', 'user-userId-latest']); + mock.method(fs, 'mkdirSync', () => undefined); + fsWriteFileSync = mock.method(fs, 'writeFileSync', () => {}); + fsReadFileSync = mock.method(fs, 'readFileSync', () => Buffer.from(JSON.stringify(storedInstallation))); + fsUnlinkSync = mock.method(fs, 'unlinkSync', () => {}); + fsReaddirSync = mock.method(fs, 'readdirSync', () => ['app-latest', 'user-userId-latest']); }); afterEach(() => { - fsMakeDirSync.restore(); - fsWriteFileSync.restore(); - fsReadFileSync.restore(); - fsUnlinkSync.restore(); - fsReaddirSync.restore(); + mock.restoreAll(); }); - it('should store the latest installation', async () => { - const installationStore = new FileInstallationStore({ baseDir: os.tmpdir() }); + it('should store only the latest installation with historicalDataEnabled off', async () => { + const installationStore = new FileInstallationStore({ baseDir: os.tmpdir(), historicalDataEnabled: false }); const { enterprise, team, user } = storedInstallation; const fakeInstallDir = path.join(os.tmpdir(), `${enterprise.id}-${team.id}`); const installationJSON = JSON.stringify(storedInstallation); await installationStore.storeInstallation(storedInstallation); - assert.strictEqual(fsWriteFileSync.calledWith(path.join(fakeInstallDir, 'app-latest'), installationJSON), true); - assert.strictEqual( - fsWriteFileSync.calledWith(sinon.match(path.join(fakeInstallDir, `user-${user.id}-latest`)), installationJSON), - true, - ); + assert.deepEqual(callsTo(fsWriteFileSync), [ + [path.join(fakeInstallDir, 'app-latest'), installationJSON], + [path.join(fakeInstallDir, `user-${user.id}-latest`), installationJSON], + ]); }); it('should throw an exception with sufficient information when failing to store data', async () => { - fsWriteFileSync.restore(); // disable sinon stub for this test case - fsWriteFileSync = sinon.stub(fs, 'writeFileSync').throws(new Error('The original error message')); + fsWriteFileSync.mock.mockImplementation(() => { + throw new Error('The original error message'); + }); const installationStore = new FileInstallationStore({ baseDir: os.tmpdir(), clientId: '11111.22222', @@ -136,17 +134,14 @@ describe('FileInstallationStore', async () => { await installationStore.storeInstallation(storedInstallation); - assert.strictEqual( - fsWriteFileSync.calledWith(sinon.match(`${fakeInstallDir}${path.sep}app-`), installationJSON), - true, - ); - assert.strictEqual( - fsWriteFileSync.calledWith(sinon.match(`${fakeInstallDir}${path.sep}user-${user.id}-`), installationJSON), - true, - ); - - // 1 store = 4 files = 2 latest + 2 timestamps - assert.strictEqual(fsWriteFileSync.callCount, 4); + const [appLatest, userLatest, appHistorical, userHistorical] = callsTo(fsWriteFileSync); + assert.deepEqual(appLatest, [path.join(fakeInstallDir, 'app-latest'), installationJSON]); + assert.deepEqual(userLatest, [path.join(fakeInstallDir, `user-${user.id}-latest`), installationJSON]); + assert.ok(String(appHistorical[0]).startsWith(path.join(fakeInstallDir, 'app-'))); + assert.ok(String(userHistorical[0]).startsWith(path.join(fakeInstallDir, `user-${user.id}-`))); + assert.equal(appHistorical[1], installationJSON); + assert.equal(userHistorical[1], installationJSON); + assert.equal(fsWriteFileSync.mock.callCount(), 4); }); it('should fetch a stored installation', async () => { @@ -158,11 +153,11 @@ describe('FileInstallationStore', async () => { await installationStore.storeInstallation(storedInstallation); const installation = await installationStore.fetchInstallation(query); - assert.strictEqual(fsReadFileSync.calledWith(sinon.match(path.join(fakeInstallDir, 'app-latest'))), true); + assert.deepEqual(callsTo(fsReadFileSync), [[path.join(fakeInstallDir, 'app-latest')]]); assert.deepStrictEqual(installation, storedInstallation); }); it('should throw an exception with sufficient information when failing to fetch data', async () => { - fsReadFileSync.restore(); // disable sinon stub for this test case + fsReadFileSync.mock.restore(); const installationStore = new FileInstallationStore({ baseDir: os.tmpdir(), clientId: '111.222', @@ -190,12 +185,11 @@ describe('FileInstallationStore', async () => { await installationStore.deleteInstallation(query); - assert.strictEqual(fsReaddirSync.calledWith(sinon.match(fakeInstallDir)), true); - assert.strictEqual(fsUnlinkSync.calledWith(sinon.match('app-latest')), true); - assert.strictEqual(fsUnlinkSync.calledWith(sinon.match('user-userId-latest')), true); - - // fsReaddirSync returns ['app-latest', 'user-userId-latest'] - assert.strictEqual(fsUnlinkSync.callCount, 2); + assert.deepEqual(callsTo(fsReaddirSync), [[fakeInstallDir]]); + assert.deepEqual(callsTo(fsUnlinkSync), [ + [path.resolve(fakeInstallDir, 'app-latest')], + [path.resolve(fakeInstallDir, 'user-userId-latest')], + ]); }); it('should delete only user records of installation if userId is passed', async () => { @@ -206,11 +200,8 @@ describe('FileInstallationStore', async () => { await installationStore.deleteInstallation(query); - assert.strictEqual(fsReaddirSync.calledWith(sinon.match(fakeInstallDir)), true); - assert.strictEqual(fsUnlinkSync.calledWith(sinon.match(`user-${user.id}-latest`)), true); - - // fsReaddirSync returns ['app-latest', 'user-userId-latest'] - assert.strictEqual(fsUnlinkSync.callCount, 1); + assert.deepEqual(callsTo(fsReaddirSync), [[fakeInstallDir]]); + assert.deepEqual(callsTo(fsUnlinkSync), [[path.resolve(fakeInstallDir, `user-${user.id}-latest`)]]); }); it("should run authorize with triage-bot's MongoDB data", async () => {