fix: preserve oauth step metadata and resolve dev merge conflicts
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
|
||||
function loadIpProxyCore({ accountListEnabled = true } = {}) {
|
||||
const providerSource = fs.readFileSync('background/ip-proxy-provider-711proxy.js', 'utf8');
|
||||
const coreSource = fs.readFileSync('background/ip-proxy-core.js', 'utf8');
|
||||
return new Function(`
|
||||
const self = {};
|
||||
const chrome = {};
|
||||
const DEFAULT_IP_PROXY_SERVICE = '711proxy';
|
||||
const IP_PROXY_SERVICE_VALUES = ['711proxy', 'lumiproxy', 'iproyal', 'omegaproxy'];
|
||||
const IP_PROXY_ENABLED_SERVICE_VALUES = ['711proxy'];
|
||||
const DEFAULT_IP_PROXY_MODE = 'account';
|
||||
const IP_PROXY_MODE_VALUES = ['api', 'account'];
|
||||
const DEFAULT_IP_PROXY_PROTOCOL = 'http';
|
||||
const IP_PROXY_PROTOCOL_VALUES = ['http', 'https', 'socks4', 'socks5'];
|
||||
const IP_PROXY_FETCH_TIMEOUT_MS = 20000;
|
||||
const IP_PROXY_SETTINGS_SCOPE = 'regular';
|
||||
const IP_PROXY_BYPASS_LIST = ['<local>', 'localhost', '127.0.0.1'];
|
||||
const IP_PROXY_ROUTE_ALL_TRAFFIC = true;
|
||||
const IP_PROXY_ACCOUNT_LIST_ENABLED = ${accountListEnabled ? 'true' : 'false'};
|
||||
const IP_PROXY_TARGET_HOST_PATTERNS = [
|
||||
'openai.com',
|
||||
'*.openai.com',
|
||||
'chatgpt.com',
|
||||
'*.chatgpt.com',
|
||||
];
|
||||
${providerSource}
|
||||
const transformIpProxyAccountEntryByProvider = self.transformIpProxyAccountEntryByProvider;
|
||||
${coreSource}
|
||||
return {
|
||||
buildIpProxyPacScript,
|
||||
getAccountModeProxyPoolFromState,
|
||||
normalizeIpProxyAccountList,
|
||||
normalizeProxyPoolEntries,
|
||||
parseIpProxyLine,
|
||||
resolveIpProxyAutoSwitchThreshold,
|
||||
};
|
||||
`)();
|
||||
}
|
||||
|
||||
test('IP proxy parser ignores disabled lines and normalizes proxy entries', () => {
|
||||
const api = loadIpProxyCore();
|
||||
|
||||
assert.equal(
|
||||
api.normalizeIpProxyAccountList([
|
||||
'# disabled',
|
||||
' // disabled',
|
||||
'; disabled',
|
||||
'global.rotgb.711proxy.com:10000:user:pass',
|
||||
'',
|
||||
].join('\n')),
|
||||
'global.rotgb.711proxy.com:10000:user:pass'
|
||||
);
|
||||
|
||||
const pool = api.normalizeProxyPoolEntries([
|
||||
'http://global.rotgb.711proxy.com:10000:user:pa:ss',
|
||||
'http://global.rotgb.711proxy.com:10000:user:pa:ss',
|
||||
{ host: 'us.proxy.example', port: '8080', username: 'u2', password: 'p2' },
|
||||
]);
|
||||
|
||||
assert.equal(pool.length, 2);
|
||||
assert.deepStrictEqual(pool[0], {
|
||||
host: 'global.rotgb.711proxy.com',
|
||||
port: 10000,
|
||||
username: 'user',
|
||||
password: 'pa:ss',
|
||||
protocol: 'http',
|
||||
region: '',
|
||||
provider: '711proxy',
|
||||
});
|
||||
assert.equal(pool[1].host, 'us.proxy.example');
|
||||
assert.equal(pool[1].port, 8080);
|
||||
});
|
||||
|
||||
test('711 fixed-account mode applies region and sticky session parameters', () => {
|
||||
const api = loadIpProxyCore();
|
||||
const pool = api.getAccountModeProxyPoolFromState({
|
||||
ipProxyService: '711proxy',
|
||||
ipProxyMode: 'account',
|
||||
ipProxyHost: 'global.rotgb.711proxy.com',
|
||||
ipProxyPort: '10000',
|
||||
ipProxyProtocol: 'http',
|
||||
ipProxyUsername: 'USER047152-zone-custom',
|
||||
ipProxyPassword: 'secret',
|
||||
ipProxyRegion: 'US',
|
||||
ipProxyAccountSessionPrefix: 'sticky_001',
|
||||
ipProxyAccountLifeMinutes: '30',
|
||||
});
|
||||
|
||||
assert.equal(pool.length, 1);
|
||||
assert.equal(pool[0].host, 'global.rotgb.711proxy.com');
|
||||
assert.equal(pool[0].port, 10000);
|
||||
assert.equal(pool[0].region, 'US');
|
||||
assert.match(pool[0].username, /region-US/);
|
||||
assert.match(pool[0].username, /session-sticky_001/);
|
||||
assert.match(pool[0].username, /sessTime-30/);
|
||||
});
|
||||
|
||||
test('IP proxy PAC keeps local traffic direct and routes target traffic through proxy', () => {
|
||||
const api = loadIpProxyCore();
|
||||
const pac = api.buildIpProxyPacScript({
|
||||
host: 'global.rotgb.711proxy.com',
|
||||
port: 10000,
|
||||
protocol: 'http',
|
||||
});
|
||||
|
||||
assert.match(pac, /FindProxyForURL/);
|
||||
assert.match(pac, /localhost/);
|
||||
assert.match(pac, /PROXY global\.rotgb\.711proxy\.com:10000/);
|
||||
assert.match(pac, /chatgpt\.com/);
|
||||
assert.match(pac, /openai\.com/);
|
||||
});
|
||||
|
||||
test('sidepanel loads IP proxy scripts before sidepanel bootstrap', () => {
|
||||
const html = fs.readFileSync('sidepanel/sidepanel.html', 'utf8');
|
||||
const providerIndex = html.indexOf('<script src="ip-proxy-provider-711proxy.js"></script>');
|
||||
const panelIndex = html.indexOf('<script src="ip-proxy-panel.js"></script>');
|
||||
const sidepanelIndex = html.indexOf('<script src="sidepanel.js"></script>');
|
||||
|
||||
assert.notEqual(providerIndex, -1);
|
||||
assert.notEqual(panelIndex, -1);
|
||||
assert.notEqual(sidepanelIndex, -1);
|
||||
assert.ok(providerIndex < panelIndex);
|
||||
assert.ok(panelIndex < sidepanelIndex);
|
||||
});
|
||||
|
||||
test('IP proxy auto-switch threshold is clamped to the supported range', () => {
|
||||
const api = loadIpProxyCore();
|
||||
|
||||
assert.equal(api.resolveIpProxyAutoSwitchThreshold({ ipProxyPoolTargetCount: '0' }), 1);
|
||||
assert.equal(api.resolveIpProxyAutoSwitchThreshold({ ipProxyPoolTargetCount: '25' }), 25);
|
||||
assert.equal(api.resolveIpProxyAutoSwitchThreshold({ ipProxyPoolTargetCount: '9999' }), 500);
|
||||
});
|
||||
@@ -159,6 +159,236 @@ test('Plus login-code step reuses step 8 verification logic but completes visibl
|
||||
assert.deepStrictEqual(remainingStepCalls, [11, 11]);
|
||||
});
|
||||
|
||||
test('step 8 completes directly when auth page is already on OAuth consent page', async () => {
|
||||
const events = {
|
||||
resolveCalls: 0,
|
||||
completeCalls: [],
|
||||
setStates: [],
|
||||
rerunStep7: 0,
|
||||
};
|
||||
|
||||
const executor = api.createStep8Executor({
|
||||
addLog: async () => {},
|
||||
chrome: {
|
||||
tabs: {
|
||||
update: async () => {},
|
||||
},
|
||||
},
|
||||
CLOUDFLARE_TEMP_EMAIL_PROVIDER: 'cloudflare-temp-email',
|
||||
completeStepFromBackground: async (step, payload) => {
|
||||
events.completeCalls.push({ step, payload });
|
||||
},
|
||||
confirmCustomVerificationStepBypass: async () => {},
|
||||
ensureStep8VerificationPageReady: async () => ({
|
||||
state: 'oauth_consent_page',
|
||||
}),
|
||||
rerunStep7ForStep8Recovery: async () => {
|
||||
events.rerunStep7 += 1;
|
||||
},
|
||||
getOAuthFlowRemainingMs: async () => 9000,
|
||||
getOAuthFlowStepTimeoutMs: async (defaultTimeoutMs) => Math.min(defaultTimeoutMs, 9000),
|
||||
getMailConfig: () => ({
|
||||
provider: 'qq',
|
||||
label: 'QQ 邮箱',
|
||||
source: 'mail-qq',
|
||||
url: 'https://mail.qq.com',
|
||||
navigateOnReuse: false,
|
||||
}),
|
||||
getState: async () => ({ email: 'user@example.com', password: 'secret' }),
|
||||
getTabId: async (sourceName) => (sourceName === 'signup-page' ? 1 : 2),
|
||||
HOTMAIL_PROVIDER: 'hotmail-api',
|
||||
isTabAlive: async () => true,
|
||||
isVerificationMailPollingError: () => false,
|
||||
LUCKMAIL_PROVIDER: 'luckmail-api',
|
||||
resolveVerificationStep: async () => {
|
||||
events.resolveCalls += 1;
|
||||
},
|
||||
reuseOrCreateTab: async () => {},
|
||||
setState: async (payload) => {
|
||||
events.setStates.push(payload);
|
||||
},
|
||||
setStepStatus: async () => {},
|
||||
shouldUseCustomRegistrationEmail: () => false,
|
||||
STANDARD_MAIL_VERIFICATION_RESEND_INTERVAL_MS: 25000,
|
||||
STEP7_MAIL_POLLING_RECOVERY_MAX_ATTEMPTS: 8,
|
||||
throwIfStopped: () => {},
|
||||
});
|
||||
|
||||
await executor.executeStep8({
|
||||
email: 'user@example.com',
|
||||
password: 'secret',
|
||||
oauthUrl: 'https://oauth.example/latest',
|
||||
});
|
||||
|
||||
assert.equal(events.resolveCalls, 0);
|
||||
assert.equal(events.rerunStep7, 0);
|
||||
assert.deepStrictEqual(events.setStates, [
|
||||
{
|
||||
step8VerificationTargetEmail: '',
|
||||
loginVerificationRequestedAt: null,
|
||||
},
|
||||
]);
|
||||
assert.deepStrictEqual(events.completeCalls, [
|
||||
{
|
||||
step: 8,
|
||||
payload: {
|
||||
loginVerificationRequestedAt: null,
|
||||
skipLoginVerificationStep: true,
|
||||
directOAuthConsentPage: true,
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('step 8 retries in-place when polling fails but auth page still stays on verification page', async () => {
|
||||
const events = {
|
||||
ensureCalls: 0,
|
||||
resolveCalls: 0,
|
||||
rerunStep7: 0,
|
||||
};
|
||||
const pageStates = [
|
||||
{ state: 'verification_page', displayedEmail: 'user@example.com' },
|
||||
{ state: 'verification_page', displayedEmail: 'user@example.com' },
|
||||
{ state: 'verification_page', displayedEmail: 'user@example.com' },
|
||||
];
|
||||
|
||||
const executor = api.createStep8Executor({
|
||||
addLog: async () => {},
|
||||
chrome: {
|
||||
tabs: {
|
||||
update: async () => {},
|
||||
},
|
||||
},
|
||||
CLOUDFLARE_TEMP_EMAIL_PROVIDER: 'cloudflare-temp-email',
|
||||
completeStepFromBackground: async () => {},
|
||||
confirmCustomVerificationStepBypass: async () => {},
|
||||
ensureStep8VerificationPageReady: async () => {
|
||||
events.ensureCalls += 1;
|
||||
return pageStates[Math.min(events.ensureCalls - 1, pageStates.length - 1)];
|
||||
},
|
||||
rerunStep7ForStep8Recovery: async () => {
|
||||
events.rerunStep7 += 1;
|
||||
},
|
||||
getOAuthFlowRemainingMs: async () => 9000,
|
||||
getOAuthFlowStepTimeoutMs: async (defaultTimeoutMs) => Math.min(defaultTimeoutMs, 9000),
|
||||
getMailConfig: () => ({
|
||||
provider: 'qq',
|
||||
label: 'QQ 邮箱',
|
||||
source: 'mail-qq',
|
||||
url: 'https://mail.qq.com',
|
||||
navigateOnReuse: false,
|
||||
}),
|
||||
getState: async () => ({ email: 'user@example.com', password: 'secret' }),
|
||||
getTabId: async (sourceName) => (sourceName === 'signup-page' ? 1 : 2),
|
||||
HOTMAIL_PROVIDER: 'hotmail-api',
|
||||
isTabAlive: async () => true,
|
||||
isVerificationMailPollingError: (error) => /页面通信异常|did not respond/i.test(String(error?.message || error || '')),
|
||||
LUCKMAIL_PROVIDER: 'luckmail-api',
|
||||
resolveVerificationStep: async () => {
|
||||
events.resolveCalls += 1;
|
||||
if (events.resolveCalls === 1) {
|
||||
throw new Error('步骤 8:页面通信异常 did not respond in 30s');
|
||||
}
|
||||
},
|
||||
reuseOrCreateTab: async () => {},
|
||||
setState: async () => {},
|
||||
setStepStatus: async () => {},
|
||||
shouldUseCustomRegistrationEmail: () => false,
|
||||
STANDARD_MAIL_VERIFICATION_RESEND_INTERVAL_MS: 25000,
|
||||
STEP7_MAIL_POLLING_RECOVERY_MAX_ATTEMPTS: 8,
|
||||
throwIfStopped: () => {},
|
||||
});
|
||||
|
||||
await executor.executeStep8({
|
||||
email: 'user@example.com',
|
||||
password: 'secret',
|
||||
oauthUrl: 'https://oauth.example/latest',
|
||||
});
|
||||
|
||||
assert.equal(events.resolveCalls, 2);
|
||||
assert.equal(events.rerunStep7, 0);
|
||||
assert.equal(events.ensureCalls >= 3, true);
|
||||
});
|
||||
|
||||
test('step 8 completes when polling fails but recovery probe shows oauth consent page', async () => {
|
||||
const events = {
|
||||
ensureCalls: 0,
|
||||
resolveCalls: 0,
|
||||
rerunStep7: 0,
|
||||
completeCalls: [],
|
||||
};
|
||||
const pageStates = [
|
||||
{ state: 'verification_page', displayedEmail: 'user@example.com' },
|
||||
{ state: 'oauth_consent_page' },
|
||||
];
|
||||
|
||||
const executor = api.createStep8Executor({
|
||||
addLog: async () => {},
|
||||
chrome: {
|
||||
tabs: {
|
||||
update: async () => {},
|
||||
},
|
||||
},
|
||||
CLOUDFLARE_TEMP_EMAIL_PROVIDER: 'cloudflare-temp-email',
|
||||
completeStepFromBackground: async (step, payload) => {
|
||||
events.completeCalls.push({ step, payload });
|
||||
},
|
||||
confirmCustomVerificationStepBypass: async () => {},
|
||||
ensureStep8VerificationPageReady: async () => {
|
||||
events.ensureCalls += 1;
|
||||
return pageStates[Math.min(events.ensureCalls - 1, pageStates.length - 1)];
|
||||
},
|
||||
rerunStep7ForStep8Recovery: async () => {
|
||||
events.rerunStep7 += 1;
|
||||
},
|
||||
getOAuthFlowRemainingMs: async () => 9000,
|
||||
getOAuthFlowStepTimeoutMs: async (defaultTimeoutMs) => Math.min(defaultTimeoutMs, 9000),
|
||||
getMailConfig: () => ({
|
||||
provider: 'qq',
|
||||
label: 'QQ 邮箱',
|
||||
source: 'mail-qq',
|
||||
url: 'https://mail.qq.com',
|
||||
navigateOnReuse: false,
|
||||
}),
|
||||
getState: async () => ({ email: 'user@example.com', password: 'secret' }),
|
||||
getTabId: async (sourceName) => (sourceName === 'signup-page' ? 1 : 2),
|
||||
HOTMAIL_PROVIDER: 'hotmail-api',
|
||||
isTabAlive: async () => true,
|
||||
isVerificationMailPollingError: (error) => /页面通信异常|did not respond/i.test(String(error?.message || error || '')),
|
||||
LUCKMAIL_PROVIDER: 'luckmail-api',
|
||||
resolveVerificationStep: async () => {
|
||||
events.resolveCalls += 1;
|
||||
throw new Error('步骤 8:页面通信异常 did not respond in 30s');
|
||||
},
|
||||
reuseOrCreateTab: async () => {},
|
||||
setState: async () => {},
|
||||
setStepStatus: async () => {},
|
||||
shouldUseCustomRegistrationEmail: () => false,
|
||||
STANDARD_MAIL_VERIFICATION_RESEND_INTERVAL_MS: 25000,
|
||||
STEP7_MAIL_POLLING_RECOVERY_MAX_ATTEMPTS: 8,
|
||||
throwIfStopped: () => {},
|
||||
});
|
||||
|
||||
await executor.executeStep8({
|
||||
email: 'user@example.com',
|
||||
password: 'secret',
|
||||
oauthUrl: 'https://oauth.example/latest',
|
||||
});
|
||||
|
||||
assert.equal(events.resolveCalls, 1);
|
||||
assert.equal(events.rerunStep7, 0);
|
||||
assert.deepStrictEqual(events.completeCalls, [
|
||||
{
|
||||
step: 8,
|
||||
payload: {
|
||||
loginVerificationRequestedAt: null,
|
||||
skipLoginVerificationStep: true,
|
||||
directOAuthConsentPage: true,
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('step 8 uses a fixed 10-minute lookback window and disables resend interval for 2925 mailbox polling', async () => {
|
||||
let capturedOptions = null;
|
||||
let ensureCalls = 0;
|
||||
|
||||
@@ -132,6 +132,115 @@ return {
|
||||
);
|
||||
});
|
||||
|
||||
test('step 8 ready check keeps waiting when retryPage is reported on consent URL', async () => {
|
||||
const api = new Function(`
|
||||
let pollCount = 0;
|
||||
|
||||
function throwIfStopped() {}
|
||||
async function sleepWithStop() {}
|
||||
async function ensureStep8SignupPageReady() {}
|
||||
async function getState() {
|
||||
return { phoneVerificationEnabled: true };
|
||||
}
|
||||
const phoneVerificationHelpers = {
|
||||
async completePhoneVerificationFlow() {
|
||||
throw new Error('should not trigger phone verification flow');
|
||||
},
|
||||
};
|
||||
async function getStep8PageState() {
|
||||
pollCount += 1;
|
||||
if (pollCount === 1) {
|
||||
return {
|
||||
url: 'https://auth.openai.com/sign-in-with-chatgpt/codex/consent',
|
||||
retryPage: true,
|
||||
consentPage: true,
|
||||
consentReady: false,
|
||||
addPhonePage: false,
|
||||
phoneVerificationPage: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
url: 'https://auth.openai.com/sign-in-with-chatgpt/codex/consent',
|
||||
retryPage: false,
|
||||
consentPage: true,
|
||||
consentReady: true,
|
||||
addPhonePage: false,
|
||||
phoneVerificationPage: false,
|
||||
};
|
||||
}
|
||||
|
||||
${extractFunction('waitForStep8Ready')}
|
||||
|
||||
return {
|
||||
async run() {
|
||||
return waitForStep8Ready(88, 1000);
|
||||
},
|
||||
};
|
||||
`)();
|
||||
|
||||
const result = await api.run();
|
||||
assert.equal(result?.consentReady, true);
|
||||
assert.equal(result?.retryPage, false);
|
||||
});
|
||||
|
||||
test('step 8 click effect ignores consent-like retry snapshots and waits for real page progress', async () => {
|
||||
const api = new Function(`
|
||||
let pollCount = 0;
|
||||
const chrome = {
|
||||
tabs: {
|
||||
async get() {
|
||||
return {
|
||||
id: 88,
|
||||
url: 'https://auth.openai.com/sign-in-with-chatgpt/codex/consent',
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
function throwIfStopped() {}
|
||||
async function sleepWithStop() {}
|
||||
async function ensureStep8SignupPageReady() {}
|
||||
async function getStep8PageState() {
|
||||
pollCount += 1;
|
||||
if (pollCount === 1) {
|
||||
return {
|
||||
url: 'https://auth.openai.com/sign-in-with-chatgpt/codex/consent',
|
||||
retryPage: true,
|
||||
consentPage: true,
|
||||
consentReady: false,
|
||||
addPhonePage: false,
|
||||
verificationPage: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
url: 'https://chatgpt.com/',
|
||||
retryPage: false,
|
||||
consentPage: false,
|
||||
consentReady: false,
|
||||
addPhonePage: false,
|
||||
verificationPage: false,
|
||||
};
|
||||
}
|
||||
|
||||
${extractFunction('waitForStep8ClickEffect')}
|
||||
|
||||
return {
|
||||
async run() {
|
||||
return waitForStep8ClickEffect(
|
||||
88,
|
||||
'https://auth.openai.com/sign-in-with-chatgpt/codex/consent',
|
||||
1000
|
||||
);
|
||||
},
|
||||
};
|
||||
`)();
|
||||
|
||||
const result = await api.run();
|
||||
assert.equal(result?.progressed, true);
|
||||
assert.equal(result?.reason, 'left_consent_page');
|
||||
assert.match(String(result?.url || ''), /chatgpt\.com/);
|
||||
});
|
||||
|
||||
test('step 8 ready check completes phone verification flow before waiting for OAuth consent', async () => {
|
||||
const api = new Function(`
|
||||
let pollCount = 0;
|
||||
|
||||
@@ -419,6 +419,79 @@ test('verification flow completes step 8 and flags phone verification when add-p
|
||||
]);
|
||||
});
|
||||
|
||||
test('verification flow keeps step 8 successful when code submit transport fails but auth page already reaches oauth consent', async () => {
|
||||
const events = [];
|
||||
|
||||
const helpers = api.createVerificationFlowHelpers({
|
||||
addLog: async (message) => {
|
||||
events.push(['log', message]);
|
||||
},
|
||||
chrome: {
|
||||
tabs: {
|
||||
update: async () => {},
|
||||
},
|
||||
},
|
||||
CLOUDFLARE_TEMP_EMAIL_PROVIDER: 'cloudflare-temp-email',
|
||||
completeStepFromBackground: async (_step, payload) => {
|
||||
events.push(['complete', payload.code]);
|
||||
},
|
||||
confirmCustomVerificationStepBypassRequest: async () => ({ confirmed: true }),
|
||||
getHotmailVerificationPollConfig: () => ({}),
|
||||
getHotmailVerificationRequestTimestamp: () => 0,
|
||||
getState: async () => ({}),
|
||||
getTabId: async () => 1,
|
||||
HOTMAIL_PROVIDER: 'hotmail-api',
|
||||
isStopError: () => false,
|
||||
LUCKMAIL_PROVIDER: 'luckmail-api',
|
||||
MAIL_2925_VERIFICATION_INTERVAL_MS: 15000,
|
||||
MAIL_2925_VERIFICATION_MAX_ATTEMPTS: 15,
|
||||
pollCloudflareTempEmailVerificationCode: async () => ({}),
|
||||
pollHotmailVerificationCode: async () => ({}),
|
||||
pollLuckmailVerificationCode: async () => ({}),
|
||||
sendToContentScript: async () => ({}),
|
||||
sendToContentScriptResilient: async (_source, message) => {
|
||||
if (message.type === 'FILL_CODE') {
|
||||
throw new Error('message channel is closed before a response was received');
|
||||
}
|
||||
if (message.type === 'GET_LOGIN_AUTH_STATE') {
|
||||
return {
|
||||
state: 'oauth_consent_page',
|
||||
url: 'https://auth.openai.com/authorize?client_id=test',
|
||||
};
|
||||
}
|
||||
return {};
|
||||
},
|
||||
sendToMailContentScriptResilient: async () => ({
|
||||
code: '654321',
|
||||
emailTimestamp: 123,
|
||||
}),
|
||||
setState: async (payload) => {
|
||||
events.push(['state', payload.lastLoginCode || payload.lastSignupCode]);
|
||||
},
|
||||
setStepStatus: async () => {},
|
||||
sleepWithStop: async () => {},
|
||||
throwIfStopped: () => {},
|
||||
VERIFICATION_POLL_MAX_ROUNDS: 5,
|
||||
});
|
||||
|
||||
const result = await helpers.resolveVerificationStep(
|
||||
8,
|
||||
{ email: 'user@example.com', lastLoginCode: null },
|
||||
{ provider: 'qq', label: 'QQ Mail' },
|
||||
{}
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(result, {
|
||||
phoneVerificationRequired: false,
|
||||
url: 'https://auth.openai.com/authorize?client_id=test',
|
||||
});
|
||||
assert.deepStrictEqual(events.filter((entry) => entry[0] !== 'log'), [
|
||||
['state', '654321'],
|
||||
['complete', '654321'],
|
||||
]);
|
||||
assert.ok(events.some((entry) => entry[0] === 'log' && /通信中断/.test(entry[1])));
|
||||
});
|
||||
|
||||
test('verification flow treats manual step 8 add-phone confirmation as the same fatal add-phone error', async () => {
|
||||
const helpers = api.createVerificationFlowHelpers({
|
||||
addLog: async () => {},
|
||||
|
||||
Reference in New Issue
Block a user