From 3baa96c37bc7c2c7258a774769f84099cbc2f460 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Sun, 22 Sep 2024 21:34:40 +0200 Subject: [PATCH] test: accelerate end2end device flow tests --- tap/end2end-device-code.ts | 4 ++-- tap/server.mjs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tap/end2end-device-code.ts b/tap/end2end-device-code.ts index 4828df00..81831d7e 100644 --- a/tap/end2end-device-code.ts +++ b/tap/end2end-device-code.ts @@ -40,7 +40,7 @@ export default (QUnit: QUnit) => { }) let result = await lib.processDeviceAuthorizationResponse(as, client, response) - const { verification_uri_complete, device_code } = result + const { verification_uri_complete, device_code, interval = 5 } = result await fetch('http://localhost:3000/drive', { method: 'POST', @@ -63,7 +63,7 @@ export default (QUnit: QUnit) => { try { result = await processDeviceCodeResponse() } catch { - await new Promise((resolve) => setTimeout(resolve, 100)) + await new Promise((resolve) => setTimeout(resolve, interval * 1000)) response = await deviceCodeGrantRequest() } } diff --git a/tap/server.mjs b/tap/server.mjs index e4e979b6..7b07505c 100644 --- a/tap/server.mjs +++ b/tap/server.mjs @@ -170,6 +170,9 @@ provider.use(async (ctx, next) => { if (typeof ctx.body === 'string' && ctx.body.includes('Continue')) { ctx.body = ctx.body.replace('Sign-in', 'Consent') } + if (ctx.body?.verification_uri_complete) { + ctx.body.interval = 0.1 + } } })