Skip to content
Open
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
13 changes: 10 additions & 3 deletions packages/oauth/src/state-stores/spec-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,18 @@ export class StateStoreChaiTestRunner {
it('should detect multiple consumption', async () => {
const { stateStore } = this;
const installUrlOptions = { scopes: ['channels:read'] };
for (let i = 0; i < 200; i++) {
for (let i = 0; i < 100; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is reducing the limit by 100 an arbitrary choice for testing or is there a reason behind it?

// generate other states
await stateStore.generateStateParam(installUrlOptions, new Date());
const date = new Date();
await stateStore.generateStateParam(installUrlOptions, date);
console.log('\tgenerateStateParam:', i, 100, date);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is this 100 the same as the loop above? If so, it may be good to put it into a variable and document why we chose 100 to avoid a future regression.

}
const state = await stateStore.generateStateParam(installUrlOptions, new Date());

// Wait 0.5 second to ensure I/O is complete and avoid flaky test results from rapid I/O
await new Promise((resolve, _) => setTimeout(resolve, 500));
console.log('\tsetTimeout: complete');

const result = await stateStore.verifyStateParam(new Date(), state);
assert.exists(result);
let expectedlyReturnedResult: InstallURLOptions = { scopes: [] };
Expand All @@ -68,7 +75,7 @@ export class StateStoreChaiTestRunner {
} catch (e: any) {
assert.equal(e.code, 'slack_oauth_invalid_state', `${state} ${JSON.stringify(expectedlyReturnedResult)}`);
}
}).timeout(4000); // https://github.com/slackapi/node-slack-sdk/issues/2159#issuecomment-2749367820
}).timeout(5000); // https://github.com/slackapi/node-slack-sdk/issues/2159#issuecomment-2749367820
}
});
}
Expand Down