epics 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +6 -0
  5. data/CONTRIBUTING.md +5 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +165 -0
  8. data/README.md +197 -0
  9. data/Rakefile +7 -0
  10. data/epics.gemspec +50 -0
  11. data/lib/epics.rb +35 -0
  12. data/lib/epics/cct.rb +42 -0
  13. data/lib/epics/cd1.rb +42 -0
  14. data/lib/epics/cdd.rb +42 -0
  15. data/lib/epics/client.rb +216 -0
  16. data/lib/epics/error.rb +324 -0
  17. data/lib/epics/generic_request.rb +99 -0
  18. data/lib/epics/generic_upload_request.rb +89 -0
  19. data/lib/epics/haa.rb +40 -0
  20. data/lib/epics/hia.rb +78 -0
  21. data/lib/epics/hpb.rb +29 -0
  22. data/lib/epics/hpd.rb +40 -0
  23. data/lib/epics/htd.rb +40 -0
  24. data/lib/epics/ini.rb +69 -0
  25. data/lib/epics/key.rb +79 -0
  26. data/lib/epics/mgf.rb +41 -0
  27. data/lib/epics/middleware/parse_ebics.rb +15 -0
  28. data/lib/epics/middleware/xmlsig.rb +18 -0
  29. data/lib/epics/ptk.rb +52 -0
  30. data/lib/epics/response.rb +93 -0
  31. data/lib/epics/signer.rb +40 -0
  32. data/lib/epics/sta.rb +52 -0
  33. data/lib/epics/version.rb +3 -0
  34. data/lib/letter/ini.erb +231 -0
  35. data/spec/client_spec.rb +98 -0
  36. data/spec/fixtures/a006.pem +28 -0
  37. data/spec/fixtures/bank_e.pem +6 -0
  38. data/spec/fixtures/e002.pem +28 -0
  39. data/spec/fixtures/x002.pem +28 -0
  40. data/spec/fixtures/xml/cd1.xml +87 -0
  41. data/spec/fixtures/xml/ebics_business_nok.xml +21 -0
  42. data/spec/fixtures/xml/ebics_technical_nok.xml +12 -0
  43. data/spec/fixtures/xml/hia.xml +2 -0
  44. data/spec/fixtures/xml/hia_request_order_data.xml +2 -0
  45. data/spec/fixtures/xml/hpb.xml +34 -0
  46. data/spec/fixtures/xml/hpb_request.xml +34 -0
  47. data/spec/fixtures/xml/hpb_response.xml +21 -0
  48. data/spec/fixtures/xml/hpb_response_order.xml +22 -0
  49. data/spec/fixtures/xml/htd_order_data.xml +153 -0
  50. data/spec/fixtures/xml/ini.xml +2 -0
  51. data/spec/fixtures/xml/signature_pub_key_order_data.xml +2 -0
  52. data/spec/fixtures/xml/upload_init_response.xml +31 -0
  53. data/spec/hpb_spec.rb +15 -0
  54. data/spec/key_spec.rb +35 -0
  55. data/spec/mgf_spec.rb +36 -0
  56. data/spec/middleware/parse_ebics_spec.rb +18 -0
  57. data/spec/orders/cct_spec.rb +17 -0
  58. data/spec/orders/cd1_spec.rb +17 -0
  59. data/spec/orders/cdd_spec.rb +17 -0
  60. data/spec/orders/haa_spec.rb +11 -0
  61. data/spec/orders/hia_spec.rb +34 -0
  62. data/spec/orders/hpb_spec.rb +11 -0
  63. data/spec/orders/hpd_spec.rb +11 -0
  64. data/spec/orders/htd_spec.rb +11 -0
  65. data/spec/orders/ini_spec.rb +36 -0
  66. data/spec/orders/ptk_spec.rb +11 -0
  67. data/spec/orders/sta_spec.rb +11 -0
  68. data/spec/response_spec.rb +34 -0
  69. data/spec/signer_spec.rb +34 -0
  70. data/spec/spec_helper.rb +43 -0
  71. data/spec/support/ebics_matcher.rb +22 -0
  72. data/spec/xsd/ebics_H004.xsd +11 -0
  73. data/spec/xsd/ebics_hev.xsd +135 -0
  74. data/spec/xsd/ebics_keymgmt_request_H004.xsd +543 -0
  75. data/spec/xsd/ebics_keymgmt_response_H004.xsd +137 -0
  76. data/spec/xsd/ebics_orders_H004.xsd +1892 -0
  77. data/spec/xsd/ebics_request_H004.xsd +355 -0
  78. data/spec/xsd/ebics_response_H004.xsd +166 -0
  79. data/spec/xsd/ebics_signature.xsd +217 -0
  80. data/spec/xsd/ebics_types_H004.xsd +2426 -0
  81. data/spec/xsd/xmldsig-core-schema.xsd +318 -0
  82. metadata +319 -0
