sepafm 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +14 -30
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +15 -0
  5. data/Gemfile +1 -1
  6. data/LICENSE +16 -4
  7. data/README.md +180 -319
  8. data/Rakefile +7 -2
  9. data/lib/sepa/application_request.rb +100 -131
  10. data/lib/sepa/application_response.rb +28 -84
  11. data/lib/sepa/attribute_checks.rb +169 -0
  12. data/lib/sepa/banks/danske/danske_response.rb +19 -0
  13. data/lib/sepa/banks/danske/soap_danske.rb +132 -0
  14. data/lib/sepa/banks/nordea/nordea_response.rb +20 -0
  15. data/lib/sepa/banks/nordea/soap_nordea.rb +51 -0
  16. data/lib/sepa/client.rb +72 -60
  17. data/lib/sepa/error_messages.rb +15 -0
  18. data/lib/sepa/response.rb +88 -85
  19. data/lib/sepa/soap_builder.rb +51 -341
  20. data/lib/sepa/utilities.rb +132 -0
  21. data/lib/sepa/version.rb +1 -1
  22. data/lib/sepa/xml_schemas/PKIFactory.xsd +334 -0
  23. data/lib/sepa/xml_schemas/xml_id.xsd +9 -0
  24. data/lib/sepa/xml_templates/application_request/create_certificate.xml +15 -10
  25. data/lib/sepa/xml_templates/application_request/danske_get_bank_certificate.xml +13 -9
  26. data/lib/sepa/xml_templates/application_request/download_file.xml +32 -30
  27. data/lib/sepa/xml_templates/application_request/download_file_list.xml +29 -27
  28. data/lib/sepa/xml_templates/application_request/encrypted_request.xml +22 -0
  29. data/lib/sepa/xml_templates/application_request/get_certificate.xml +9 -8
  30. data/lib/sepa/xml_templates/application_request/get_user_info.xml +26 -24
  31. data/lib/sepa/xml_templates/application_request/upload_file.xml +29 -27
  32. data/lib/sepa/xml_templates/soap/create_certificate.xml +17 -15
  33. data/lib/sepa/xml_templates/soap/danske_get_bank_certificate.xml +15 -13
  34. data/lib/sepa/xml_templates/soap/download_file.xml +19 -15
  35. data/lib/sepa/xml_templates/soap/download_file_list.xml +19 -15
  36. data/lib/sepa/xml_templates/soap/get_certificate.xml +2 -1
  37. data/lib/sepa/xml_templates/soap/get_user_info.xml +19 -15
  38. data/lib/sepa/xml_templates/soap/header.xml +48 -37
  39. data/lib/sepa/xml_templates/soap/upload_file.xml +19 -15
  40. data/lib/sepafm.rb +20 -18
  41. data/{sepa.gemspec → sepafm.gemspec} +10 -9
  42. data/test/sepa/banks/danske/danske_cert_response_test.rb +52 -0
  43. data/test/sepa/banks/danske/danske_cert_soap_builder_test.rb +100 -0
  44. data/test/sepa/banks/danske/danske_generic_soap_builder_test.rb +278 -0
  45. data/test/sepa/banks/danske/danske_get_bank_cert_test.rb +111 -0
  46. data/{lib/sepa/danske_testing/keys/danske_encryption.crt → test/sepa/banks/danske/keys/bank_encryption_cert.pem} +0 -0
  47. data/test/sepa/{danske_test_keys/danskeroot.pem → banks/danske/keys/bank_root_cert.pem} +1 -1
  48. data/test/sepa/banks/danske/keys/bank_signing_cert.pem +24 -0
  49. data/test/sepa/banks/danske/keys/danske_encryption.crt +24 -0
  50. data/test/sepa/banks/danske/keys/enc_private_key.pem +27 -0
  51. data/test/sepa/{danske_test_keys → banks/danske/keys}/encryption_pkcs.csr +0 -0
  52. data/test/sepa/banks/danske/keys/own_enc_cert.pem +21 -0
  53. data/test/sepa/banks/danske/keys/own_signing_cert.pem +22 -0
  54. data/test/sepa/{danske_test_keys → banks/danske/keys}/signing_key.pem +0 -0
  55. data/test/sepa/{danske_test_keys → banks/danske/keys}/signing_pkcs.csr +0 -0
  56. data/test/sepa/banks/danske/keys/signing_private_key.pem +27 -0
  57. data/test/sepa/banks/danske/responses/create_cert.xml +38 -0
  58. data/test/sepa/banks/danske/responses/get_bank_cert.xml +37 -0
  59. data/{lib/sepa/nordea_testing → test/sepa/banks/nordea}/keys/nordea.crt +0 -4
  60. data/test/sepa/{nordea_test_keys → banks/nordea/keys}/nordea.key +0 -3
  61. data/test/sepa/{nordea_test_keys → banks/nordea/keys}/root_cert.cer +0 -0
  62. data/test/sepa/{nordea_test_keys → banks/nordea/keys}/testcert.csr +0 -0
  63. data/test/sepa/banks/nordea/nordea_application_request_test.rb +252 -0
  64. data/test/sepa/{application_response_test.rb → banks/nordea/nordea_application_response_test.rb} +40 -46
  65. data/test/sepa/banks/nordea/nordea_cert_application_request_test.rb +72 -0
  66. data/test/sepa/banks/nordea/nordea_cert_request_soap_builder_test.rb +65 -0
  67. data/test/sepa/banks/nordea/nordea_generic_soap_builder_test.rb +280 -0
  68. data/test/sepa/banks/nordea/nordea_response_test.rb +116 -0
  69. data/test/sepa/banks/nordea/responses/df_ktl.xml +45 -0
  70. data/test/sepa/{test_files/test_responses/df.xml → banks/nordea/responses/df_tito.xml} +1 -1
  71. data/test/sepa/{test_files/test_responses → banks/nordea/responses}/dfl.xml +0 -0
  72. data/test/sepa/banks/nordea/responses/gbc.xml +15 -0
  73. data/test/sepa/banks/nordea/responses/gc.xml +49 -0
  74. data/test/sepa/{test_files/test_responses → banks/nordea/responses}/gui.xml +0 -0
  75. data/test/sepa/{test_files/test_responses → banks/nordea/responses}/uf.xml +0 -0
  76. data/test/sepa/client_test.rb +156 -302
  77. data/test/sepa/fixtures.rb +214 -0
  78. data/test/sepa/sepa_test.rb +3 -13
  79. data/test/sepa/test_files/{invalid.wsdl → invalid_wsdl.wsdl} +0 -0
  80. data/test/test_helper.rb +29 -3
  81. metadata +140 -116
  82. data/lib/danske_get_bank_certificate_test.rb +0 -15
  83. data/lib/sepa/custom_exceptions.rb +0 -2
  84. data/lib/sepa/filedescriptor.rb +0 -7
  85. data/lib/sepa/filetypeservice.rb +0 -6
  86. data/lib/sepa/nordea_testing/keys/CSR.csr +0 -0
  87. data/lib/sepa/nordea_testing/keys/nordea.key +0 -19
  88. data/lib/sepa/nordea_testing/response/content_053.xml +0 -998
  89. data/lib/sepa/nordea_testing/response/content_054.xml +0 -1
  90. data/lib/sepa/nordea_testing/response/download_file_response.xml +0 -14
  91. data/lib/sepa/nordea_testing/response/download_filelist_response.xml +0 -14
  92. data/lib/sepa/nordea_testing/response/get_user_info_response.xml +0 -14
  93. data/lib/sepa/nordea_testing/response/upload_file_response.xml +0 -14
  94. data/lib/sepa/payload.rb +0 -109
  95. data/lib/sepa/payment.rb +0 -97
  96. data/lib/sepa/sender_verifier.rb +0 -15
  97. data/lib/sepa/signature.rb +0 -7
  98. data/lib/sepa/soap_danske.rb +0 -47
  99. data/lib/sepa/soap_nordea.rb +0 -68
  100. data/lib/sepa/transaction.rb +0 -178
  101. data/lib/sepa/userfiletype.rb +0 -16
  102. data/lib/sepa/xml_parser.rb +0 -291
  103. data/lib/sepa_client_testing_mika.rb +0 -32
  104. data/lib/sepa_client_testing_tiere.rb +0 -257
  105. data/test/sepa/application_request_test.rb +0 -423
  106. data/test/sepa/cert_application_request_test.rb +0 -99
  107. data/test/sepa/nordea_cert_request_soap_builder_test.rb +0 -112
  108. data/test/sepa/nordea_generic_soap_builder_test.rb +0 -427
  109. data/test/sepa/nordea_test_keys/nordea.crt +0 -27
  110. data/test/sepa/payload_test.rb +0 -297
  111. data/test/sepa/payment_test.rb +0 -198
  112. data/test/sepa/response_test.rb +0 -269
  113. data/test/sepa/transaction_test.rb +0 -362
  114. data/test/sepa/user_file_type_test.rb +0 -21
  115. data/test/sepa/xml_parser_test.rb +0 -73
