Skip to content

Commit

Permalink
Merge pull request #104 from jonathoncarter/master
Browse files Browse the repository at this point in the history
CC Analyze unit test
  • Loading branch information
d-Rickyy-b authored Jan 26, 2020
2 parents 6b2e212 + 792d398 commit 2aa27f8
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions pastepwn/analyzers/tests/creditcardanalyzer_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
import unittest
from unittest import mock

from pastepwn.analyzers.creditcardanalyzer import CreditCardAnalyzer


class TestCreditCardAnalyzer(unittest.TestCase):
def setUp(self):
self.analyzer = CreditCardAnalyzer(None)
self.paste = mock.Mock()

def test_match_positive(self):
"""Test if positives are recognized
* CARDS IN ORDER *
VISA
MASTERCARD
AMERICAN EXPRESS
DINERS CLUB
DISCOVER
JCB
"""
self.paste.body = "4556316812657526"
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "4556 3168 1265 7526"
#self.assertTrue(self.analyzer.match(self.paste))

self.paste.body = "5168441223630339"
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "5168 4412 2363 0339"
#self.assertTrue(self.analyzer.match(self.paste))

self.paste.body = "371642190784801"
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "3716 421907 84801"
#self.assertTrue(self.analyzer.match(self.paste))

self.paste.body = "30043277253249"
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "3004 327725 3249"
#self.assertTrue(self.analyzer.match(self.paste))

self.paste.body = "6011988461284820"
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "6011 9884 6128 4820"
#self.assertTrue(self.analyzer.match(self.paste))

self.paste.body = "3538684728624673"
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "3538 6847 2862 4673"
#self.assertTrue(self.analyzer.match(self.paste))

def test_match_negative(self):
"""Test if negatives are not recognized"""
self.paste.body = ""
self.assertFalse(self.analyzer.match(self.paste))
self.paste.body = None
self.assertFalse(self.analyzer.match(self.paste))
self.paste.body = "https://www.github.com"
self.assertFalse(self.analyzer.match(self.paste))
self.paste.body = "1234 5678 9101 12"
self.assertFalse(self.analyzer.match(self.paste))
self.paste.body = "123456789101112"
self.assertFalse(self.analyzer.match(self.paste))
self.paste.body = "51684+4122363339"
self.assertFalse(self.analyzer.match(self.paste))
self.paste.body = "+5168441223630"
self.assertFalse(self.analyzer.match(self.paste))
self.paste.body = "5368441223630339183239284"
self.assertFalse(self.analyzer.match(self.paste))


if __name__ == '__main__':
unittest.main()

0 comments on commit 2aa27f8

Please sign in to comment.