@@ -0,0 +1,153 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <HTDResponseOrderData xmlns="urn:org:ebics:H004" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:org:ebics:H004 http://www.ebics.org/H004/ebics_orders_H004.xsd">
3
+ <PartnerInfo>
4
+ <AddressInfo>
5
+ <Name>Railslove GmbH</Name>
6
+ <Country>Deutschland</Country>
7
+ </AddressInfo>
8
+ <BankInfo>
9
+ <HostID>SIZBN001</HostID>
10
+ </BankInfo>
11
+ <AccountInfo ID="1">
12
+ <AccountNumber international="false">1929807319</AccountNumber>
13
+ <AccountNumber international="true">DE51370501981929807319</AccountNumber>
14
+ <BankCode international="false" Prefix="DE">37050198</BankCode>
15
+ <BankCode international="true">COLSDE33XXX</BankCode>
16
+ </AccountInfo>
17
+ <OrderInfo>
18
+ <OrderType>HTD</OrderType>
19
+ <TransferType>Download</TransferType>
20
+ <Description>Kunden- und Teilnehmerdaten abholen</Description>
21
+ </OrderInfo>
22
+ <OrderInfo>
23
+ <OrderType>STA</OrderType>
24
+ <TransferType>Download</TransferType>
25
+ <Description>Abholen SWIFT-Tagesauszüge</Description>
26
+ </OrderInfo>
27
+ <OrderInfo>
28
+ <OrderType>PTK</OrderType>
29
+ <TransferType>Download</TransferType>
30
+ <Description>Abholen Kundenprotokoll</Description>
31
+ </OrderInfo>
32
+ <OrderInfo>
33
+ <OrderType>HPD</OrderType>
34
+ <TransferType>Download</TransferType>
35
+ <Description>Bankparameter abholen</Description>
36
+ </OrderInfo>
37
+ <OrderInfo>
38
+ <OrderType>HAC</OrderType>
39
+ <TransferType>Download</TransferType>
40
+ <Description>HAC</Description>
41
+ </OrderInfo>
42
+ <OrderInfo>
43
+ <OrderType>HAA</OrderType>
44
+ <TransferType>Download</TransferType>
45
+ <Description>Abrufbare Auftragsarten abholen</Description>
46
+ </OrderInfo>
47
+ <OrderInfo>
48
+ <OrderType>HVT</OrderType>
49
+ <TransferType>Download</TransferType>
50
+ <Description>VEU-Transaktionsdetails abrufen</Description>
51
+ </OrderInfo>
52
+ <OrderInfo>
53
+ <OrderType>HVU</OrderType>
54
+ <TransferType>Download</TransferType>
55
+ <Description>VEU-Übersicht abholen</Description>
56
+ </OrderInfo>
57
+ <OrderInfo>
58
+ <OrderType>HVD</OrderType>
59
+ <TransferType>Download</TransferType>
60
+ <Description>VEU-Status abrufen</Description>
61
+ </OrderInfo>
62
+ <OrderInfo>
63
+ <OrderType>HPB</OrderType>
64
+ <TransferType>Download</TransferType>
65
+ <Description>Abholen Public-Keys der Bank</Description>
66
+ </OrderInfo>
67
+ <OrderInfo>
68
+ <OrderType>HVZ</OrderType>
69
+ <TransferType>Download</TransferType>
70
+ <Description>VEU-Übersicht mit Zusatzinformationen abholen</Description>
71
+ </OrderInfo>
72
+ <OrderInfo>
73
+ <OrderType>CCS</OrderType>
74
+ <TransferType>Upload</TransferType>
75
+ <Description>CCS</Description>
76
+ <NumSigRequired>1</NumSigRequired>
77
+ </OrderInfo>
78
+ <OrderInfo>
79
+ <OrderType>INI</OrderType>
80
+ <TransferType>Upload</TransferType>
81
+ <Description>Passwort-Initialisierung</Description>
82
+ <NumSigRequired>1</NumSigRequired>
83
+ </OrderInfo>
84
+ <OrderInfo>
85
+ <OrderType>HIA</OrderType>
86
+ <TransferType>Upload</TransferType>
87
+ <Description>Initiales Senden Public Key</Description>
88
+ </OrderInfo>
89
+ <OrderInfo>
90
+ <OrderType>HCA</OrderType>
91
+ <TransferType>Upload</TransferType>
92
+ <Description>Senden Public Key</Description>
93
+ <NumSigRequired>1</NumSigRequired>
94
+ </OrderInfo>
95
+ <OrderInfo>
96
+ <OrderType>HSA</OrderType>
97
+ <TransferType>Upload</TransferType>
98
+ <Description>Initiales Senden Public Key</Description>
99
+ <NumSigRequired>1</NumSigRequired>
100
+ </OrderInfo>
101
+ <OrderInfo>
102
+ <OrderType>SPR</OrderType>
103
+ <TransferType>Upload</TransferType>
104
+ <Description>Sperren der Zugangsberechtigung</Description>
105
+ </OrderInfo>
106
+ <OrderInfo>
107
+ <OrderType>PUB</OrderType>
108
+ <TransferType>Upload</TransferType>
109
+ <Description>Senden Public Key zur Unterschrift</Description>
110
+ <NumSigRequired>1</NumSigRequired>
111
+ </OrderInfo>
112
+ <OrderInfo>
113
+ <OrderType>HVE</OrderType>
114
+ <TransferType>Upload</TransferType>
115
+ <Description>VEU-Unterschrift hinzufügen</Description>
116
+ <NumSigRequired>1</NumSigRequired>
117
+ </OrderInfo>
118
+ <OrderInfo>
119
+ <OrderType>HVS</OrderType>
120
+ <TransferType>Upload</TransferType>
121
+ <Description>VEU-Storno</Description>
122
+ <NumSigRequired>1</NumSigRequired>
123
+ </OrderInfo>
124
+ <OrderInfo>
125
+ <OrderType>CCT</OrderType>
126
+ <TransferType>Upload</TransferType>
127
+ <Description>Credit Transfer Initiation</Description>
128
+ <NumSigRequired>1</NumSigRequired>
129
+ </OrderInfo>
130
+ <OrderInfo>
131
+ <OrderType>CD1</OrderType>
132
+ <TransferType>Upload</TransferType>
133
+ <Description>CD1</Description>
134
+ <NumSigRequired>1</NumSigRequired>
135
+ </OrderInfo>
136
+ <OrderInfo>
137
+ <OrderType>CDD</OrderType>
138
+ <TransferType>Upload</TransferType>
139
+ <Description>Direct Debit Initiation</Description>
140
+ <NumSigRequired>1</NumSigRequired>
141
+ </OrderInfo>
142
+ </PartnerInfo>
143
+ <UserInfo>
144
+ <UserID Status="1">EBIX</UserID>
145
+ <Name>Ebi, Epics</Name>
146
+ <Permission>
147
+ <OrderTypes>PTK HPD HTD STA HVD HPB HAA HVT HVU HVZ</OrderTypes>
148
+ </Permission>
149
+ <Permission AuthorisationLevel="E">
150
+ <OrderTypes>INI SPR PUB HIA HCA HSA HVE HVS CCS CCT CD1 CDD</OrderTypes>
151
+ </Permission>
152
+ </UserInfo>
153
+ </HTDResponseOrderData>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <ebicsUnsecuredRequest xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="urn:org:ebics:H004" Version="H004" Revision="1"><header authenticate="true"><static><HostID>SIZBN001</HostID><PartnerID>EBICS</PartnerID><UserID>EBIX</UserID><Product Language="de">EPICS - a ruby ebics kernel</Product><OrderDetails><OrderType>INI</OrderType><OrderAttribute>DZNNN</OrderAttribute></OrderDetails><SecurityMedium>0000</SecurityMedium></static><mutable/></header><body><DataTransfer><OrderData>eJxlUktzokAQvu+vSGUPHrbiDIoGLCTFS3nICiERzA0yIyI6wDCA5tevm+y6cVPVh/ke3VPV/UkPx8P+psW0zgoy7XF92LvB5LVAGUmnvYZt7oTeg/xNCrKUxKyh2GsSB5+WFGGqxyy+ObeTeoLq6e2WsXICQNd1/W7YL2gKBhBCAEVw9qA6S7/ffrivrDjJXut3dwAhdyv//5NFNoUsfbxX8b7BsoTqyWOgXGG3QM2+qWWOHxX3LwKOSEkZOy7SZw2JniPEjt3EC3s0hMSMNFtwsuW95zYHZK9iVC+TRLfMSNy+0lUknsJnytcOq8DuzTjhTKWP5ewYzZnlDHI14QWzjDehUflcEidAyXiwCnW+Nte+1qmh4Fin2iHWunz015xOTP+HOYw2s22gkt1qTgULkkRPtQHvqE2bV+LM04QiAGnukwN1XkYDinaLMBhWwxwxzW/dU97xc9i1P/25vQ9AeHS1PIB0A21o7bq1Ehz3XLLnRXvQtu0iqDqdKbY3i0OryaFrmqkxHqXEg1tuvKwg5+1cxWuOilluqwVJW5cEYY7XOmIF3Yg7rBgHaizQGlkzQN9MWtnddCqBT0v+vXDjWBYEEyYrvqK+qxfmHV0d6Ck74IDFh1IeQI6/4+C5njhuwo0nEL5I4J8ugatLX7Kw+giorEA4lsAX+hN1lZqYMoKppcuGamnBefiFkJ7rv0IkgT/gy5hLzOVfAqASnw==</OrderData></DataTransfer></body></ebicsUnsecuredRequest>
@@ -0,0 +1,2 @@
1
+ <?xml version='1.0' encoding='utf-8'?>
2
+ <SignaturePubKeyOrderData xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="http://www.ebics.org/S001"><SignaturePubKeyInfo><PubKeyValue><ds:RSAKeyValue><ds:Modulus>145o7Z8eXnprttxLgUCd9PK8aKJuaLJ530nHXCJ8KiO7PMumdJVadsObbDIHX9hcrVX9yWUr4sKtq/jzEyeiBrRpFxXGtIK2kBb48HpafWEqQ1bab/Ai4/VWD4sHYQCwBW8KIysKnIYpRQY1DnHQ+H3XfFhSBnjVGr8I0nbDgC24KBuvkq9FPC8oS/gkQnmrKZ52rdjLWS3q3kdtCQvMykw4G0wvNQGJlS/WxMCkS0rf0J0IjwYASxl1bl49J2vvvLSqwDtAJPFaWIuk0MHHgE65gnP0h16Oq01PjMAPuxAHphqLngvMnSWkeYDdtorf9jeAEmrELdYdIF/rzHrqJw==</ds:Modulus><ds:Exponent>AQAB</ds:Exponent></ds:RSAKeyValue><TimeStamp>2014-10-10T11:16:00Z</TimeStamp></PubKeyValue><SignatureVersion>A006</SignatureVersion></SignaturePubKeyInfo><PartnerID>EBICS</PartnerID><UserID>EBIX</UserID></SignaturePubKeyOrderData>
@@ -0,0 +1,31 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ebicsResponse Revision="1" Version="H003" xsi:schemaLocation="http://www.ebics.org/H003 http://www.ebics.org/H003/ebics_response.xsd" xmlns="http://www.ebics.org/H003" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
3
+ <header authenticate="true">
4
+ <static>
5
+ <TransactionID>ABF70F5E704E03CFE5B50692BEE55ABA</TransactionID>
6
+ </static>
7
+ <mutable>
8
+ <TransactionPhase>Initialisation</TransactionPhase>
9
+ <ReturnCode>000000</ReturnCode>
10
+ <ReportText>[EBICS_OK] OK</ReportText>
11
+ </mutable>
12
+ </header>
13
+ <AuthSignature>
14
+ <ds:SignedInfo>
15
+ <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
16
+ <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
17
+ <ds:Reference URI="#xpointer(//*[@authenticate='true'])">
18
+ <ds:Transforms>
19
+ <ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
20
+ </ds:Transforms>
21
+ <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
22
+ <ds:DigestValue>0/3J0Cne3ncZmTUNZuD8S8HOKI95bo9fP1AvVyVZDfc=</ds:DigestValue>
23
+ </ds:Reference>
24
+ </ds:SignedInfo>
25
+ <ds:SignatureValue>J1vtnW2TX3sY9IWnWDcYA2SiZcPwSKq8ap7ESJEfHjDsqDhJV5A3dOo/R4v3LwoMe7CdbWc0AX+KMrcL4FSeQ+CnM776ncQV3OELS83ZkHZzbp15B0cJ9pf3lY9JiEDxKLMeoRjNJlc97Io2iJOW6dO2ZoSPXjF2G4ukQ81P7P8=</ds:SignatureValue>
26
+ </AuthSignature>
27
+ <body>
28
+ <ReturnCode authenticate="true">000000</ReturnCode>
29
+ <TimestampBankParameter authenticate="true">2009-06-16T17:56:05.698+02:00</TimestampBankParameter>
30
+ </body>
31
+ </ebicsResponse>
data/spec/hpb_spec.rb ADDED
@@ -0,0 +1,15 @@
1
+ RSpec.describe Epics::HPB do
2
+ let(:client) { instance_double(Epics::Client, host_id: "HOST", user_id: "USER", partner_id: "PARTNER") }
3
+ describe '#to_xml' do
4
+ subject { Nokogiri::XML.parse(described_class.new(client).to_xml) }
5
+
6
+ specify do
7
+ expect(subject.xpath("//xmlns:Timestamp").first.content).to_not be_nil
8
+ expect(subject.xpath("//xmlns:Nonce").first.content).to_not be_nil
9
+ expect(subject.xpath("//xmlns:HostID").first.content).to eq("HOST")
10
+ expect(subject.xpath("//xmlns:UserID").first.content).to eq("USER")
11
+ expect(subject.xpath("//xmlns:PartnerID").first.content).to eq("PARTNER")
12
+ end
13
+ end
14
+
15
+ end
data/spec/key_spec.rb ADDED
@@ -0,0 +1,35 @@
1
+ RSpec.describe Epics::Key do
2
+
3
+ subject { described_class.new( File.read(File.join( File.dirname(__FILE__), 'fixtures', 'e002.pem'))) }
4
+
5
+ describe '#public_digest' do
6
+
7
+ it 'will calculate the digest as the specification suggests' do
8
+ expect(subject.public_digest).to eq("rwIxSUJAVEFDQ0sdYe+CybdspMllDG6ArNtdCzUbT1E=")
9
+ end
10
+ end
11
+
12
+
13
+ describe '#sign' do
14
+ # echo QwpW2a/Cu43TmibTIABrLuyZsiWY9oL8fARob0YoytU= | base64 -d | openssl dgst -sha256 -sign spec/fixtures/e002.pem -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:32 | base64 -w0
15
+ let(:openssl) { "bZyyz4vPqRTyU7hfJ1cv6FgihhQOi8NTbk8nSuPEoXeuODJOQkCvxRDw1QoUGa181EbaPACYwJbQ9uwgwgb/b3k+bQ4KdJzCjbCrh7rKmQvLmnLgfQWIxp5hZdw7ebaR36rlpoHQ8yzlm0hhVLCDu2+HMIu5SA4kEd4ci9ZfVRm+aDVOwQZNLXNyKWAW/ZYkbsH+TzX4euIh831JBxGq967U5DVz6Aa8qqJPUafYiSE4H8x36Nw3qW0ib2DDcvGFTqtA6MeJyI1Quzko5+kSdnZkpIeZr/SXB1WnocYWR1oYoVG4+P+cMyCNiYSV4/NVEL4jmUbfdCSmUYo5cfPlJg==" }
16
+
17
+ # r = subject.recover(sig)
18
+ # masked_db = r[0..222]
19
+ # hm = r[223..-2]
20
+ # db_mask = MGF1.new.generate(hm, masked_db.size)
21
+ # db = MGF1.new.xor(masked_db, db_mask)
22
+ # salt = db[-32..-1]
23
+ # Base64.encode64(salt)
24
+ let(:salt) { "HkCke9oBSGTo2J20Xq8LZ/ouRHfB/ySlXf4+Cr45RV0=" }
25
+
26
+ let(:dsi) { OpenSSL::Digest::SHA256.new.digest("ruby is great") }
27
+
28
+ it 'will be compliant with openssl' do
29
+ expect( subject.sign( dsi, Base64.decode64(salt)) ).to eq(openssl)
30
+ end
31
+
32
+ end
33
+
34
+
35
+ end
data/spec/mgf_spec.rb ADDED
@@ -0,0 +1,36 @@
1
+ RSpec.describe Epics::MGF1 do
2
+
3
+ describe '#generate' do
4
+ it { expect(subject.generate('foo', 0)).to eq('')}
5
+ it { expect(subject.generate('bar', 1)).to eq('8')}
6
+ it { expect(subject.generate('noIdea', 2).bytes.to_a).to eq([86, 174])}
7
+ it { expect(subject.generate('What', 4).bytes.to_a).to eq([238, 183, 195, 188])}
8
+ it { expect(subject.generate('ImDoing', 8).bytes.to_a).to eq([134, 205, 115, 236, 187, 67, 223, 2])}
9
+ it { expect { subject.generate('seed', 137438953473) }.to raise_error(ArgumentError, 'mask too long') }
10
+ end
11
+
12
+ describe '#i2osp' do
13
+ it { expect(subject.i2osp(1, 1).bytes.to_a).to eq([1])}
14
+ it { expect(subject.i2osp(1, 2).bytes.to_a).to eq([0, 1])}
15
+ it { expect(subject.i2osp(1, 3).bytes.to_a).to eq([0, 0, 1])}
16
+ it { expect(subject.i2osp(2, 1).bytes.to_a).to eq([2])}
17
+ it { expect(subject.i2osp(4, 4).bytes.to_a).to eq([0, 0, 0, 4])}
18
+ it { expect { subject.i2osp(256, 1) }.to raise_error(ArgumentError, 'integer too large') }
19
+ end
20
+
21
+ describe '#divceil' do
22
+ it { expect(subject.divceil(1, 1)).to eq(1) }
23
+ it { expect(subject.divceil(8, 2)).to eq(4) }
24
+ it { expect(subject.divceil(32, 4)).to eq(8) }
25
+ it { expect(subject.divceil(140, 21)).to eq(7) }
26
+ it { expect(subject.divceil(987654321, 123456789)).to eq(9) }
27
+ end
28
+
29
+ describe '#xor' do
30
+ it { expect(subject.xor('a', 'a').bytes.to_a).to eq([0]) }
31
+ it { expect(subject.xor('a', 'b').bytes.to_a).to eq([3]) }
32
+ it { expect(subject.xor('foo', 'bar').bytes.to_a).to eq([4, 14, 29]) }
33
+ it { expect(subject.xor('encyclopedia', 'aidepolcycne').bytes.to_a).to eq([4, 7, 7, 28, 19, 3, 3, 19, 28, 7, 7, 4]) }
34
+ it { expect { subject.xor('to raise', 'or not') }.to raise_error(ArgumentError, 'different length for a and b') }
35
+ end
36
+ end
@@ -0,0 +1,18 @@
1
+ RSpec.describe Epics::ParseEbics do
2
+
3
+ subject do
4
+ Faraday.new do |builder|
5
+ builder.adapter :test, Faraday::Adapter::Test::Stubs.new do |stub|
6
+ stub.post('/business_nok') {[ 200, {}, File.read( File.join( File.dirname(__FILE__), '..', 'fixtures', 'xml', 'ebics_business_nok.xml') ) ]}
7
+ stub.post('/technical_nok') {[ 200, {}, File.read( File.join( File.dirname(__FILE__), '..', 'fixtures', 'xml', 'ebics_technical_nok.xml') ) ]}
8
+ end
9
+ builder.use Epics::ParseEbics
10
+ end
11
+ end
12
+
13
+ it "will handle errornous response with raising the related error class" do
14
+ expect { subject.post("/business_nok") }.to raise_error(Epics::Error::BusinessError, "EBICS_PROCESSING_ERROR - During processing of the EBICS request, other business-related errors have ocurred")
15
+ expect { subject.post("/technical_nok") }.to raise_error(Epics::Error::TechnicalError, "EBICS_AUTHENTICATION_FAILED - Authentication signature error")
16
+ end
17
+
18
+ end
@@ -0,0 +1,17 @@
1
+ RSpec.describe Epics::CCT do
2
+
3
+ let(:client) { Epics::Client.new( File.open(File.join( File.dirname(__FILE__), '..', 'fixtures', 'SIZBN001.key')), 'secret' , 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') }
4
+ let(:document) { File.read( File.join( File.dirname(__FILE__), '..', 'fixtures', 'xml', 'cd1.xml') ) }
5
+ subject { described_class.new(client, document) }
6
+
7
+ describe '#to_xml' do
8
+ specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
9
+ end
10
+
11
+ describe '#to_transfer_xml' do
12
+ before { subject.transaction_id = SecureRandom.hex(16) }
13
+
14
+ specify { expect(subject.to_transfer_xml).to be_a_valid_ebics_doc }
15
+ end
16
+
17
+ end
@@ -0,0 +1,17 @@
1
+ RSpec.describe Epics::CD1 do
2
+
3
+ let(:client) { Epics::Client.new( File.open(File.join( File.dirname(__FILE__), '..', 'fixtures', 'SIZBN001.key')), 'secret' , 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') }
4
+ let(:document) { File.read( File.join( File.dirname(__FILE__), '..', 'fixtures', 'xml', 'cd1.xml') ) }
5
+ subject { described_class.new(client, document) }
6
+
7
+ describe '#to_xml' do
8
+ specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
9
+ end
10
+
11
+ describe '#to_transfer_xml' do
12
+ before { subject.transaction_id = SecureRandom.hex(16) }
13
+
14
+ specify { expect(subject.to_transfer_xml).to be_a_valid_ebics_doc }
15
+ end
16
+
17
+ end
@@ -0,0 +1,17 @@
1
+ RSpec.describe Epics::CDD do
2
+
3
+ let(:client) { Epics::Client.new( File.open(File.join( File.dirname(__FILE__), '..', 'fixtures', 'SIZBN001.key')), 'secret' , 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') }
4
+ let(:document) { File.read( File.join( File.dirname(__FILE__), '..', 'fixtures', 'xml', 'cd1.xml') ) }
5
+ subject { described_class.new(client, document) }
6
+
7
+ describe '#to_xml' do
8
+ specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
9
+ end
10
+
11
+ describe '#to_transfer_xml' do
12
+ before { subject.transaction_id = SecureRandom.hex(16) }
13
+
14
+ specify { expect(subject.to_transfer_xml).to be_a_valid_ebics_doc }
15
+ end
16
+
17
+ end
@@ -0,0 +1,11 @@
1
+ RSpec.describe Epics::HAA do
2
+
3
+ let(:client) { Epics::Client.new( File.open(File.join( File.dirname(__FILE__), '..', 'fixtures', 'SIZBN001.key')), 'secret' , 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') }
4
+
5
+ subject { described_class.new(client) }
6
+
7
+ describe '#to_xml' do
8
+ specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
9
+ end
10
+
11
+ end
@@ -0,0 +1,34 @@
1
+ RSpec.describe Epics::HIA do
2
+
3
+ let(:client) { Epics::Client.new( File.open(File.join( File.dirname(__FILE__), '..', 'fixtures', 'SIZBN001.key')), 'secret' , 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') }
4
+
5
+ subject { described_class.new(client) }
6
+
7
+ describe '#to_xml' do
8
+ specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
9
+
10
+ describe 'validate against fixture' do
11
+
12
+ let(:hia) { Nokogiri::XML(File.read(File.join( File.dirname(__FILE__), '..', 'fixtures', 'xml', 'hia.xml'))) }
13
+
14
+ it "will match exactly" do
15
+ expect(Nokogiri::XML(subject.to_xml)).to be_equivalent_to(hia)
16
+ end
17
+ end
18
+ end
19
+
20
+ describe '#order_data' do
21
+
22
+ specify { expect(subject.order_data).to be_a_valid_ebics_doc }
23
+
24
+ describe 'validate against fixture' do
25
+
26
+ let(:hia_request_order_data) { Nokogiri::XML(File.read(File.join( File.dirname(__FILE__), '..', 'fixtures', 'xml', 'hia_request_order_data.xml'))) }
27
+
28
+ it "will match exactly" do
29
+ expect(Nokogiri::XML(subject.order_data)).to be_equivalent_to(hia_request_order_data)
30
+ end
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,11 @@
1
+ RSpec.describe Epics::HPB do
2
+
3
+ let(:client) { Epics::Client.new( File.open(File.join( File.dirname(__FILE__), '..', 'fixtures', 'SIZBN001.key')), 'secret' , 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') }
4
+
5
+ subject { described_class.new(client) }
6
+
7
+ describe '#to_xml' do
8
+ specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
9
+ end
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ RSpec.describe Epics::HPD do
2
+
3
+ let(:client) { Epics::Client.new( File.open(File.join( File.dirname(__FILE__), '..', 'fixtures', 'SIZBN001.key')), 'secret' , 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') }
4
+
5
+ subject { described_class.new(client) }
6
+
7
+ describe '#to_xml' do
8
+ specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
9
+ end
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ RSpec.describe Epics::HTD do
2
+
3
+ let(:client) { Epics::Client.new( File.open(File.join( File.dirname(__FILE__), '..', 'fixtures', 'SIZBN001.key')), 'secret' , 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') }
4
+
5
+ subject { described_class.new(client) }
6
+
7
+ describe '#to_xml' do
8
+ specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
9
+ end
10
+
11
+ end