epics 2.8.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +73 -3
- data/lib/epics/client.rb +41 -9
- data/lib/epics/generic_request.rb +14 -0
- data/lib/epics/hev.rb +19 -0
- data/lib/epics/hia.rb +2 -0
- data/lib/epics/ini.rb +1 -0
- data/lib/epics/letter_renderer.rb +23 -3
- data/lib/epics/response.rb +8 -0
- data/lib/epics/signer.rb +3 -3
- data/lib/epics/version.rb +1 -1
- data/lib/epics/x_509_certificate.rb +15 -0
- data/lib/epics/z01.rb +17 -0
- data/lib/epics.rb +3 -0
- data/lib/letter/ini_with_certs.erb +335 -0
- data/lib/letter/locales/de.yml +1 -0
- data/lib/letter/locales/en.yml +1 -0
- data/lib/letter/locales/fr.yml +1 -0
- data/spec/client_spec.rb +150 -58
- data/spec/orders/hev_spec.rb +14 -0
- data/spec/orders/hia_spec.rb +31 -7
- data/spec/orders/ini_spec.rb +27 -8
- data/spec/orders/x_509_certificate_spec.rb +26 -0
- data/spec/orders/z01_spec.rb +11 -0
- data/spec/support/x_509_crt_generator.rb +22 -0
- metadata +15 -5
data/spec/client_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
RSpec.describe Epics::Client do
|
2
|
-
|
3
|
-
|
2
|
+
subject { described_class.new(key, 'secret', 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') }
|
3
|
+
let(:key) { File.read(File.join(File.dirname(__FILE__), 'fixtures', 'SIZBN001.key')) }
|
4
4
|
|
5
5
|
describe 'attributes' do
|
6
6
|
it { expect(subject.host_id).to eq('SIZBN001') }
|
@@ -12,14 +12,18 @@ RSpec.describe Epics::Client do
|
|
12
12
|
|
13
13
|
it 'holds all keys, user and bank' do
|
14
14
|
expect(subject.keys).to match(a_hash_including(
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
'E002' => be_a(Epics::Key),
|
16
|
+
'X002' => be_a(Epics::Key),
|
17
|
+
'A006' => be_a(Epics::Key),
|
18
|
+
'SIZBN001.E002' => be_a(Epics::Key),
|
19
|
+
'SIZBN001.X002' => be_a(Epics::Key)
|
20
|
+
))
|
21
21
|
end
|
22
22
|
|
23
|
+
it 'assigns x_509_certificates_content' do
|
24
|
+
subject.x_509_certificates_content = { a: 'cert_a', x: 'cert_x', e: 'cert_e' }
|
25
|
+
expect(subject.x_509_certificates_content).to eq({ a: 'cert_a', x: 'cert_x', e: 'cert_e' })
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
context 'environment settings' do
|
@@ -54,41 +58,43 @@ RSpec.describe Epics::Client do
|
|
54
58
|
|
55
59
|
describe '#e' do
|
56
60
|
it 'the encryption key' do
|
57
|
-
expect(subject.e.public_digest).to eq(
|
61
|
+
expect(subject.e.public_digest).to eq('rwIxSUJAVEFDQ0sdYe+CybdspMllDG6ArNtdCzUbT1E=')
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
65
|
describe '#x' do
|
62
66
|
it 'the signing key' do
|
63
|
-
expect(subject.x.public_digest).to eq(
|
67
|
+
expect(subject.x.public_digest).to eq('Jjcu97qg595PPn+0OvqBOBIskMIiStNYYXyjgWHeBhE=')
|
64
68
|
end
|
65
69
|
end
|
66
70
|
|
67
71
|
describe '#a' do
|
68
72
|
it 'the authentication key' do
|
69
|
-
expect(subject.a.public_digest).to eq(
|
73
|
+
expect(subject.a.public_digest).to eq('9ay3tc+I3MgJBaroeD7XJfOtHcq7IR23fljWefl0dzk=')
|
70
74
|
end
|
71
75
|
end
|
72
76
|
|
73
77
|
describe '#bank_e' do
|
74
78
|
it 'the banks encryption key' do
|
75
|
-
expect(subject.bank_e.public_digest).to eq(
|
79
|
+
expect(subject.bank_e.public_digest).to eq('dFAYe281vj9NB7w+VoWIdfHnjY9hNbZLbHsDOu76QAE=')
|
76
80
|
end
|
77
81
|
end
|
78
82
|
|
79
83
|
describe '#bank_x' do
|
80
84
|
it 'the banks signing key' do
|
81
|
-
expect(subject.bank_x.public_digest).to eq(
|
85
|
+
expect(subject.bank_x.public_digest).to eq('dFAYe281vj9NB7w+VoWIdfHnjY9hNbZLbHsDOu76QAE=')
|
82
86
|
end
|
83
87
|
end
|
84
88
|
|
85
89
|
describe '#order_types' do
|
86
90
|
before do
|
87
|
-
allow(subject).to receive(:download).and_return(
|
91
|
+
allow(subject).to receive(:download).and_return(File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml',
|
92
|
+
'htd_order_data.xml')))
|
88
93
|
end
|
89
94
|
|
90
95
|
it 'extracts the accessible order types of a subscriber' do
|
91
|
-
expect(subject.order_types).to match_array(%w
|
96
|
+
expect(subject.order_types).to match_array(%w[PTK HPD HTD STA HVD HPB HAA HVT HVU HVZ INI SPR PUB HIA HCA HSA HVE
|
97
|
+
HVS CCS CCT CIP CD1 CDB CDD])
|
92
98
|
end
|
93
99
|
end
|
94
100
|
|
@@ -98,109 +104,119 @@ RSpec.describe Epics::Client do
|
|
98
104
|
end
|
99
105
|
|
100
106
|
before do
|
101
|
-
stub_request(:post,
|
102
|
-
.with(:
|
103
|
-
.to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml',
|
107
|
+
stub_request(:post, 'https://194.180.18.30/ebicsweb/ebicsweb')
|
108
|
+
.with(body: /ebicsNoPubKeyDigestsRequest/)
|
109
|
+
.to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml',
|
110
|
+
'hpb_response_ebics_ns.xml')))
|
104
111
|
end
|
105
112
|
|
106
113
|
it { expect(subject.HPB).to match([be_a(Epics::Key), be_a(Epics::Key)]) }
|
107
114
|
|
108
115
|
it 'changes the SIZBN001.(E|X)002 keys' do
|
109
|
-
expect { subject.HPB }.to
|
110
|
-
expect { subject.HPB }.to
|
116
|
+
expect { subject.HPB }.to(change { subject.keys['SIZBN001.E002'] })
|
117
|
+
expect { subject.HPB }.to(change { subject.keys['SIZBN001.X002'] })
|
111
118
|
end
|
112
119
|
|
113
120
|
describe 'crypto' do
|
114
|
-
|
115
121
|
before { subject.HPB }
|
116
122
|
|
117
|
-
it { expect(subject.keys[
|
118
|
-
it { expect(subject.keys[
|
123
|
+
it { expect(subject.keys['SIZBN001.E002'].public_digest).to eq(e_key.public_digest) }
|
124
|
+
it { expect(subject.keys['SIZBN001.X002'].public_digest).to eq(e_key.public_digest) }
|
119
125
|
end
|
120
126
|
|
121
127
|
describe 'when order data wont include namesspaces' do
|
122
128
|
before do
|
123
|
-
allow(subject).to receive(:download).with(Epics::HPB).and_return(File.read(File.join(File.dirname(__FILE__),
|
129
|
+
allow(subject).to receive(:download).with(Epics::HPB).and_return(File.read(File.join(File.dirname(__FILE__),
|
130
|
+
'fixtures', 'xml', 'hpb_response_order_without_ns.xml')))
|
124
131
|
|
125
132
|
subject.HPB
|
126
133
|
end
|
127
134
|
|
128
|
-
it { expect(subject.keys[
|
129
|
-
it { expect(subject.keys[
|
135
|
+
it { expect(subject.keys['SIZBN001.E002'].public_digest).to eq(e_key.public_digest) }
|
136
|
+
it { expect(subject.keys['SIZBN001.X002'].public_digest).to eq(e_key.public_digest) }
|
130
137
|
end
|
131
138
|
end
|
132
139
|
|
133
|
-
|
134
140
|
describe '#CDB' do
|
135
141
|
let(:cdb_document) { File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml', 'cdb.xml')) }
|
136
142
|
before do
|
137
|
-
stub_request(:post,
|
138
|
-
.with(:
|
139
|
-
.to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml',
|
140
|
-
|
141
|
-
|
142
|
-
.
|
143
|
+
stub_request(:post, 'https://194.180.18.30/ebicsweb/ebicsweb')
|
144
|
+
.with(body: %r{<TransactionPhase>Initialisation</TransactionPhase>})
|
145
|
+
.to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml',
|
146
|
+
'cdb_init_response.xml')))
|
147
|
+
stub_request(:post, 'https://194.180.18.30/ebicsweb/ebicsweb')
|
148
|
+
.with(body: %r{<TransactionPhase>Transfer</TransactionPhase>})
|
149
|
+
.to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml',
|
150
|
+
'cdb_transfer_response.xml')))
|
143
151
|
end
|
144
152
|
|
145
|
-
it { expect(subject.CDB(cdb_document)).to eq([
|
153
|
+
it { expect(subject.CDB(cdb_document)).to eq(%w[387B7BE88FE33B0F4B60AC64A63F18E2 N00L]) }
|
146
154
|
end
|
147
155
|
|
148
156
|
describe '#CD1' do
|
149
157
|
let(:cd1_document) { File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml', 'cd1.xml')) }
|
150
158
|
describe 'normal behaviour' do
|
151
159
|
before do
|
152
|
-
stub_request(:post,
|
153
|
-
.with(:
|
154
|
-
.to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml',
|
155
|
-
|
156
|
-
|
157
|
-
.
|
160
|
+
stub_request(:post, 'https://194.180.18.30/ebicsweb/ebicsweb')
|
161
|
+
.with(body: %r{<TransactionPhase>Initialisation</TransactionPhase>})
|
162
|
+
.to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml',
|
163
|
+
'cd1_init_response.xml')))
|
164
|
+
stub_request(:post, 'https://194.180.18.30/ebicsweb/ebicsweb')
|
165
|
+
.with(body: %r{<TransactionPhase>Transfer</TransactionPhase>})
|
166
|
+
.to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml',
|
167
|
+
'cd1_transfer_response.xml')))
|
158
168
|
end
|
159
169
|
|
160
|
-
it { expect(subject.CD1(cd1_document)).to eq([
|
170
|
+
it { expect(subject.CD1(cd1_document)).to eq(%w[387B7BE88FE33B0F4B60AC64A63F18E2 N00L]) }
|
161
171
|
end
|
162
172
|
|
163
173
|
describe 'special case' do
|
164
174
|
before do
|
165
|
-
stub_request(:post,
|
166
|
-
.with(:
|
167
|
-
.to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml', 'cd1_init_response.xml')).sub(
|
168
|
-
|
169
|
-
|
170
|
-
|
175
|
+
stub_request(:post, 'https://194.180.18.30/ebicsweb/ebicsweb')
|
176
|
+
.with(body: %r{<TransactionPhase>Initialisation</TransactionPhase>})
|
177
|
+
.to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml', 'cd1_init_response.xml')).sub(
|
178
|
+
'N00L', 'N11L'
|
179
|
+
))
|
180
|
+
stub_request(:post, 'https://194.180.18.30/ebicsweb/ebicsweb')
|
181
|
+
.with(body: %r{<TransactionPhase>Transfer</TransactionPhase>})
|
182
|
+
.to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml', 'cd1_transfer_response.xml')).sub(
|
183
|
+
'<OrderID>N00L</OrderID>', ''
|
184
|
+
))
|
171
185
|
end
|
172
186
|
|
173
187
|
# happend on some handelsbank accounts
|
174
188
|
it 'can also try to fetch the order_id from the first transaction being made' do
|
175
|
-
expect(subject.CD1(cd1_document)).to eq([
|
189
|
+
expect(subject.CD1(cd1_document)).to eq(%w[387B7BE88FE33B0F4B60AC64A63F18E2 N11L])
|
176
190
|
end
|
177
191
|
end
|
178
192
|
end
|
179
193
|
|
180
194
|
describe '#HTD' do
|
181
195
|
before do
|
182
|
-
allow(subject).to receive(:download).and_return(
|
196
|
+
allow(subject).to receive(:download).and_return(File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml',
|
197
|
+
'htd_order_data.xml')))
|
183
198
|
end
|
184
199
|
|
185
200
|
it 'sets @iban' do
|
186
|
-
expect { subject.HTD }.to
|
201
|
+
expect { subject.HTD }.to(change { subject.instance_variable_get('@iban') })
|
187
202
|
end
|
188
203
|
|
189
204
|
it 'sets @bic' do
|
190
|
-
expect { subject.HTD }.to
|
205
|
+
expect { subject.HTD }.to(change { subject.instance_variable_get('@bic') })
|
191
206
|
end
|
192
207
|
|
193
208
|
it 'sets @name' do
|
194
|
-
expect { subject.HTD }.to
|
209
|
+
expect { subject.HTD }.to(change { subject.instance_variable_get('@name') })
|
195
210
|
end
|
196
211
|
|
197
212
|
it 'sets @order_types' do
|
198
|
-
expect { subject.HTD }.to
|
213
|
+
expect { subject.HTD }.to(change { subject.instance_variable_get('@order_types') })
|
199
214
|
end
|
200
215
|
|
201
216
|
describe 'without iban' do
|
202
217
|
before do
|
203
|
-
allow(subject).to receive(:download).and_return(
|
218
|
+
allow(subject).to receive(:download).and_return(File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml',
|
219
|
+
'htd_order_data_without_names.xml')))
|
204
220
|
end
|
205
221
|
|
206
222
|
it 'sets @iban' do
|
@@ -211,11 +227,12 @@ RSpec.describe Epics::Client do
|
|
211
227
|
|
212
228
|
describe '#C53/C52/C54/Z52/Z53/Z54 types with zipped data' do
|
213
229
|
before do
|
214
|
-
allow(subject).to receive(:download).and_return(
|
230
|
+
allow(subject).to receive(:download).and_return(File.read(File.join(File.dirname(__FILE__), 'fixtures',
|
231
|
+
'test.zip')))
|
215
232
|
end
|
216
233
|
|
217
234
|
it 'will unzip the returned data' do
|
218
|
-
%w
|
235
|
+
%w[C52 C53 C54 Z52 Z53 Z54].each do |c|
|
219
236
|
expect(subject.send(c, :today, :yesterday)).to eq(["ebics is great\n"])
|
220
237
|
end
|
221
238
|
end
|
@@ -223,13 +240,88 @@ RSpec.describe Epics::Client do
|
|
223
240
|
|
224
241
|
describe '#C53/C52/C54/Z52/Z53/Z54 types with zipped data with general purpose bit flag 3 set' do
|
225
242
|
before do
|
226
|
-
allow(subject).to receive(:download).and_return(
|
243
|
+
allow(subject).to receive(:download).and_return(File.read(File.join(File.dirname(__FILE__), 'fixtures',
|
244
|
+
'test_with_general_purpose_bit_3.zip')))
|
227
245
|
end
|
228
246
|
|
229
247
|
it 'will unzip the returned data' do
|
230
|
-
%w
|
248
|
+
%w[C52 C53 C54 Z52 Z53 Z54].each do |c|
|
231
249
|
expect(subject.send(c, :today, :yesterday)).to eq(["ebics is great\n"])
|
232
250
|
end
|
233
251
|
end
|
234
252
|
end
|
253
|
+
|
254
|
+
describe '#x_509_certificate' do
|
255
|
+
let(:epics_client) do
|
256
|
+
Epics::Client.new(key, 'secret', 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS')
|
257
|
+
end
|
258
|
+
|
259
|
+
context 'with valid certificates content' do
|
260
|
+
it 'returns an instance of Epics::X509Certificate' do
|
261
|
+
epics_client.x_509_certificates_content = {
|
262
|
+
a: generate_x_509_crt(epics_client.a.key, '/C=GB/O=TestOrg/CN=test.example.org'),
|
263
|
+
x: generate_x_509_crt(epics_client.x.key, '/C=GB/O=TestOrg/CN=test.example.org'),
|
264
|
+
e: generate_x_509_crt(epics_client.e.key, '/C=GB/O=TestOrg/CN=test.example.org')
|
265
|
+
}
|
266
|
+
|
267
|
+
expect(epics_client.x_509_certificate(:a)).to be_a(Epics::X509Certificate)
|
268
|
+
expect(epics_client.x_509_certificate(:x)).to be_a(Epics::X509Certificate)
|
269
|
+
expect(epics_client.x_509_certificate(:e)).to be_a(Epics::X509Certificate)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
context 'with nil or empty content' do
|
274
|
+
it 'returns nil when content is nil' do
|
275
|
+
epics_client.x_509_certificates_content = { a: nil, x: nil, e: nil }
|
276
|
+
expect(epics_client.x_509_certificate(:a)).to be_nil
|
277
|
+
expect(epics_client.x_509_certificate(:x)).to be_nil
|
278
|
+
expect(epics_client.x_509_certificate(:e)).to be_nil
|
279
|
+
end
|
280
|
+
|
281
|
+
it 'returns nil when content is empty string' do
|
282
|
+
epics_client.x_509_certificates_content = { a: '', x: '', e: '' }
|
283
|
+
expect(epics_client.x_509_certificate(:a)).to be_nil
|
284
|
+
expect(epics_client.x_509_certificate(:x)).to be_nil
|
285
|
+
expect(epics_client.x_509_certificate(:e)).to be_nil
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
describe '#x_509_certificate_hash' do
|
291
|
+
let(:epics_client) do
|
292
|
+
Epics::Client.new(key, 'secret', 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS')
|
293
|
+
end
|
294
|
+
context 'with valid certificates content' do
|
295
|
+
it 'returns SHA256 hash' do
|
296
|
+
epics_client.x_509_certificates_content = {
|
297
|
+
a: generate_x_509_crt(epics_client.a.key, '/C=GB/O=TestOrg/CN=test.example.org'),
|
298
|
+
x: generate_x_509_crt(epics_client.x.key, '/C=GB/O=TestOrg/CN=test.example.org'),
|
299
|
+
e: generate_x_509_crt(epics_client.e.key, '/C=GB/O=TestOrg/CN=test.example.org')
|
300
|
+
}
|
301
|
+
|
302
|
+
expect(epics_client.x_509_certificate_hash(:a)).to be_a(String)
|
303
|
+
expect(epics_client.x_509_certificate_hash(:x)).to be_a(String)
|
304
|
+
expect(epics_client.x_509_certificate_hash(:e)).to be_a(String)
|
305
|
+
expect(epics_client.x_509_certificate_hash(:a).size).to eq(64)
|
306
|
+
expect(epics_client.x_509_certificate_hash(:x).size).to eq(64)
|
307
|
+
expect(epics_client.x_509_certificate_hash(:e).size).to eq(64)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
context 'with nil or empty content' do
|
312
|
+
it 'returns nil when content is nil' do
|
313
|
+
epics_client.x_509_certificates_content = { a: nil, x: nil, e: nil }
|
314
|
+
expect(epics_client.x_509_certificate_hash(:a)).to be_nil
|
315
|
+
expect(epics_client.x_509_certificate_hash(:x)).to be_nil
|
316
|
+
expect(epics_client.x_509_certificate_hash(:e)).to be_nil
|
317
|
+
end
|
318
|
+
|
319
|
+
it 'returns nil when content is empty string' do
|
320
|
+
epics_client.x_509_certificates_content = { a: '', x: '', e: '' }
|
321
|
+
expect(epics_client.x_509_certificate_hash(:a)).to be_nil
|
322
|
+
expect(epics_client.x_509_certificate_hash(:x)).to be_nil
|
323
|
+
expect(epics_client.x_509_certificate_hash(:e)).to be_nil
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
235
327
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.describe Epics::HEV 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
|
+
let(:xsd) { Nokogiri::XML::Schema(File.open( File.join( File.dirname(__FILE__), '..', 'xsd', 'ebics_hev.xsd') )) }
|
6
|
+
let(:validator) { xsd.valid?(Nokogiri::XML(subject.to_xml)) }
|
7
|
+
|
8
|
+
subject { described_class.new(client) }
|
9
|
+
|
10
|
+
describe '#to_xml' do
|
11
|
+
specify { expect(validator).to be_truthy }
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/spec/orders/hia_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
RSpec.describe Epics::HIA do
|
2
|
-
let(:client) { Epics::Client.new(
|
2
|
+
let(:client) { Epics::Client.new(key, 'secret', 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') }
|
3
|
+
let(:key) { File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', 'SIZBN001.key')) }
|
3
4
|
|
4
5
|
subject { described_class.new(client) }
|
5
6
|
|
@@ -7,25 +8,48 @@ RSpec.describe Epics::HIA do
|
|
7
8
|
specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
|
8
9
|
|
9
10
|
describe 'validate against fixture' do
|
10
|
-
let(:hia)
|
11
|
+
let(:hia) do
|
12
|
+
Nokogiri::XML(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', 'xml', RUBY_ENGINE, 'hia.xml')))
|
13
|
+
end
|
11
14
|
|
12
|
-
it
|
15
|
+
it 'will match exactly' do
|
13
16
|
expect(Nokogiri::XML(subject.to_xml)).to be_equivalent_to(hia)
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|
17
20
|
|
18
21
|
describe '#order_data' do
|
19
|
-
|
20
22
|
specify { expect(subject.order_data).to be_a_valid_ebics_doc }
|
21
23
|
|
22
24
|
describe 'validate against fixture' do
|
25
|
+
let(:hia_request_order_data) do
|
26
|
+
Nokogiri::XML(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', 'xml',
|
27
|
+
'hia_request_order_data.xml')))
|
28
|
+
end
|
23
29
|
|
24
|
-
|
25
|
-
|
26
|
-
it "will match exactly" do
|
30
|
+
it 'will match exactly' do
|
27
31
|
expect(Nokogiri::XML(subject.order_data)).to be_equivalent_to(hia_request_order_data)
|
28
32
|
end
|
29
33
|
end
|
34
|
+
|
35
|
+
context 'with x509 certificate' do
|
36
|
+
let(:client) do
|
37
|
+
client = Epics::Client.new(key, 'secret', 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS')
|
38
|
+
client.x_509_certificates_content = {
|
39
|
+
x: generate_x_509_crt(client.x.key, '/C=GB/O=TestOrg/CN=test.example.org'),
|
40
|
+
e: generate_x_509_crt(client.e.key, '/C=GB/O=TestOrg/CN=test.example.org')
|
41
|
+
}
|
42
|
+
client
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'includes x509 certificate' do
|
46
|
+
x_crt = Epics::X509Certificate.new(client.x_509_certificates_content[:x])
|
47
|
+
e_crt = Epics::X509Certificate.new(client.x_509_certificates_content[:e])
|
48
|
+
expect(subject.order_data).to include('<ds:X509IssuerName>/C=GB/O=TestOrg/CN=test.example.org</ds:X509IssuerName>')
|
49
|
+
expect(subject.order_data).to include('<ds:X509SerialNumber>2</ds:X509SerialNumber>')
|
50
|
+
expect(subject.order_data).to include("<ds:X509Certificate>#{x_crt.data}</ds:X509Certificate>")
|
51
|
+
expect(subject.order_data).to include("<ds:X509Certificate>#{e_crt.data}</ds:X509Certificate>")
|
52
|
+
end
|
53
|
+
end
|
30
54
|
end
|
31
55
|
end
|
data/spec/orders/ini_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
RSpec.describe Epics::INI do
|
2
|
-
let(:client) { Epics::Client.new(
|
3
|
-
|
4
|
-
before { allow(subject).to receive(:timestamp) {
|
2
|
+
let(:client) { Epics::Client.new(key, 'secret', 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') }
|
3
|
+
let(:key) { File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', 'SIZBN001.key')) }
|
4
|
+
before { allow(subject).to receive(:timestamp) { '2014-10-10T11:16:00Z' } }
|
5
5
|
|
6
6
|
subject { described_class.new(client) }
|
7
7
|
|
@@ -9,9 +9,11 @@ RSpec.describe Epics::INI do
|
|
9
9
|
specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
|
10
10
|
|
11
11
|
describe 'validate against fixture' do
|
12
|
-
let(:signature_order_data)
|
12
|
+
let(:signature_order_data) do
|
13
|
+
Nokogiri::XML(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', 'xml', RUBY_ENGINE, 'ini.xml')))
|
14
|
+
end
|
13
15
|
|
14
|
-
it
|
16
|
+
it 'will match exactly' do
|
15
17
|
expect(Nokogiri::XML(subject.to_xml)).to be_equivalent_to(signature_order_data)
|
16
18
|
end
|
17
19
|
end
|
@@ -21,12 +23,29 @@ RSpec.describe Epics::INI do
|
|
21
23
|
specify { expect(subject.key_signature).to be_a_valid_ebics_doc }
|
22
24
|
|
23
25
|
describe 'validate against fixture' do
|
26
|
+
let(:signature_order_data) do
|
27
|
+
Nokogiri::XML(File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', 'xml',
|
28
|
+
'signature_pub_key_order_data.xml')))
|
29
|
+
end
|
24
30
|
|
25
|
-
|
26
|
-
|
27
|
-
it "will match exactly" do
|
31
|
+
it 'will match exactly' do
|
28
32
|
expect(Nokogiri::XML(subject.key_signature)).to be_equivalent_to(signature_order_data)
|
29
33
|
end
|
30
34
|
end
|
35
|
+
|
36
|
+
context 'with x509 certificate' do
|
37
|
+
let(:client) do
|
38
|
+
client = Epics::Client.new(key, 'secret', 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS')
|
39
|
+
client.x_509_certificates_content = {a: generate_x_509_crt(client.a.key, '/C=GB/O=TestOrg/CN=test.example.org')}
|
40
|
+
client
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'includes x509 certificate' do
|
44
|
+
a_crt = Epics::X509Certificate.new(client.x_509_certificates_content[:a])
|
45
|
+
expect(subject.key_signature).to include('<ds:X509IssuerName>/C=GB/O=TestOrg/CN=test.example.org</ds:X509IssuerName>')
|
46
|
+
expect(subject.key_signature).to include('<ds:X509SerialNumber>2</ds:X509SerialNumber>')
|
47
|
+
expect(subject.key_signature).to include("<ds:X509Certificate>#{a_crt.data}</ds:X509Certificate>")
|
48
|
+
end
|
49
|
+
end
|
31
50
|
end
|
32
51
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec.describe Epics::X509Certificate do
|
2
|
+
subject(:x_509_certificate) { described_class.new(crt_content) }
|
3
|
+
|
4
|
+
let(:key) { OpenSSL::PKey::RSA.new(2048) }
|
5
|
+
let(:crt_content) { generate_x_509_crt(key, distinguished_name) }
|
6
|
+
let(:distinguished_name) { '/C=GB/O=TestOrg/CN=test.example.org' }
|
7
|
+
|
8
|
+
describe '#issuer' do
|
9
|
+
it 'returns the issuer of the certificate' do
|
10
|
+
expect(x_509_certificate.issuer.to_s).to eq(distinguished_name)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#version' do
|
15
|
+
it 'returns the version of the certificate' do
|
16
|
+
expect(x_509_certificate.version).to eq(2)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#data' do
|
21
|
+
it 'returns the base64 encoded certificate data' do
|
22
|
+
expect(x_509_certificate.data).to start_with('MIIDDzCCAfegAwIBAgIBATANBgkqhkiG9w0BA')
|
23
|
+
expect(x_509_certificate.data).to end_with('==')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
RSpec.describe Epics::Z01 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, from: "2014-09-01", to: "2014-09-30") }
|
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,22 @@
|
|
1
|
+
def generate_x_509_crt(key, distinguished_name)
|
2
|
+
name = OpenSSL::X509::Name.parse(distinguished_name)
|
3
|
+
|
4
|
+
cert = OpenSSL::X509::Certificate.new
|
5
|
+
cert.version = 2
|
6
|
+
cert.serial = 1
|
7
|
+
cert.subject = name
|
8
|
+
cert.issuer = name
|
9
|
+
cert.public_key = key.public_key
|
10
|
+
cert.not_before = Time.now
|
11
|
+
cert.not_after = cert.not_before + 365 * 24 * 60 * 60
|
12
|
+
|
13
|
+
ef = OpenSSL::X509::ExtensionFactory.new
|
14
|
+
ef.subject_certificate = cert
|
15
|
+
ef.issuer_certificate = cert
|
16
|
+
cert.add_extension(ef.create_extension("basicConstraints", "CA:FALSE", true))
|
17
|
+
cert.add_extension(ef.create_extension("keyUsage", "digitalSignature,keyEncipherment,nonRepudiation", true))
|
18
|
+
|
19
|
+
cert.sign(key, OpenSSL::Digest::SHA256.new)
|
20
|
+
|
21
|
+
cert.to_pem
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lars Brillert
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: base64
|
@@ -249,6 +248,7 @@ files:
|
|
249
248
|
- lib/epics/haa.rb
|
250
249
|
- lib/epics/hac.rb
|
251
250
|
- lib/epics/header_request.rb
|
251
|
+
- lib/epics/hev.rb
|
252
252
|
- lib/epics/hia.rb
|
253
253
|
- lib/epics/hkd.rb
|
254
254
|
- lib/epics/hpb.rb
|
@@ -266,14 +266,17 @@ files:
|
|
266
266
|
- lib/epics/version.rb
|
267
267
|
- lib/epics/vmk.rb
|
268
268
|
- lib/epics/wss.rb
|
269
|
+
- lib/epics/x_509_certificate.rb
|
269
270
|
- lib/epics/xct.rb
|
270
271
|
- lib/epics/xds.rb
|
271
272
|
- lib/epics/xe2.rb
|
272
273
|
- lib/epics/xe3.rb
|
274
|
+
- lib/epics/z01.rb
|
273
275
|
- lib/epics/z52.rb
|
274
276
|
- lib/epics/z53.rb
|
275
277
|
- lib/epics/z54.rb
|
276
278
|
- lib/letter/ini.erb
|
279
|
+
- lib/letter/ini_with_certs.erb
|
277
280
|
- lib/letter/locales/de.yml
|
278
281
|
- lib/letter/locales/en.yml
|
279
282
|
- lib/letter/locales/fr.yml
|
@@ -340,6 +343,7 @@ files:
|
|
340
343
|
- spec/orders/fdl_spec.rb
|
341
344
|
- spec/orders/haa_spec.rb
|
342
345
|
- spec/orders/hac_spec.rb
|
346
|
+
- spec/orders/hev_spec.rb
|
343
347
|
- spec/orders/hia_spec.rb
|
344
348
|
- spec/orders/hkd_spec.rb
|
345
349
|
- spec/orders/hpb_spec.rb
|
@@ -350,9 +354,11 @@ files:
|
|
350
354
|
- spec/orders/sta_spec.rb
|
351
355
|
- spec/orders/vmk_spec.rb
|
352
356
|
- spec/orders/wss_spec.rb
|
357
|
+
- spec/orders/x_509_certificate_spec.rb
|
353
358
|
- spec/orders/xds_spec.rb
|
354
359
|
- spec/orders/xe2_spec.rb
|
355
360
|
- spec/orders/xe3_spec.rb
|
361
|
+
- spec/orders/z01_spec.rb
|
356
362
|
- spec/orders/z52_spec.rb
|
357
363
|
- spec/orders/z53_spec.rb
|
358
364
|
- spec/orders/z54_spec.rb
|
@@ -360,6 +366,7 @@ files:
|
|
360
366
|
- spec/signer_spec.rb
|
361
367
|
- spec/spec_helper.rb
|
362
368
|
- spec/support/ebics_matcher.rb
|
369
|
+
- spec/support/x_509_crt_generator.rb
|
363
370
|
- spec/xsd/ebics_H004.xsd
|
364
371
|
- spec/xsd/ebics_hev.xsd
|
365
372
|
- spec/xsd/ebics_keymgmt_request_H004.xsd
|
@@ -398,8 +405,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
398
405
|
- !ruby/object:Gem::Version
|
399
406
|
version: '0'
|
400
407
|
requirements: []
|
401
|
-
rubygems_version: 3.
|
402
|
-
signing_key:
|
408
|
+
rubygems_version: 3.6.8
|
403
409
|
specification_version: 4
|
404
410
|
summary: a ruby implementation of the EBICS protocol
|
405
411
|
test_files:
|
@@ -466,6 +472,7 @@ test_files:
|
|
466
472
|
- spec/orders/fdl_spec.rb
|
467
473
|
- spec/orders/haa_spec.rb
|
468
474
|
- spec/orders/hac_spec.rb
|
475
|
+
- spec/orders/hev_spec.rb
|
469
476
|
- spec/orders/hia_spec.rb
|
470
477
|
- spec/orders/hkd_spec.rb
|
471
478
|
- spec/orders/hpb_spec.rb
|
@@ -476,9 +483,11 @@ test_files:
|
|
476
483
|
- spec/orders/sta_spec.rb
|
477
484
|
- spec/orders/vmk_spec.rb
|
478
485
|
- spec/orders/wss_spec.rb
|
486
|
+
- spec/orders/x_509_certificate_spec.rb
|
479
487
|
- spec/orders/xds_spec.rb
|
480
488
|
- spec/orders/xe2_spec.rb
|
481
489
|
- spec/orders/xe3_spec.rb
|
490
|
+
- spec/orders/z01_spec.rb
|
482
491
|
- spec/orders/z52_spec.rb
|
483
492
|
- spec/orders/z53_spec.rb
|
484
493
|
- spec/orders/z54_spec.rb
|
@@ -486,6 +495,7 @@ test_files:
|
|
486
495
|
- spec/signer_spec.rb
|
487
496
|
- spec/spec_helper.rb
|
488
497
|
- spec/support/ebics_matcher.rb
|
498
|
+
- spec/support/x_509_crt_generator.rb
|
489
499
|
- spec/xsd/ebics_H004.xsd
|
490
500
|
- spec/xsd/ebics_hev.xsd
|
491
501
|
- spec/xsd/ebics_keymgmt_request_H004.xsd
|