-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
UI: allow retries for MFA form errors #27574
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
ui: Display an error and force a timeout when TOTP passcode is incorrect | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,9 +177,10 @@ module('Integration | Component | mfa-form', function (hooks) { | |
|
||
test('it should show countdown on passcode already used and rate limit errors', async function (assert) { | ||
const messages = { | ||
used: 'code already used; new code is available in 45 seconds', | ||
used: 'code already used; new code is available in 30 seconds', | ||
// note: the backend returns a duplicate "s" in "30s seconds" in the limit message below. we have intentionally left it as is to ensure our regex for parsing the delay time can handle it | ||
limit: | ||
'maximum TOTP validation attempts 4 exceeded the allowed attempts 3. Please try again in 15 seconds', | ||
'maximum TOTP validation attempts 4 exceeded the allowed attempts 3. Please try again in 30s seconds', | ||
}; | ||
const codes = ['used', 'limit']; | ||
for (const code of codes) { | ||
|
@@ -188,25 +189,46 @@ module('Integration | Component | mfa-form', function (hooks) { | |
throw { errors: [messages[code]] }; | ||
}, | ||
}); | ||
const expectedTime = code === 'used' ? 45 : 15; | ||
|
||
await render(hbs`<Mfa::MfaForm @clusterId={{this.clusterId}} @authData={{this.mfaAuthData}} />`); | ||
|
||
await fillIn('[data-test-mfa-passcode]', code); | ||
|
||
await fillIn('[data-test-mfa-passcode]', 'foo'); | ||
await click('[data-test-mfa-validate]'); | ||
|
||
await waitFor('[data-test-mfa-countdown]'); | ||
|
||
assert | ||
.dom('[data-test-mfa-countdown]') | ||
.includesText(expectedTime, 'countdown renders with correct initial value from error response'); | ||
.includesText('30', 'countdown renders with correct initial value from error response'); | ||
assert.dom('[data-test-mfa-validate]').isDisabled('Button is disabled during countdown'); | ||
assert.dom('[data-test-mfa-passcode]').isDisabled('Input is disabled during countdown'); | ||
assert.dom('[data-test-inline-error-message]').exists('Alert message renders'); | ||
} | ||
}); | ||
|
||
test('it defaults countdown to 30 seconds if error message does not indicate when user can try again ', async function (assert) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test coverage for the default timeout that i added |
||
this.owner.lookup('service:auth').reopen({ | ||
totpValidate() { | ||
throw { | ||
errors: ['maximum TOTP validation attempts 4 exceeded the allowed attempts 3. Beep-boop.'], | ||
}; | ||
}, | ||
}); | ||
await render(hbs`<Mfa::MfaForm @clusterId={{this.clusterId}} @authData={{this.mfaAuthData}} />`); | ||
|
||
await fillIn('[data-test-mfa-passcode]', 'foo'); | ||
await click('[data-test-mfa-validate]'); | ||
|
||
await waitFor('[data-test-mfa-countdown]'); | ||
|
||
assert | ||
.dom('[data-test-mfa-countdown]') | ||
.includesText('30', 'countdown renders with correct initial value from error response'); | ||
assert.dom('[data-test-mfa-validate]').isDisabled('Button is disabled during countdown'); | ||
assert.dom('[data-test-mfa-passcode]').isDisabled('Input is disabled during countdown'); | ||
assert.dom('[data-test-inline-error-message]').exists('Alert message renders'); | ||
}); | ||
|
||
test('it should show error message for passcode invalid error', async function (assert) { | ||
this.owner.lookup('service:auth').reopen({ | ||
totpValidate() { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea wrapping this in a conditional!