fix(editor): ask only the top refusing layer, safe retry notes
This commit is contained in:
1 parent
f8be0ad01a
commit
ee86a3a659
5 files changed
+92
-15
No files matched your search
@@ -57,6 +57,18 @@ export async function passwordToken(account: SandboxAccount): Promise<string> {
|
||||
return body.access_token
|
||||
}
|
||||
|
||||
/**
|
||||
* Records a retry on the running test; outside a test (the global setup) it goes to the
|
||||
* console, where `test.info()` would throw.
|
||||
*/
|
||||
function noteRetry(type: string, description: string): void {
|
||||
try {
|
||||
test.info().annotations.push({ type, description })
|
||||
} catch {
|
||||
console.log(`${type}: ${description}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A verified TOTP factor enrolled by the account itself through the GoTrue
|
||||
* API (as its authenticator app would be set up); resolves with its secret.
|
||||
@@ -70,8 +82,10 @@ export async function enrolVerifiedFactor(
|
||||
if (!enrolment.factor) throw new Error(`sandbox enrol: ${refusal(enrolment)}`)
|
||||
let verified = await verifyTotp(token, enrolment.factor)
|
||||
// The HTTP 500 of the sweep (see `STEP_UP_ATTEMPTS`) is tried once more.
|
||||
if (verified.status >= 500)
|
||||
if (verified.status >= 500) {
|
||||
noteRetry('verify retried', `HTTP ${verified.status} from GoTrue verify`)
|
||||
verified = await verifyTotp(token, enrolment.factor)
|
||||
}
|
||||
if (verified.status !== 200)
|
||||
throw new Error(`sandbox verify: ${refusal(verified)}`)
|
||||
return enrolment.factor.secret
|
||||
@@ -151,10 +165,10 @@ export async function stepUpAdmin(page: Page, dict: Dict, secret: string) {
|
||||
for (let attempt = 1; ; attempt += 1) {
|
||||
const unavailable = await sendStepUpCode(page, dict, secret)
|
||||
if (!unavailable || attempt === STEP_UP_ATTEMPTS) break
|
||||
test.info().annotations.push({
|
||||
type: 'step-up retried',
|
||||
description: `attempt ${attempt}: GoTrue verify failed on the server`,
|
||||
})
|
||||
noteRetry(
|
||||
'step-up retried',
|
||||
`attempt ${attempt}: GoTrue verify failed on the server`,
|
||||
)
|
||||
await page.reload()
|
||||
}
|
||||
await expect(stepUpHeading(page, dict)).toBeHidden()
|
||||
|
||||
Reference in new issue
Block a user