From 8cdbc8a9a88057684a0e75d8a508ffd3d7422e49 Mon Sep 17 00:00:00 2001 From: Jay Shah Date: Tue, 19 Dec 2017 12:19:10 +0000 Subject: [PATCH] Add failing tests for IBANs for countries we don't explicitly support. --- spec/ibandit/iban_spec.rb | 275 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 275 insertions(+) diff --git a/spec/ibandit/iban_spec.rb b/spec/ibandit/iban_spec.rb index 329927b..54c67f5 100755 --- a/spec/ibandit/iban_spec.rb +++ b/spec/ibandit/iban_spec.rb @@ -1674,275 +1674,550 @@ it { is_expected.to be_valid } end + context "for an invalid Azerbaijanian IBAN" do + let(:iban_code) { "AZ91 NABZ 0000 0000 1370 1000 1944" } + it { is_expected.to_not be_valid } + end + context "for a valid Bahrainian IBAN" do let(:iban_code) { "BH67 BMAG 0000 1299 1234 56" } it { is_expected.to be_valid } end + context "for an invalid Bahrainian IBAN" do + let(:iban_code) { "BH97 BMAG 0000 1299 1234 56" } + it { is_expected.to_not be_valid } + end + context "for a valid Belgian IBAN" do let(:iban_code) { "BE62 5100 0754 7061" } it { is_expected.to be_valid } end + context "for an invalid Belgian IBAN" do + let(:iban_code) { "BE92 5100 0754 7061" } + it { is_expected.to_not be_valid } + end + context "for a valid Bosnian IBAN" do let(:iban_code) { "BA39 1290 0794 0102 8494" } it { is_expected.to be_valid } end + context "for an invalid Bosnian IBAN" do + let(:iban_code) { "BA99 1290 0794 0102 8494" } + it { is_expected.to_not be_valid } + end + context "for a valid Bulgarian IBAN" do let(:iban_code) { "BG80 BNBG 9661 1020 3456 78" } it { is_expected.to be_valid } end + context "for an invalid Bulgarian IBAN" do + let(:iban_code) { "BG90 BNBG 9661 1020 3456 78" } + it { is_expected.to_not be_valid } + end + context "for a valid Croatian IBAN" do let(:iban_code) { "HR12 1001 0051 8630 0016 0" } it { is_expected.to be_valid } end + context "for an invalid Croatian IBAN" do + let(:iban_code) { "HR92 1001 0051 8630 0016 0" } + it { is_expected.to_not be_valid } + end + context "for a valid Cypriot IBAN" do let(:iban_code) { "CY17 0020 0128 0000 0012 0052 7600" } it { is_expected.to be_valid } end + context "for an invalid Cypriot IBAN" do + let(:iban_code) { "CY97 0020 0128 0000 0012 0052 7600" } + it { is_expected.to_not be_valid } + end + context "for a valid Czech IBAN" do let(:iban_code) { "CZ65 0800 0000 1920 0014 5399" } it { is_expected.to be_valid } end + context "for an invalid Czech IBAN" do + let(:iban_code) { "CZ95 0800 0000 1920 0014 5399" } + it { is_expected.to_not be_valid } + end + context "for a valid Danish IBAN" do let(:iban_code) { "DK50 0040 0440 1162 43" } it { is_expected.to be_valid } end + context "for an invalid Danish IBAN" do + let(:iban_code) { "DK90 0040 0440 1162 43" } + it { is_expected.to_not be_valid } + end + context "for a valid Estonian IBAN" do let(:iban_code) { "EE38 2200 2210 2014 5685" } it { is_expected.to be_valid } end + context "for an invalid Estonian IBAN" do + let(:iban_code) { "EE98 2200 2210 2014 5685" } + it { is_expected.to_not be_valid } + end + context "for a valid Faroe Islands IBAN" do let(:iban_code) { "FO97 5432 0388 8999 44" } it { is_expected.to be_valid } end + context "for an invalid Faroe Islands IBAN" do + let(:iban_code) { "FO27 5432 0388 8999 44" } + it { is_expected.to_not be_valid } + end + context "for a valid Finnish IBAN" do let(:iban_code) { "FI21 1234 5600 0007 85" } it { is_expected.to be_valid } end + context "for an invalid Finnish IBAN" do + let(:iban_code) { "FI91 1234 5600 0007 85" } + it { is_expected.to_not be_valid } + end + context "for a valid French IBAN" do let(:iban_code) { "FR14 2004 1010 0505 0001 3M02 606" } it { is_expected.to be_valid } end + context "for an invalid French IBAN" do + let(:iban_code) { "FR94 2004 1010 0505 0001 3M02 606" } + it { is_expected.to_not be_valid } + end + context "for a valid Georgian IBAN" do let(:iban_code) { "GE29 NB00 0000 0101 9049 17" } it { is_expected.to be_valid } end + context "for an invalid Georgian IBAN" do + let(:iban_code) { "GE99 NB00 0000 0101 9049 17" } + it { is_expected.to_not be_valid } + end + context "for a valid German IBAN" do let(:iban_code) { "DE89 3704 0044 0532 0130 00" } it { is_expected.to be_valid } end + context "for an invalid German IBAN" do + let(:iban_code) { "DE99 3704 0044 0532 0130 00" } + it { is_expected.to_not be_valid } + end + context "for a valid Gibraltan IBAN" do let(:iban_code) { "GI75 NWBK 0000 0000 7099 453" } it { is_expected.to be_valid } end + context "for an invalid Gibraltan IBAN" do + let(:iban_code) { "GI95 NWBK 0000 0000 7099 453" } + it { is_expected.to_not be_valid } + end + context "for a valid Greek IBAN" do let(:iban_code) { "GR16 0110 1250 0000 0001 2300 695" } it { is_expected.to be_valid } end + context "for an invalid Greek IBAN" do + let(:iban_code) { "GR96 0110 1250 0000 0001 2300 695" } + it { is_expected.to_not be_valid } + end + context "for a valid Greenland IBAN" do let(:iban_code) { "GL56 0444 9876 5432 10" } it { is_expected.to be_valid } end + context "for an invalid Greenland IBAN" do + let(:iban_code) { "GL96 0444 9876 5432 10" } + it { is_expected.to_not be_valid } + end + context "for a valid Hungarian IBAN" do let(:iban_code) { "HU42 1177 3016 1111 1018 0000 0000" } it { is_expected.to be_valid } end + context "for an invalid Hungarian IBAN" do + let(:iban_code) { "HU92 1177 3016 1111 1018 0000 0000" } + it { is_expected.to_not be_valid } + end + context "for a valid Icelandic IBAN" do let(:iban_code) { "IS14 0159 2600 7654 5510 7303 39" } it { is_expected.to be_valid } end + context "for an invalid Icelandic IBAN" do + let(:iban_code) { "IS94 0159 2600 7654 5510 7303 39" } + it { is_expected.to_not be_valid } + end + context "for a valid Irish IBAN" do let(:iban_code) { "IE29 AIBK 9311 5212 3456 78" } it { is_expected.to be_valid } end + context "for an invalid Irish IBAN" do + let(:iban_code) { "IE99 AIBK 9311 5212 3456 78" } + it { is_expected.to_not be_valid } + end + context "for a valid Israeli IBAN" do let(:iban_code) { "IL62 0108 0000 0009 9999 999" } it { is_expected.to be_valid } end + context "for an invalid Israeli IBAN" do + let(:iban_code) { "IL92 0108 0000 0009 9999 999" } + it { is_expected.to_not be_valid } + end + context "for a valid Italian IBAN" do let(:iban_code) { "IT40 S054 2811 1010 0000 0123 456" } it { is_expected.to be_valid } end + context "for an invalid Italian IBAN" do + let(:iban_code) { "IT90 S054 2811 1010 0000 0123 456" } + it { is_expected.to_not be_valid } + end + context "for a valid Jordanian IBAN" do let(:iban_code) { "JO94 CBJO 0010 0000 0000 0131 0003 02" } it { is_expected.to be_valid } end + context "for an invalid Jordanian IBAN" do + let(:iban_code) { "JO24 CBJO 0010 0000 0000 0131 0003 02" } + it { is_expected.to_not be_valid } + end + context "for a valid Kuwaiti IBAN" do let(:iban_code) { "KW81 CBKU 0000 0000 0000 1234 5601 01" } it { is_expected.to be_valid } end + context "for an invalid Kuwaiti IBAN" do + let(:iban_code) { "KW91 CBKU 0000 0000 0000 1234 5601 01" } + it { is_expected.to_not be_valid } + end + context "for a valid Latvian IBAN" do let(:iban_code) { "LV80 BANK 0000 4351 9500 1" } it { is_expected.to be_valid } end + context "for an invalid Latvian IBAN" do + let(:iban_code) { "LV90 BANK 0000 4351 9500 1" } + it { is_expected.to_not be_valid } + end + context "for a valid Lebanese IBAN" do let(:iban_code) { "LB62 0999 0000 0001 0019 0122 9114" } it { is_expected.to be_valid } end + context "for an invalid Lebanese IBAN" do + let(:iban_code) { "LB92 0999 0000 0001 0019 0122 9114" } + it { is_expected.to_not be_valid } + end + context "for a valid Liechtensteinian IBAN" do let(:iban_code) { "LI21 0881 0000 2324 013A A" } it { is_expected.to be_valid } end + context "for an invalid Liechtensteinian IBAN" do + let(:iban_code) { "LI91 0881 0000 2324 013A A" } + it { is_expected.to_not be_valid } + end + context "for a valid Lithuanian IBAN" do let(:iban_code) { "LT12 1000 0111 0100 1000" } it { is_expected.to be_valid } end + context "for an invalid Lithuanian IBAN" do + let(:iban_code) { "LT92 1000 0111 0100 1000" } + it { is_expected.to_not be_valid } + end + context "for a valid Luxembourgian IBAN" do let(:iban_code) { "LU28 0019 4006 4475 0000" } it { is_expected.to be_valid } end + context "for an invalid Luxembourgian IBAN" do + let(:iban_code) { "LU98 0019 4006 4475 0000" } + it { is_expected.to_not be_valid } + end + context "for a valid Macedonian IBAN" do let(:iban_code) { "MK072 5012 0000 0589 84" } it { is_expected.to be_valid } end + context "for an invalid Macedonian IBAN" do + let(:iban_code) { "MK972 5012 0000 0589 84" } + it { is_expected.to_not be_valid } + end + context "for a valid Maltese IBAN" do let(:iban_code) { "MT84 MALT 0110 0001 2345 MTLC AST0 01S" } it { is_expected.to be_valid } end + context "for an invalid Maltese IBAN" do + let(:iban_code) { "MT94 MALT 0110 0001 2345 MTLC AST0 01S" } + it { is_expected.to_not be_valid } + end + context "for a valid Maurititanian IBAN" do let(:iban_code) { "MU17 BOMM 0101 1010 3030 0200 000M UR" } it { is_expected.to be_valid } end + context "for an invalid Maurititanian IBAN" do + let(:iban_code) { "MU97 BOMM 0101 1010 3030 0200 000M UR" } + it { is_expected.to_not be_valid } + end + context "for a valid Moldovan IBAN" do let(:iban_code) { "MD24 AG00 0225 1000 1310 4168" } it { is_expected.to be_valid } end + context "for an invalid Moldovan IBAN" do + let(:iban_code) { "MD94 AG00 0225 1000 1310 4168" } + it { is_expected.to_not be_valid } + end + context "for a valid Monocan IBAN" do let(:iban_code) { "MC93 2005 2222 1001 1223 3M44 555" } it { is_expected.to be_valid } end + context "for an invalid Monocan IBAN" do + let(:iban_code) { "MC23 2005 2222 1001 1223 3M44 555" } + it { is_expected.to_not be_valid } + end + context "for a valid Montenegrian IBAN" do let(:iban_code) { "ME25 5050 0001 2345 6789 51" } it { is_expected.to be_valid } end + context "for an invalid Montenegrian IBAN" do + let(:iban_code) { "ME95 5050 0001 2345 6789 51" } + it { is_expected.to_not be_valid } + end + context "for a valid Dutch IBAN" do let(:iban_code) { "NL39 RABO 0300 0652 64" } it { is_expected.to be_valid } end + context "for an invalid Dutch IBAN" do + let(:iban_code) { "NL99 RABO 0300 0652 64" } + it { is_expected.to_not be_valid } + end + context "for a valid Norwegian IBAN" do let(:iban_code) { "NO93 8601 1117 947" } it { is_expected.to be_valid } end + context "for an invalid Norwegian IBAN" do + let(:iban_code) { "NO23 8601 1117 947" } + it { is_expected.to_not be_valid } + end + context "for a valid Pakistani IBAN" do let(:iban_code) { "PK36 SCBL 0000 0011 2345 6702" } it { is_expected.to be_valid } end + context "for an invalid Pakistani IBAN" do + let(:iban_code) { "PK96 SCBL 0000 0011 2345 6702" } + it { is_expected.to_not be_valid } + end + context "for a valid Polish IBAN" do let(:iban_code) { "PL60 1020 1026 0000 0422 7020 1111" } it { is_expected.to be_valid } end + context "for an invalid Polish IBAN" do + let(:iban_code) { "PL90 1020 1026 0000 0422 7020 1111" } + it { is_expected.to_not be_valid } + end + context "for a valid Potuguese IBAN" do let(:iban_code) { "PT50 0002 0123 1234 5678 9015 4" } it { is_expected.to be_valid } end + context "for an invalid Potuguese IBAN" do + let(:iban_code) { "PT90 0002 0123 1234 5678 9015 4" } + it { is_expected.to_not be_valid } + end + context "for a valid Qatari IBAN" do let(:iban_code) { "QA58 DOHB 0000 1234 5678 90AB CDEF G" } it { is_expected.to be_valid } end + context "for an invalid Qatari IBAN" do + let(:iban_code) { "QA98 DOHB 0000 1234 5678 90AB CDEF G" } + it { is_expected.to_not be_valid } + end + context "for a valid Romanian IBAN" do let(:iban_code) { "RO49 AAAA 1B31 0075 9384 0000" } it { is_expected.to be_valid } end + context "for an invalid Romanian IBAN" do + let(:iban_code) { "RO99 AAAA 1B31 0075 9384 0000" } + it { is_expected.to_not be_valid } + end + context "for a valid San Marinian IBAN" do let(:iban_code) { "SM86 U032 2509 8000 0000 0270 100" } it { is_expected.to be_valid } end + context "for an invalid San Marinian IBAN" do + let(:iban_code) { "SM96 U032 2509 8000 0000 0270 100" } + it { is_expected.to_not be_valid } + end + context "for a valid Saudi IBAN" do let(:iban_code) { "SA03 8000 0000 6080 1016 7519" } it { is_expected.to be_valid } end + context "for an invalid Saudi IBAN" do + let(:iban_code) { "SA93 8000 0000 6080 1016 7519" } + it { is_expected.to_not be_valid } + end + context "for a valid Serbian IBAN" do let(:iban_code) { "RS35 2600 0560 1001 6113 79" } it { is_expected.to be_valid } end + context "for an invalid Serbian IBAN" do + let(:iban_code) { "RS95 2600 0560 1001 6113 79" } + it { is_expected.to_not be_valid } + end + context "for a valid Slovakian IBAN" do let(:iban_code) { "SK31 1200 0000 1987 4263 7541" } it { is_expected.to be_valid } end + context "for an invalid Slovakian IBAN" do + let(:iban_code) { "SK91 1200 0000 1987 4263 7541" } + it { is_expected.to_not be_valid } + end + context "for a valid Slovenian IBAN" do let(:iban_code) { "SI56 1910 0000 0123 438" } it { is_expected.to be_valid } end + context "for an invalid Slovenian IBAN" do + let(:iban_code) { "SI96 1910 0000 0123 438" } + it { is_expected.to_not be_valid } + end + context "for a valid Spanish IBAN" do let(:iban_code) { "ES80 2310 0001 1800 0001 2345" } it { is_expected.to be_valid } end + context "for an invalid Spanish IBAN" do + let(:iban_code) { "ES90 2310 0001 1800 0001 2345" } + it { is_expected.to_not be_valid } + end + context "for a valid Swedish IBAN" do let(:iban_code) { "SE35 5000 0000 0549 1000 0003" } it { is_expected.to be_valid } end + context "for an invalid Swedish IBAN" do + let(:iban_code) { "SE95 5000 0000 0549 1000 0003" } + it { is_expected.to_not be_valid } + end + context "for a valid Swiss IBAN" do let(:iban_code) { "CH93 0076 2011 6238 5295 7" } it { is_expected.to be_valid } end + context "for an invalid Swiss IBAN" do + let(:iban_code) { "CH23 0076 2011 6238 5295 7" } + it { is_expected.to_not be_valid } + end + context "for a valid Tunisian IBAN" do let(:iban_code) { "TN59 1000 6035 1835 9847 8831" } it { is_expected.to be_valid } end + context "for an invalid Tunisian IBAN" do + let(:iban_code) { "TN99 1000 6035 1835 9847 8831" } + it { is_expected.to_not be_valid } + end + context "for a valid Turkish IBAN" do let(:iban_code) { "TR33 0006 1005 1978 6457 8413 26" } it { is_expected.to be_valid } end + context "for an invalid Turkish IBAN" do + let(:iban_code) { "TR93 0006 1005 1978 6457 8413 26" } + it { is_expected.to_not be_valid } + end + context "for a valid UAE IBAN" do let(:iban_code) { "AE07 0331 2345 6789 0123 456" } it { is_expected.to be_valid } end + context "for an invalid UAE IBAN" do + let(:iban_code) { "AE97 0331 2345 6789 0123 456" } + it { is_expected.to_not be_valid } + end + context "for a valid UK IBAN" do let(:iban_code) { "GB82 WEST 1234 5698 7654 32" } it { is_expected.to be_valid } end + + context "for an invalid UK IBAN" do + let(:iban_code) { "GB92 WEST 1234 5698 7654 32" } + it { is_expected.to_not be_valid } + end end describe "#local_check_digits" do