Imported Upstream version 2.5.11
[libapache-mod-security.git] / apache2 / t / op / verifyCC.t
1 ### Empty
2 # empty w/re not matching empty
3 {
4         type => "op",
5         name => "verifyCC",
6         param => "\d+",
7         input => "",
8         ret => 0,
9 },
10 # empty w/re matching empty
11 {
12         type => "op",
13         name => "verifyCC",
14         param => '\d*',
15         input => "",
16         ret => 0,
17 },
18
19 ### Non-matching
20 {
21         type => "op",
22         name => "verifyCC",
23         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
24         input => "TestCase",
25         ret => 0,
26 },
27
28 ### No digits in match
29 {
30         type => "op",
31         name => "verifyCC",
32         param => 'TestCase',
33         input => "TestCase",
34         ret => 0,
35 },
36
37 ### Too generic RE w/no matchs (Luhn will be called until all fail)
38 {
39         type => "op",
40         name => "verifyCC",
41         param => '.*',
42         input => "TestCase",
43         ret => 0,
44 },
45
46 ### Test Good CC#
47 # Mastercard
48 {
49         type => "op",
50         name => "verifyCC",
51         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
52         input => "5484605089158216",
53         ret => 1,
54 },
55 {
56         type => "op",
57         name => "verifyCC",
58         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
59         input => "5574407071707154",
60         ret => 1,
61 },
62 {
63         type => "op",
64         name => "verifyCC",
65         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
66         input => "5351341509714210",
67         ret => 1,
68 },
69 {
70         type => "op",
71         name => "verifyCC",
72         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
73         input => "5585166974020647",
74         ret => 1,
75 },
76 {
77         type => "op",
78         name => "verifyCC",
79         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
80         input => "5492180332479256",
81         ret => 1,
82 },
83 {
84         type => "op",
85         name => "verifyCC",
86         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
87         input => "5111178142162816",
88         ret => 1,
89 },
90 {
91         type => "op",
92         name => "verifyCC",
93         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
94         input => "5511424748431031",
95         ret => 1,
96 },
97 {
98         type => "op",
99         name => "verifyCC",
100         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
101         input => "5259964281562326",
102         ret => 1,
103 },
104 {
105         type => "op",
106         name => "verifyCC",
107         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
108         input => "5138342589974385",
109         ret => 1,
110 },
111 {
112         type => "op",
113         name => "verifyCC",
114         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
115         input => "5362069587634979",
116         ret => 1,
117 },
118 # VISA 16 digit
119 {
120         type => "op",
121         name => "verifyCC",
122         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
123         input => "4916545704601136",
124         ret => 1,
125 },
126 {
127         type => "op",
128         name => "verifyCC",
129         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
130         input => "4539501231827691",
131         ret => 1,
132 },
133 {
134         type => "op",
135         name => "verifyCC",
136         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
137         input => "4556338049595394",
138         ret => 1,
139 },
140 {
141         type => "op",
142         name => "verifyCC",
143         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
144         input => "4929326438756024",
145         ret => 1,
146 },
147 {
148         type => "op",
149         name => "verifyCC",
150         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
151         input => "4485432027326322",
152         ret => 1,
153 },
154 {
155         type => "op",
156         name => "verifyCC",
157         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
158         input => "4532104980682081",
159         ret => 1,
160 },
161 {
162         type => "op",
163         name => "verifyCC",
164         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
165         input => "4485974616349298",
166         ret => 1,
167 },
168 {
169         type => "op",
170         name => "verifyCC",
171         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
172         input => "4916580487207199",
173         ret => 1,
174 },
175 {
176         type => "op",
177         name => "verifyCC",
178         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
179         input => "4532009746910413",
180         ret => 1,
181 },
182 {
183         type => "op",
184         name => "verifyCC",
185         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
186         input => "4024007144622932",
187         ret => 1,
188 },
189 # VISA 13 digit
190 {
191         type => "op",
192         name => "verifyCC",
193         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
194         input => "4556324125126",
195         ret => 1,
196 },
197 {
198         type => "op",
199         name => "verifyCC",
200         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
201         input => "4067482954141",
202         ret => 1,
203 },
204 {
205         type => "op",
206         name => "verifyCC",
207         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
208         input => "4532402654980",
209         ret => 1,
210 },
211 {
212         type => "op",
213         name => "verifyCC",
214         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
215         input => "4539709679875",
216         ret => 1,
217 },
218 {
219         type => "op",
220         name => "verifyCC",
221         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
222         input => "4024007182237",
223         ret => 1,
224 },
225 # American Express
226 {
227         type => "op",
228         name => "verifyCC",
229         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
230         input => "343918934573386",
231         ret => 1,
232 },
233 {
234         type => "op",
235         name => "verifyCC",
236         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
237         input => "344881778330710",
238         ret => 1,
239 },
240 {
241         type => "op",
242         name => "verifyCC",
243         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
244         input => "345439478558905",
245         ret => 1,
246 },
247 {
248         type => "op",
249         name => "verifyCC",
250         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
251         input => "346465614421111",
252         ret => 1,
253 },
254 {
255         type => "op",
256         name => "verifyCC",
257         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
258         input => "372263817755618",
259         ret => 1,
260 },
261 # Discover
262 {
263         type => "op",
264         name => "verifyCC",
265         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
266         input => "6011402777433576",
267         ret => 1,
268 },
269 {
270         type => "op",
271         name => "verifyCC",
272         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
273         input => "6011890045362751",
274         ret => 1,
275 },
276 {
277         type => "op",
278         name => "verifyCC",
279         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
280         input => "6011439091242416",
281         ret => 1,
282 },
283 # Diners Club
284 {
285         type => "op",
286         name => "verifyCC",
287         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
288         input => "30162519308318",
289         ret => 1,
290 },
291 {
292         type => "op",
293         name => "verifyCC",
294         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
295         input => "30311556856867",
296         ret => 1,
297 },
298 {
299         type => "op",
300         name => "verifyCC",
301         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
302         input => "36850112043985",
303         ret => 1,
304 },
305 # enRoute
306 {
307         type => "op",
308         name => "verifyCC",
309         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
310         input => "201427829075664",
311         ret => 1,
312 },
313 {
314         type => "op",
315         name => "verifyCC",
316         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
317         input => "201434726660424",
318         ret => 1,
319 },
320 {
321         type => "op",
322         name => "verifyCC",
323         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
324         input => "201453368666085",
325         ret => 1,
326 },
327 # JCB 15 digit
328 {
329         type => "op",
330         name => "verifyCC",
331         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
332         input => "210091499965007",
333         ret => 1,
334 },
335 {
336         type => "op",
337         name => "verifyCC",
338         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
339         input => "210072739882947",
340         ret => 1,
341 },
342 {
343         type => "op",
344         name => "verifyCC",
345         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
346         input => "180013970064072",
347         ret => 1,
348 },
349 # JCB 16 digit
350 {
351         type => "op",
352         name => "verifyCC",
353         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
354         input => "3096676276259096",
355         ret => 1,
356 },
357 {
358         type => "op",
359         name => "verifyCC",
360         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
361         input => "3158726040010070",
362         ret => 1,
363 },
364 {
365         type => "op",
366         name => "verifyCC",
367         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
368         input => "3096531217494742",
369         ret => 1,
370 },
371 # Voyager
372 {
373         type => "op",
374         name => "verifyCC",
375         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
376         input => "869974262335041",
377         ret => 1,
378 },
379 {
380         type => "op",
381         name => "verifyCC",
382         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
383         input => "869905005856398",
384         ret => 1,
385 },
386 {
387         type => "op",
388         name => "verifyCC",
389         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
390         input => "869950500085465",
391         ret => 1,
392 },
393
394 ### Test Bad CC#
395 {
396         type => "op",
397         name => "verifyCC",
398         param => '(?:^|[^\d])(\d+)(?:[^\d]|$)',
399         input => "1234567890012345",
400         ret => 0,
401 },
402
403 ### Test regex + Luhn
404 # from http://www.merriampark.com/anatomycc.htm
405 {
406         type => "op",
407         name => "verifyCC",
408         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
409         input => "4417123456789113",
410         ret => 1,
411 },
412 {
413         type => "op",
414         name => "verifyCC",
415         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
416         input => "4408041234567893",
417         ret => 1,
418 },
419 {
420         type => "op",
421         name => "verifyCC",
422         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
423         input => "4408041234567890",
424         ret => 0,
425 },
426 {
427         type => "op",
428         name => "verifyCC",
429         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
430         input => "4417123456789112",
431         ret => 0,
432 },
433 # on word boundary
434 {
435         type => "op",
436         name => "verifyCC",
437         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
438         input => "a5484605089158216",
439         ret => 1,
440 },
441 {
442         type => "op",
443         name => "verifyCC",
444         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
445         input => "a5484605089158216b",
446         ret => 1,
447 },
448 {
449         type => "op",
450         name => "verifyCC",
451         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
452         input => "5484605089158216b",
453         ret => 1,
454 },
455 # valid patterns
456 {
457         type => "op",
458         name => "verifyCC",
459         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
460         input => "5484-6050-8915-8216",
461         ret => 1,
462 },
463 # changed digit from table above
464 {
465         type => "op",
466         name => "verifyCC",
467         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
468         input => "5484605089158217",
469         ret => 0,
470 },
471 {
472         type => "op",
473         name => "verifyCC",
474         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
475         input => "5574407071807154",
476         ret => 0,
477 },
478 # wrong patterns
479 {
480         type => "op",
481         name => "verifyCC",
482         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
483         input => "5-484-6050-8915-8216",
484         ret => 0,
485 },
486 {
487         type => "op",
488         name => "verifyCC",
489         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
490         input => "5484 6050 8915 8216",
491         ret => 0,
492 },
493 # not on digits boundary
494 {
495         type => "op",
496         name => "verifyCC",
497         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
498         input => "15484605089158216",
499         ret => 0,
500 },
501 {
502         type => "op",
503         name => "verifyCC",
504         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
505         input => "154846050891582162",
506         ret => 0,
507 },
508 {
509         type => "op",
510         name => "verifyCC",
511         param => '(?:^|[^\d])(\d{4}\-?\d{4}\-?\d{2}\-?\d{2}\-?\d{1,4})(?:[^\d]|$)',
512         input => "54846050891582162",
513         ret => 0,
514 },