短信验证调试成功
This commit is contained in:
+31
-11
@@ -24,22 +24,39 @@ async function expectFail(clientApp, path, options = {}) {
|
||||
return json.message;
|
||||
}
|
||||
|
||||
async function adminLogin() {
|
||||
return req('HQ_WEB', '/admin/auth/login/sms', {
|
||||
const MOCK_SMS_CODE = process.env.MOCK_SMS_CODE ?? '123456';
|
||||
|
||||
async function sendSms(clientApp, phone, scene, sendPath = '/auth/sms/send') {
|
||||
await req(clientApp, sendPath, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ phone: '13600000001', code: '123456' }),
|
||||
body: JSON.stringify({ phone, scene }),
|
||||
});
|
||||
}
|
||||
|
||||
async function loginSms(clientApp, phone, scene, loginPath = '/auth/login/sms', sendPath = '/auth/sms/send') {
|
||||
await sendSms(clientApp, phone, scene, sendPath);
|
||||
return req(clientApp, loginPath, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ phone, code: MOCK_SMS_CODE }),
|
||||
});
|
||||
}
|
||||
|
||||
async function adminLogin() {
|
||||
return loginSms(
|
||||
'HQ_WEB',
|
||||
'13600000001',
|
||||
'HQ_LOGIN',
|
||||
'/admin/auth/login/sms',
|
||||
'/admin/auth/sms/send',
|
||||
);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log('1. Health');
|
||||
await req('USER_H5', '/health');
|
||||
|
||||
console.log('2. User login');
|
||||
const userLogin = await req('USER_H5', '/auth/login/sms', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ phone: '13800000001', code: '123456' }),
|
||||
});
|
||||
const userLogin = await loginSms('USER_H5', '13800000001', 'USER_LOGIN');
|
||||
const userToken = userLogin.accessToken;
|
||||
|
||||
console.log('3. Cities + products');
|
||||
@@ -105,10 +122,13 @@ async function main() {
|
||||
});
|
||||
|
||||
console.log('8. Shop confirm redeem');
|
||||
const shopLogin = await req('SHOP_H5', '/shop/auth/login/sms', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ phone: '13900000001', code: '123456' }),
|
||||
});
|
||||
const shopLogin = await loginSms(
|
||||
'SHOP_H5',
|
||||
'13900000001',
|
||||
'STORE_LOGIN',
|
||||
'/shop/auth/login/sms',
|
||||
'/shop/auth/sms/send',
|
||||
);
|
||||
const preview = await req('SHOP_H5', '/shop/redeem/preview', {
|
||||
method: 'POST',
|
||||
token: shopLogin.accessToken,
|
||||
|
||||
Reference in New Issue
Block a user