Skip to content
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

test: make login api tests fully independent #31786

Merged
merged 6 commits into from
Mar 28, 2024
Merged
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
50 changes: 26 additions & 24 deletions apps/meteor/tests/end-to-end/api/31-failed-login-attempts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,31 @@ describe('[Failed Login Attempts]', function () {

before((done) => getCredentials(done));

before(async () => {
await updateSetting('Block_Multiple_Failed_Logins_Enabled', true);
await updateSetting('Block_Multiple_Failed_Logins_By_Ip', true);
await updateSetting('Block_Multiple_Failed_Logins_By_User', true);
await updateSetting('Block_Multiple_Failed_Logins_Attempts_Until_Block_by_User', maxAttemptsByUser);
await updateSetting('Block_Multiple_Failed_Logins_Time_To_Unblock_By_User_In_Minutes', userBlockSeconds / 60);
await updateSetting('Block_Multiple_Failed_Logins_Attempts_Until_Block_By_Ip', maxAttemptsByIp);
await updateSetting('Block_Multiple_Failed_Logins_Time_To_Unblock_By_Ip_In_Minutes', ipBlockSeconds / 60);

await updatePermission('logout-other-user', ['admin']);
});

after(async () => {
await updateSetting('Block_Multiple_Failed_Logins_Attempts_Until_Block_by_User', 10);
await updateSetting('Block_Multiple_Failed_Logins_Time_To_Unblock_By_User_In_Minutes', 5);
await updateSetting('Block_Multiple_Failed_Logins_Attempts_Until_Block_By_Ip', 50);
await updateSetting('Block_Multiple_Failed_Logins_Time_To_Unblock_By_Ip_In_Minutes', 5);
await updateSetting('Block_Multiple_Failed_Logins_Enabled', false);
});
before(() =>
Promise.all([
updateSetting('Block_Multiple_Failed_Logins_Enabled', true),
updateSetting('Block_Multiple_Failed_Logins_By_Ip', true),
updateSetting('Block_Multiple_Failed_Logins_By_User', true),
updateSetting('Block_Multiple_Failed_Logins_Attempts_Until_Block_by_User', maxAttemptsByUser),
updateSetting('Block_Multiple_Failed_Logins_Time_To_Unblock_By_User_In_Minutes', userBlockSeconds / 60),
updateSetting('Block_Multiple_Failed_Logins_Attempts_Until_Block_By_Ip', maxAttemptsByIp),
updateSetting('Block_Multiple_Failed_Logins_Time_To_Unblock_By_Ip_In_Minutes', ipBlockSeconds / 60),
updatePermission('logout-other-user', ['admin']),
]),
);

after(() =>
Promise.all([
updateSetting('Block_Multiple_Failed_Logins_Attempts_Until_Block_by_User', 10),
updateSetting('Block_Multiple_Failed_Logins_Time_To_Unblock_By_User_In_Minutes', 5),
updateSetting('Block_Multiple_Failed_Logins_Attempts_Until_Block_By_Ip', 50),
updateSetting('Block_Multiple_Failed_Logins_Time_To_Unblock_By_Ip_In_Minutes', 5),
updateSetting('Block_Multiple_Failed_Logins_Enabled', true),
updateSetting('Block_Multiple_Failed_Logins_By_Ip', true),
updateSetting('Block_Multiple_Failed_Logins_By_User', true),
updatePermission('logout-other-user', ['admin']),
]),
);

async function shouldFailLoginWithUser(username: string, password: string) {
await request
Expand Down Expand Up @@ -163,11 +169,7 @@ describe('[Failed Login Attempts]', function () {
userLogin = await createUser();
});

afterEach(async () => {
await deleteUser(user);
await deleteUser(user2);
await deleteUser(userLogin);
});
afterEach(() => Promise.all([deleteUser(user), deleteUser(user2), deleteUser(userLogin)]));

afterEach(async () => {
// reset counter
Expand Down
Loading