补充后端核心链路自动化测试
This commit is contained in:
@@ -60,7 +60,7 @@ export async function replayAgisoTradeWebhookEvent(webhookEvent) {
|
||||
return executeAgisoTradeWebhook(parsed, webhookEvent.id, { requestId: requestLike.requestId })
|
||||
}
|
||||
|
||||
function buildWebhookEventInput(requestLike, parsed) {
|
||||
export function buildWebhookEventInput(requestLike, parsed) {
|
||||
return {
|
||||
provider: parsed.provider,
|
||||
platform: parsed.platform,
|
||||
@@ -258,7 +258,7 @@ async function enrichTradeBeforeUpsert(parsed, { requestId = '', webhookEventId
|
||||
}
|
||||
}
|
||||
|
||||
function shouldEnrichAgisoXianyuTrade(parsed) {
|
||||
export function shouldEnrichAgisoXianyuTrade(parsed) {
|
||||
if (!parsed || parsed.provider !== 'agiso' || parsed.platform !== 'xianyu') {
|
||||
return false
|
||||
}
|
||||
@@ -306,7 +306,7 @@ function hasDetailedOrderItems(items) {
|
||||
})
|
||||
}
|
||||
|
||||
function parseAgisoTradeRequest(requestLike) {
|
||||
export function parseAgisoTradeRequest(requestLike) {
|
||||
const query = normalizeRecord(requestLike.query)
|
||||
const body = normalizeRecord(requestLike.body)
|
||||
const rawJson = String(body.json || '').trim()
|
||||
@@ -386,10 +386,10 @@ function parseAgisoTradeRequest(requestLike) {
|
||||
}
|
||||
}
|
||||
|
||||
function verifyAgisoSignature({ rawJson, timestamp, sign }) {
|
||||
const appSecret = String(runtimeConfig.platforms.agiso.appSecret || '').trim()
|
||||
export function verifyAgisoSignatureWithSecret({ rawJson, timestamp, sign, appSecret }) {
|
||||
const normalizedSecret = String(appSecret || '').trim()
|
||||
|
||||
if (!appSecret) {
|
||||
if (!normalizedSecret) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ function verifyAgisoSignature({ rawJson, timestamp, sign }) {
|
||||
|
||||
const documentedDigest = crypto
|
||||
.createHash('md5')
|
||||
.update(`${appSecret}json${rawJson}timestamp${timestamp}${appSecret}`, 'utf8')
|
||||
.update(`${normalizedSecret}json${rawJson}timestamp${timestamp}${normalizedSecret}`, 'utf8')
|
||||
.digest('hex')
|
||||
.toLowerCase()
|
||||
|
||||
@@ -409,13 +409,18 @@ function verifyAgisoSignature({ rawJson, timestamp, sign }) {
|
||||
|
||||
const legacyDigest = crypto
|
||||
.createHash('md5')
|
||||
.update(`${appSecret}${rawJson}${timestamp}`, 'utf8')
|
||||
.update(`${normalizedSecret}${rawJson}${timestamp}`, 'utf8')
|
||||
.digest('hex')
|
||||
.toLowerCase()
|
||||
|
||||
return legacyDigest === sign
|
||||
}
|
||||
|
||||
function verifyAgisoSignature({ rawJson, timestamp, sign }) {
|
||||
const appSecret = String(runtimeConfig.platforms.agiso.appSecret || '').trim()
|
||||
return verifyAgisoSignatureWithSecret({ rawJson, timestamp, sign, appSecret })
|
||||
}
|
||||
|
||||
function resolveEventType(aopic, payload) {
|
||||
const normalized = String(aopic || '').trim()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user