Fix GenerateTestPAN: random fills, suppress cardType when unknown
This commit is contained in:
parent
c405326f03
commit
0aadfb94e3
@ -220,11 +220,11 @@ function parsePan(pan) {
|
||||
return {
|
||||
pan: normalized,
|
||||
network: brand || "Unknown",
|
||||
cardType: typeHint ? typeHint.likelyType : "Unknown",
|
||||
cardTypeConfidence: typeHint ? typeHint.confidence : "low",
|
||||
cardTypeNote: typeHint ?
|
||||
typeHint.note :
|
||||
"Card type cannot be determined — the PAN did not match a known network range.",
|
||||
...(typeHint && typeHint.confidence !== "low" ? {
|
||||
cardType: typeHint.likelyType,
|
||||
cardTypeConfidence: typeHint.confidence,
|
||||
cardTypeNote: typeHint.note,
|
||||
} : {}),
|
||||
majorIndustryIdentifier: mii,
|
||||
majorIndustryIdentifierDescription: MII_DESCRIPTIONS[mii] || "Unknown",
|
||||
issuerIdentificationNumber: normalized.substring(0, Math.min(8, normalized.length)),
|
||||
@ -250,18 +250,17 @@ function finalizePan(body) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a numeric filler string.
|
||||
* Generates random filler digits.
|
||||
*
|
||||
* @param {number} length
|
||||
* @returns {string}
|
||||
*/
|
||||
function fillerDigits(length) {
|
||||
const seed = "12345678901234567890";
|
||||
return seed.repeat(Math.ceil(length / seed.length)).substring(0, length);
|
||||
return Array.from({ length }, () => Math.floor(Math.random() * 10)).join("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a deterministic brand-valid PAN.
|
||||
* Generates a random brand-valid PAN.
|
||||
*
|
||||
* @param {string} brand
|
||||
* @param {number} requestedLength
|
||||
|
||||
@ -401,9 +401,6 @@ TestRegister.addTests([
|
||||
pan: "4024140000000131",
|
||||
source: "Public Visa test PAN published in Mastercard AVS scenario documentation.",
|
||||
network: "Visa",
|
||||
cardType: "Unknown",
|
||||
cardTypeConfidence: "low",
|
||||
cardTypeNote: "Visa issues credit, debit, and prepaid cards. The product type is determined by the issuer BIN, not the PAN prefix — a BIN database lookup is required.",
|
||||
majorIndustryIdentifier: "4",
|
||||
majorIndustryIdentifierDescription: "Banking and financial (Visa)",
|
||||
issuerIdentificationNumber: "40241400",
|
||||
@ -424,13 +421,13 @@ TestRegister.addTests([
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Generate Test PAN: American Express generated sample",
|
||||
name: "Generate Test PAN: American Express curated sample",
|
||||
input: "",
|
||||
expectedOutput: "371234567890120",
|
||||
expectedOutput: "371449635398431",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Generate Test PAN",
|
||||
args: ["American Express", "Generated valid PAN", 15, false]
|
||||
args: ["American Express", "Curated sample", 15, false]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user