@@ -1,297 +0,0 @@
1
- require File.expand_path('../../test_helper.rb', __FILE__)
2
-
3
- class TestPayload < MiniTest::Test
4
- def setup
5
- @schemas_path = File.expand_path('../../../lib/sepa/xml_schemas', __FILE__)
6
-
7
- @invoice_bundle = []
8
-
9
- invoice_1 = {
10
- type: 'CINV',
11
- amount: '700',
12
- currency: 'EUR',
13
- invoice_number: '123456'
14
- }
15
-
16
- invoice_2 = {
17
- type: 'CINV',
18
- amount: '300',
19
- currency: 'EUR',
20
- reference: '123456789',
21
- }
22
-
23
- invoice_3 = {
24
- type: 'CREN',
25
- amount: '-100',
26
- currency: 'EUR',
27
- invoice_number: '654321'
28
- }
29
-
30
- invoice_4 = {
31
- type: 'CREN',
32
- amount: '-500',
33
- currency: 'EUR',
34
- reference: '987654321'
35
- }
36
-
37
- @invoice_bundle.push(invoice_1)
38
- @invoice_bundle.push(invoice_2)
39
- @invoice_bundle.push(invoice_3)
40
- @invoice_bundle.push(invoice_4)
41
-
42
- trans_1_params = {
43
- instruction_id: '70CEF29BEBA8396A1F806005EDA51DEE4CE',
44
- end_to_end_id: '629CADFDAD5246AD915BA24A3C8E9FC3313',
45
- amount: '30.75',
46
- currency: 'EUR',
47
- bic: 'NDEAFIHH',
48
- name: 'Testi Saaja Oy',
49
- address: 'Kokeilukatu 66',
50
- country: 'FI',
51
- postcode: '00200',
52
- town: 'Helsinki',
53
- iban: 'FI7429501800000014',
54
- reference: '00000000000000001245',
55
- message: 'Maksu'
56
- }
57
-
58
- trans_2_params = {
59
- instruction_id: 'A552D3EBB207B4AC17DF97C7D548A0571B0',
60
- end_to_end_id: 'CDE1206C8745D6FBDCD2BBB02DB6CB6D3BE',
61
- amount: '1075.20',
62
- currency: 'EUR',
63
- bic: 'NDEAFIHH',
64
- name: 'Testing Company',
65
- address: 'Tynnyrikatu 56',
66
- country: 'FI',
67
- postcode: '00600',
68
- town: 'Helsinki',
69
- iban: 'FI7429501800000014',
70
- reference: '000000000000000034795',
71
- message: 'Siirto',
72
- invoice_bundle: @invoice_bundle
73
- }
74
-
75
- trans_3_params = {
76
- instruction_id: '44DB2850ABDFBEF2A32D0EE511BE5AB0B79',
77
- end_to_end_id: 'A107CF858A22116D0C8EC1E78B078794B8C',
78
- amount: '10000',
79
- currency: 'EUR',
80
- bic: 'NDEAFIHH',
81
- name: 'Best Company Ever',
82
- address: 'Banaanikuja 66',
83
- country: 'FI',
84
- postcode: '00900',
85
- town: 'Helsinki',
86
- iban: 'FI7429501800000014',
87
- reference: '000000000000000013247',
88
- message: 'Valuutan siirto toiselle tilille'
89
- }
90
-
91
- trans_4_params = {
92
- instruction_id: '16A0C311AF72F3F5E8B6704EB3B6086047C',
93
- end_to_end_id: 'B10CE2EC71DB76114DDA68C9DAAA77A59DB',
94
- amount: '12',
95
- currency: 'EUR',
96
- bic: 'NDEAFIHH',
97
- name: 'Testi Saaja Oy',
98
- address: 'Kokeilukatu 66',
99
- country: 'FI',
100
- postcode: '00200',
101
- town: 'Helsinki',
102
- iban: 'FI7429501800000014',
103
- reference: '00000000000000001245',
104
- message: 'Palkka heinakuulta',
105
- salary: true,
106
- social_security_number: '112233-0000'
107
- }
108
-
109
- trans_5_params = {
110
- instruction_id: 'E0C01A8D65EA0BAB7CF1D4337FBCC3D33D7',
111
- end_to_end_id: 'B10CE2EC71DB76114DDA68C9DAAA77A59DB',
112
- amount: '99.20',
113
- currency: 'EUR',
114
- bic: 'NDEAFIHH',
115
- name: 'Testing Company',
116
- address: 'Tynnyrikatu 56',
117
- country: 'FI',
118
- postcode: '00600',
119
- town: 'Helsinki',
120
- iban: 'FI7429501800000014',
121
- reference: '000000000000000034795',
122
- message: 'Elake',
123
- pension: true
124
- }
125
-
126
- trans_6_params = {
127
- instruction_id: 'FD19CD1844B20B0E65E66EA307668B1C3F8',
128
- end_to_end_id: 'CE9FF7E7CE5961AA1207C828DBFE467182F',
129
- amount: '15000',
130
- currency: 'EUR',
131
- bic: 'NDEAFIHH',
132
- name: 'Best Company Ever',
133
- address: 'Banaanikuja 66',
134
- country: 'FI',
135
- postcode: '00900',
136
- town: 'Helsinki',
137
- iban: 'FI7429501800000014',
138
- reference: '000000000000000013247',
139
- message: 'Palkka ajalta 15.6.2013 - 30.6.2013',
140
- salary: true,
141
- social_security_number: '112233-0001'
142
- }
143
-
144
- @debtor = {
145
- name: 'Testi Maksaja Oy',
146
- address: 'Testing Street 12',
147
- country: 'FI',
148
- postcode: '00100',
149
- town: 'Helsinki',
150
- customer_id: '0987654321',
151
- iban: 'FI4819503000000010',
152
- bic: 'NDEAFIHH'
153
- }
154
-
155
- payment_1_transactions = []
156
- payment_2_transactions = []
157
-
158
- payment_1_transactions.push(Sepa::Transaction.new(trans_1_params))
159
- payment_1_transactions.push(Sepa::Transaction.new(trans_2_params))
160
- payment_1_transactions.push(Sepa::Transaction.new(trans_3_params))
161
-
162
- payment_2_transactions.push(Sepa::Transaction.new(trans_4_params))
163
- payment_2_transactions.push(Sepa::Transaction.new(trans_5_params))
164
- payment_2_transactions.push(Sepa::Transaction.new(trans_6_params))
165
-
166
- payment_1_params = {
167
- payment_info_id: 'F56D46DDA136A981F58C05999479E768C92',
168
- execution_date: '2013-08-10',
169
- transactions: payment_1_transactions
170
- }
171
-
172
- payment_2_params = {
173
- payment_info_id: 'B60EECC432C306876FE3E23999DF7F43254',
174
- execution_date: '2013-08-15',
175
- salary_or_pension: true,
176
- transactions: payment_2_transactions
177
- }
178
-
179
- @payments = []
180
-
181
- @payments.push(Sepa::Payment.new(@debtor, payment_1_params))
182
- @payments.push(Sepa::Payment.new(@debtor, payment_2_params))
183
-
184
- @payload = Sepa::Payload.new(@debtor, @payments)
185
- @pay_noko = Nokogiri::XML(@payload.to_xml)
186
-
187
- @xmlns = 'urn:iso:std:iso:20022:tech:xsd:pain.001.001.02'
188
- end
189
-
190
- def test_should_initialize_with_proper_params
191
- assert Sepa::Payload.new(@debtor, @payments)
192
- end
193
-
194
- def test_validates_against_schema
195
- xsd = Nokogiri::XML::Schema(
196
- File.read("#{@schemas_path}/pain.001.001.02.xsd")
197
- )
198
- doc = Nokogiri::XML(@payload.to_xml)
199
-
200
- assert xsd.valid?(doc)
201
- end
202
-
203
- def test_debtor_name_is_added_correctly_to_group_header
204
- assert_equal @debtor[:name],
205
- @pay_noko.at("//xmlns:InitgPty/xmlns:Nm", 'xmlns' => @xmlns).content
206
- end
207
-
208
- def test_debtors_first_address_line_is_added_correctly_to_group_header
209
- assert_equal @debtor[:address],
210
- @pay_noko.at(
211
- "//xmlns:InitgPty/xmlns:PstlAdr/xmlns:AdrLine[1]", 'xmlns' => @xmlns
212
- ).content
213
- end
214
-
215
- def test_debtors_second_address_line_is_added_correctly_to_group_header
216
- assert_equal "#{@debtor[:country]}-#{@debtor[:postcode]}",
217
- @pay_noko.at(
218
- "//xmlns:InitgPty/xmlns:PstlAdr/xmlns:AdrLine[2]", 'xmlns' => @xmlns
219
- ).content
220
- end
221
-
222
- def test_debtors_street_name_is_added_correctly_to_group_header
223
- assert_equal @debtor[:address],
224
- @pay_noko.at(
225
- "//xmlns:InitgPty/xmlns:PstlAdr/xmlns:StrtNm", 'xmlns' => @xmlns
226
- ).content
227
- end
228
-
229
- def test_debtors_postcode_is_added_correctly_to_group_header
230
- assert_equal "#{@debtor[:country]}-#{@debtor[:postcode]}",
231
- @pay_noko.at(
232
- "//xmlns:InitgPty/xmlns:PstlAdr/xmlns:PstCd", 'xmlns' => @xmlns
233
- ).content
234
- end
235
-
236
- def test_debtors_town_is_added_correctly_to_group_header
237
- assert_equal @debtor[:town],
238
- @pay_noko.at(
239
- "//xmlns:InitgPty/xmlns:PstlAdr/xmlns:TwnNm", 'xmlns' => @xmlns
240
- ).content
241
- end
242
-
243
- def test_debtors_country_is_added_correctly_to_group_header
244
- assert_equal @debtor[:country],
245
- @pay_noko.at(
246
- "//xmlns:InitgPty/xmlns:PstlAdr/xmlns:Ctry", 'xmlns' => @xmlns
247
- ).content
248
- end
249
-
250
- def test_nr_of_transactions_is_added_correctly_to_group_header
251
- assert_equal '6',
252
- @pay_noko.at(
253
- "//xmlns:GrpHdr/xmlns:NbOfTxs", 'xmlns' => @xmlns
254
- ).content
255
- end
256
-
257
- def test_should_raise_schema_error_if_doesnt_validate_against_schema
258
- @debtor[:name] = 'a'*71
259
- payload = Sepa::Payload.new(@debtor, @payments)
260
- refute payload.valid?, payload.errors.join("\n")
261
- end
262
-
263
- def test_raises_key_error_if_debtor_name_missing
264
- @debtor.delete(:name)
265
- assert_raises(KeyError) { Sepa::Payload.new(@debtor, @payments) }
266
- end
267
-
268
- def test_raises_key_error_if_debtor_address_missing
269
- @debtor.delete(:address)
270
- assert_raises(KeyError) { Sepa::Payload.new(@debtor, @payments) }
271
- end
272
-
273
- def test_raises_key_error_if_debtor_country_missing
274
- @debtor.delete(:country)
275
- assert_raises(KeyError) { Sepa::Payload.new(@debtor, @payments) }
276
- end
277
-
278
- def test_raises_key_error_if_debtor_postcode_missing
279
- @debtor.delete(:postcode)
280
- assert_raises(KeyError) { Sepa::Payload.new(@debtor, @payments) }
281
- end
282
-
283
- def test_raises_key_error_if_debtor_town_missing
284
- @debtor.delete(:town)
285
- assert_raises(KeyError) { Sepa::Payload.new(@debtor, @payments) }
286
- end
287
-
288
- def test_raises_key_error_if_debtor_customer_id_missing
289
- @debtor.delete(:customer_id)
290
- assert_raises(KeyError) { Sepa::Payload.new(@debtor, @payments) }
291
- end
292
-
293
- def test_raises_key_error_if_payments_missing
294
- @payments = nil
295
- assert_raises(KeyError) { Sepa::Payload.new(@debtor, @payments) }
296
- end
297
- end
@@ -1,198 +0,0 @@
1
- require File.expand_path('../../test_helper.rb', __FILE__)
2
-
3
- class TestPayment < MiniTest::Test
4
- def setup
5
- trans_1_params = {
6
- instruction_id: '70CEF29BEBA8396A1F806005EDA51DEE4CE',
7
- end_to_end_id: '629CADFDAD5246AD915BA24A3C8E9FC3313',
8
- amount: '30.75',
9
- currency: 'EUR',
10
- bic: 'NDEAFIHH',
11
- name: 'Testi Saaja Oy',
12
- address: 'Kokeilukatu 66',
13
- country: 'FI',
14
- postcode: '00200',
15
- town: 'Helsinki',
16
- iban: 'FI7429501800000014',
17
- reference: '00000000000000001245',
18
- message: 'Maksu'
19
- }
20
-
21
- trans_2_params = {
22
- instruction_id: 'A552D3EBB207B4AC17DF97C7D548A0571B0',
23
- end_to_end_id: 'CDE1206C8745D6FBDCD2BBB02DB6CB6D3BE',
24
- amount: '1075.20',
25
- currency: 'EUR',
26
- bic: 'NDEAFIHH',
27
- name: 'Testing Company',
28
- address: 'Tynnyrikatu 56',
29
- country: 'FI',
30
- postcode: '00600',
31
- town: 'Helsinki',
32
- iban: 'FI7429501800000014',
33
- reference: '000000000000000034795',
34
- message: 'Siirto'
35
- }
36
-
37
- trans_3_params = {
38
- instruction_id: '44DB2850ABDFBEF2A32D0EE511BE5AB0B79',
39
- end_to_end_id: 'A107CF858A22116D0C8EC1E78B078794B8C',
40
- amount: '10000',
41
- currency: 'EUR',
42
- bic: 'NDEAFIHH',
43
- name: 'Best Company Ever',
44
- address: 'Banaanikuja 66',
45
- country: 'FI',
46
- postcode: '00900',
47
- town: 'Helsinki',
48
- iban: 'FI7429501800000014',
49
- reference: '000000000000000013247',
50
- message: 'Valuutan siirto toiselle tilille'
51
- }
52
-
53
- @debtor = {
54
- name: 'Testi Maksaja Oy',
55
- address: 'Testing Street 12',
56
- country: 'Finland',
57
- postcode: '00100',
58
- town: 'Helsinki',
59
- customer_id: '0987654321',
60
- iban: 'FI4819503000000010',
61
- bic: 'NDEAFIHH'
62
- }
63
-
64
- transactions = []
65
-
66
- transactions.push(Sepa::Transaction.new(trans_1_params))
67
- transactions.push(Sepa::Transaction.new(trans_2_params))
68
- transactions.push(Sepa::Transaction.new(trans_3_params))
69
-
70
- @params = {
71
- payment_info_id: 'F56D46DDA136A981F58C05999479E768C92',
72
- execution_date: '2013-08-10',
73
- transactions: transactions
74
- }
75
-
76
- @payment = Sepa::Payment.new(@debtor, @params)
77
-
78
- @payment_node = @payment.to_node
79
- end
80
-
81
- def test_should_initialize_with_proper_params
82
- assert Sepa::Payment.new(@debtor, @params)
83
- end
84
-
85
- def test_payment_info_id_is_set_correctly
86
- assert_equal @params[:payment_info_id],
87
- @payment_node.at('/PmtInf/PmtInfId').content
88
- end
89
-
90
- def test_execution_date_is_set_correctly
91
- assert_equal @params[:execution_date],
92
- @payment_node.at('/PmtInf/ReqdExctnDt').content
93
- end
94
-
95
- def test_debtor_name_is_set_correctly
96
- assert_equal @debtor[:name],
97
- @payment_node.at('/PmtInf/Dbtr/Nm').content
98
- end
99
-
100
- def test_debtors_first_address_line_is_set_correctly
101
- assert_equal @debtor[:address],
102
- @payment_node.at('/PmtInf/Dbtr/PstlAdr/AdrLine[1]').content
103
- end
104
-
105
- def test_debtors_second_address_line_is_set_correctly
106
- assert_equal "#{@debtor[:country]}-#{@debtor[:postcode]} #{@debtor[:town]}",
107
- @payment_node.at('/PmtInf/Dbtr/PstlAdr/AdrLine[2]').content
108
- end
109
-
110
- def test_debtors_country_is_set_correctly
111
- assert_equal @debtor[:country],
112
- @payment_node.at('/PmtInf/Dbtr/PstlAdr/Ctry').content
113
- end
114
-
115
- def test_debtors_customer_id_is_set_when_present
116
- assert_equal @debtor[:customer_id],
117
- @payment_node.at('/PmtInf/Dbtr/Id/OrgId').content
118
- end
119
-
120
- def test_debtors_iban_is_set_correctly
121
- assert_equal @debtor[:iban],
122
- @payment_node.at('/PmtInf/DbtrAcct/Id/IBAN').content
123
- end
124
-
125
- def test_debtors_bic_is_set_correctly
126
- assert_equal @debtor[:bic],
127
- @payment_node.at('/PmtInf/DbtrAgt/FinInstnId/BIC').content
128
- end
129
-
130
- def test_nr_of_transaction_elements_matches_the_nr_in_hash
131
- assert_equal @params[:transactions].count,
132
- @payment_node.xpath('/PmtInf/CdtTrfTxInf').count
133
- end
134
-
135
- def test_category_purpose_is_set_when_salary_or_pension
136
- @params[:salary_or_pension] = true
137
- payment = Sepa::Payment.new(@debtor, @params)
138
- payment_node = payment.to_node
139
-
140
- assert_equal 'SALA',
141
- payment_node.at('/PmtInf/PmtTpInf/CtgyPurp').content
142
- end
143
-
144
- def test_raises_key_error_if_payment_info_id_missing
145
- @params.delete(:payment_info_id)
146
- assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
147
- end
148
-
149
- def test_raises_key_error_if_execution_date_missing
150
- @params.delete(:execution_date)
151
- assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
152
- end
153
-
154
- def test_raises_key_error_if_debtor_name_missing
155
- @debtor.delete(:name)
156
- assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
157
- end
158
-
159
- def test_raises_key_error_if_debtor_address_missing
160
- @debtor.delete(:address)
161
- assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
162
- end
163
-
164
- def test_raises_key_error_if_debtor_country_missing
165
- @debtor.delete(:country)
166
- assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
167
- end
168
-
169
- def test_raises_key_error_if_debtor_postcode_missing
170
- @debtor.delete(:postcode)
171
- assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
172
- end
173
-
174
- def test_raises_key_error_if_debtor_town_missing
175
- @debtor.delete(:town)
176
- assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
177
- end
178
-
179
- def test_raises_key_error_if_debtor_customer_id_missing
180
- @debtor.delete(:customer_id)
181
- assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
182
- end
183
-
184
- def test_raises_key_error_if_debtor_iban_missing
185
- @debtor.delete(:iban)
186
- assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
187
- end
188
-
189
- def test_raises_key_error_if_debtor_bic_missing
190
- @debtor.delete(:bic)
191
- assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
192
- end
193
-
194
- def test_raises_key_error_if_transactions_missing
195
- @params.delete(:transactions)
196
- assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
197
- end
198
- end