epics 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51b94d179773db218f4e12893aad065b478fe4fc
4
- data.tar.gz: 221ef01157bbcd652e17e6bd7d05d97edeef0765
3
+ metadata.gz: ffb2fe355ff8d4811bff967cf20cf742cbd688a5
4
+ data.tar.gz: 5edb7d8ee8bbc115a97646fa10eb41eff0780a9c
5
5
  SHA512:
6
- metadata.gz: bf71172943ed9c56975b555550277cc1a066a93f6e473b03819833f047c4ae328d50baf7419f535c1c8a62f4ecc64c46dba6fd68ad236d775d676dba5030dbef
7
- data.tar.gz: b99b8db9d8a5a332012600d74ccde6fbcfeab0962edb33d34359c2abc2c37fdcfa94052edd0cfe622d23ad09414fc97d422cc2a8627f2da2554667c612115001
6
+ metadata.gz: 6d51f0ac477dac99702a10886ada30c5bb8bca9836cf4480b800a7717630d5b34183ef8246834e515e8e4a84753dbae11d0c031fe340c51e1af79c641e3ccd60
7
+ data.tar.gz: cc2220b2f3456e12e68cdc392873439a2ae634303276130a444ab9b504e081266db6924d31b83fc3544aa17f4efb6d538bd40d8b5555b5a3e595fb2d831c835f
data/.travis.yml CHANGED
@@ -1,6 +1,10 @@
1
1
  language: ruby
2
+ env:
3
+ - JAVA_OPTS=-Djava.security.egd=file:/dev/./urandom --server -Dcext.enabled=false -Xcompile.invokedynamic=false
2
4
  rvm:
3
5
  - 2.0.0
4
- - 2.1.8
5
- - 2.2.4
6
- - jruby
6
+ - 2.1.10
7
+ - 2.2.7
8
+ - 2.3.4
9
+ - 2.4.1
10
+ - jruby-9.1.10.0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### 1.5.0
2
+
3
+ * [ENHANCEMENT] support for fetching the C54 order type
4
+ * [ENHANCEMENT] Exceptions expose their internal code via `code`
5
+ * [HOUSEKEEPING] Added Ruby 2.4 compatibility
6
+ * [HOUSEKEEPING] Drop Ruby 2.0.0
7
+
1
8
  ### 1.4.1
2
9
 
3
10
  * [ENHANCEMENT] support for fetching the VMK order type
data/README.md CHANGED
@@ -8,7 +8,7 @@ Communication Standard).
8
8
 
9
9
  The client supports the complete initialization process comprising INI, HIA and HPB including the
10
10
  INI letter generation. It offers support for the most common download and upload order types
11
- (STA HAA HTD HPD PKT HAC HKD C52 C53 CD1 CDD CCT VMK).
11
+ (STA HAA HTD HPD PKT HAC HKD C52 C53 C54 CD1 CDD CCT VMK).
12
12
 
13
13
 
14
14
  ## Installation
@@ -41,7 +41,7 @@ Once the paperwork is done, your bank should provide you with:
41
41
  Take these parameters and start setting up an UserID (repeat this for every user you want to initialize):
42
42
 
43
43
  ```ruby
44
- e = Epics::Client.setup("my-super-secret", "https://ebics.sandbox", "SIZBN001", "EBIX", "EPICS")
44
+ e = Epics::Client.setup("my-super-secret", "https://ebics.sandbox", "EBICS_HOST_ID", "EBICS_USER_ID", "EBICS_PARTNER_ID")
45
45
  ```
46
46
 
47
47
  To use the keys later, just store them in a file
@@ -208,14 +208,38 @@ This gem provides a full implementation of the Electronic Banking Internet Commu
208
208
  and works with any bank that supports this standard. Please ask your bank if they support EBICS and
209
209
  what order types are available.
210
210
 
211
- Besides EBCIS being a standard, some server implementations are slighty different.
212
- Is Epics working with your institution?
213
- Please help us to grow this list of supported banks:
211
+ Besides EBCIS being a standard, some server implementations are slighty different.
212
+ But most banks use the same EBICS server implementations. Commonly used and supported by Epics are:
213
+
214
+ * Business-Logics EBICS, Banking-Server
215
+ * Travic Corporate
216
+
217
+ Used for example by the following tested institutions:
214
218
 
215
219
  * Handelsbank
216
220
  * Deutsche Bank
217
- * Sparkasse Köln Bonn
218
221
  * Commerzbank
222
+ * Kreissparkasse Mayen
223
+ * Postbank
224
+ * Sozialbank
225
+ * Sparkassen
226
+ * Volksbanken Raiffeisenbanken
227
+ * Hypo Vereinsbank
228
+
229
+ Is Epics working with your institution? Please help us to grow this list of supported banks:
230
+
231
+
232
+ ## Development
233
+
234
+ For development purposes, you may want to use a proxy server in order to have a convienent look into request and response data.
235
+ To do so, it's sufficient to define `http_proxy` in your environment.
236
+ Also you may want to disable SSL verification - simply set `EPICS_VERIFY_SSL` to `"false"`.
237
+
238
+ For example:
239
+ ```
240
+ http_proxy=localhost:8080
241
+ EPICS_VERIFY_SSL=false
242
+ ```
219
243
 
220
244
  ## Links
221
245
 
@@ -236,4 +260,4 @@ Please help us to grow this list of supported banks:
236
260
 
237
261
 
238
262
  ------------
239
- 2014 - built with love by [Railslove](http://railslove.com) and released under the [GNU LESSER GENERAL PUBLIC LICENSE](https://github.com/railslove/epics/blob/master/LICENSE.txt). We have built quite a number of FinTech products. If you need support we are happy to help. Please contact us at team@railslove.com.
263
+ 2014-2017 - built with love by [Railslove](http://railslove.com) and released under the [GNU LESSER GENERAL PUBLIC LICENSE](https://github.com/railslove/epics/blob/master/LICENSE.txt). We have built quite a number of FinTech products. If you need support we are happy to help. Please contact us at team@railslove.com.
data/epics.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  including the INI letter generation.
17
17
 
18
18
  Furthermore it offers support for the most common download types:
19
- STA HAA HTD HPD PKT HAC HKD C52 C53
19
+ STA HAA HTD HPD PKT HAC HKD C52 C53 C54
20
20
 
21
21
  And the following upload orders:
22
22
  CD1 CDD CCT
@@ -25,6 +25,8 @@ Gem::Specification.new do |spec|
25
25
  spec.homepage = "https://github.com/railslove/epics"
26
26
  spec.license = "LGPL-3.0"
27
27
 
28
+ spec.required_ruby_version = '>= 2.0'
29
+
28
30
  spec.files = `git ls-files -z`.split("\x0")
29
31
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
30
32
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
@@ -37,7 +39,12 @@ Gem::Specification.new do |spec|
37
39
  spec.post_install_message += "Please create an issue on github (railslove/epics) if anything does not work as expected. And contact team@railslove.com if you are looking for support with your integration.\n"
38
40
  spec.post_install_message += "\e[32m" + ("*" * 60) + "\n\e[0m"
39
41
 
40
- spec.add_dependency "nokogiri"
42
+ if RUBY_VERSION < '2.1'
43
+ spec.add_dependency "nokogiri", '< 1.7.0'
44
+ else
45
+ spec.add_dependency "nokogiri"
46
+ end
47
+
41
48
  spec.add_dependency "gyoku"
42
49
  spec.add_dependency "faraday"
43
50
  spec.add_dependency "rubyzip", ">= 1.0.0"
data/lib/epics.rb CHANGED
@@ -26,6 +26,7 @@ require "epics/sta"
26
26
  require "epics/vmk"
27
27
  require "epics/c52"
28
28
  require "epics/c53"
29
+ require "epics/c54"
29
30
  require "epics/ptk"
30
31
  require "epics/hac"
31
32
  require "epics/hpd"
data/lib/epics/c54.rb ADDED
@@ -0,0 +1,52 @@
1
+ class Epics::C54 < Epics::GenericRequest
2
+ attr_accessor :from, :to
3
+
4
+ def initialize(client, from, to)
5
+ super(client)
6
+ self.from = from
7
+ self.to = to
8
+ end
9
+
10
+ def header
11
+ {
12
+ :@authenticate => true,
13
+ static: {
14
+ "HostID" => host_id,
15
+ "Nonce" => nonce,
16
+ "Timestamp" => timestamp,
17
+ "PartnerID" => partner_id,
18
+ "UserID" => user_id,
19
+ "Product" => {
20
+ :@Language => "de",
21
+ :content! => "EPICS - a ruby ebics kernel"
22
+ },
23
+ "OrderDetails" => {
24
+ "OrderType" => "C54",
25
+ "OrderAttribute" => "DZHNN",
26
+ "StandardOrderParams" => {
27
+ "DateRange" => {
28
+ "Start" => from,
29
+ "End" => to
30
+ }
31
+ }
32
+ },
33
+ "BankPubKeyDigests" => {
34
+ "Authentication" => {
35
+ :@Version => "X002",
36
+ :@Algorithm => "http://www.w3.org/2001/04/xmlenc#sha256",
37
+ :content! => client.bank_x.public_digest
38
+ },
39
+ "Encryption" => {
40
+ :@Version => "E002",
41
+ :@Algorithm => "http://www.w3.org/2001/04/xmlenc#sha256",
42
+ :content! => client.bank_e.public_digest
43
+ }
44
+ },
45
+ "SecurityMedium" => "0000"
46
+ },
47
+ "mutable" => {
48
+ "TransactionPhase" => "Initialisation"
49
+ }
50
+ }
51
+ end
52
+ end
data/lib/epics/client.rb CHANGED
@@ -102,8 +102,12 @@ class Epics::Client
102
102
  exponent = Base64.decode64(node.at_xpath(".//*[local-name() = 'Exponent']").content)
103
103
 
104
104
  bank = OpenSSL::PKey::RSA.new
105
- bank.n = OpenSSL::BN.new(modulus, 2)
106
- bank.e = OpenSSL::BN.new(exponent, 2)
105
+ if bank.respond_to?(:set_key)
106
+ bank.set_key(OpenSSL::BN.new(modulus, 2), OpenSSL::BN.new(exponent, 2), nil)
107
+ else
108
+ bank.n = OpenSSL::BN.new(modulus, 2)
109
+ bank.e = OpenSSL::BN.new(exponent, 2)
110
+ end
107
111
 
108
112
  self.keys["#{host_id.upcase}.#{type}"] = Epics::Key.new(bank)
109
113
  end
@@ -139,6 +143,10 @@ class Epics::Client
139
143
  download_and_unzip(Epics::C53, from, to)
140
144
  end
141
145
 
146
+ def C54(from, to)
147
+ download_and_unzip(Epics::C54, from, to)
148
+ end
149
+
142
150
  def HAA
143
151
  Nokogiri::XML(download(Epics::HAA)).at_xpath("//xmlns:OrderTypes", xmlns: "urn:org:ebics:H004").content.split(/\s/)
144
152
  end
@@ -206,7 +214,7 @@ class Epics::Client
206
214
  end
207
215
 
208
216
  def connection
209
- @connection ||= Faraday.new(headers: {user_agent: "EPICS v#{Epics::VERSION}"}) do |faraday|
217
+ @connection ||= Faraday.new(headers: {user_agent: "EPICS v#{Epics::VERSION}"}, ssl: { verify: verify_ssl? }) do |faraday|
210
218
  faraday.use Epics::XMLSIG, { client: self }
211
219
  faraday.use Epics::ParseEbics, { client: self}
212
220
  # faraday.response :logger # log requests to STDOUT
@@ -225,7 +233,7 @@ class Epics::Client
225
233
  end
226
234
 
227
235
  def cipher
228
- @cipher ||= OpenSSL::Cipher::Cipher.new("aes-256-cbc")
236
+ @cipher ||= OpenSSL::Cipher.new("aes-256-cbc")
229
237
  end
230
238
 
231
239
  def encrypt(data)
@@ -249,4 +257,7 @@ class Epics::Client
249
257
  cipher.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(passphrase, salt, 1, cipher.key_len)
250
258
  end
251
259
 
260
+ def verify_ssl?
261
+ ENV['EPICS_VERIFY_SSL'] != 'false'
262
+ end
252
263
  end
data/lib/epics/error.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  class Epics::Error < StandardError
2
+
3
+ attr_reader :code
4
+
2
5
  def to_s
3
6
  [@error.fetch("symbol", "EPICS_UNKNOWN"), @error.fetch("short_text", "unknown")].join(" - ")
4
7
  end
@@ -8,6 +11,15 @@ class Epics::Error < StandardError
8
11
  @error = self.class::ERRORS.fetch(code, {})
9
12
  end
10
13
 
14
+ def symbol
15
+ @error.fetch("symbol", "EPICS_UNKNOWN")
16
+ end
17
+
18
+ def short_text
19
+ @error.fetch("short_text", "unknown")
20
+ end
21
+
22
+
11
23
  class TechnicalError < self
12
24
  ERRORS = {
13
25
  "000000" => {
@@ -10,7 +10,7 @@ class Epics::GenericUploadRequest < Epics::GenericRequest
10
10
  end
11
11
 
12
12
  def cipher
13
- @cipher ||= OpenSSL::Cipher::Cipher.new("aes-128-cbc")
13
+ @cipher ||= OpenSSL::Cipher.new("aes-128-cbc")
14
14
  end
15
15
 
16
16
  def digester
@@ -84,7 +84,7 @@ class Epics::Response
84
84
  end
85
85
 
86
86
  def cipher
87
- cipher = OpenSSL::Cipher::Cipher.new("aes-128-cbc")
87
+ cipher = OpenSSL::Cipher.new("aes-128-cbc")
88
88
 
89
89
  cipher.decrypt
90
90
  cipher.padding = 0
data/lib/epics/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Epics
2
- VERSION = "1.4.1"
2
+ VERSION = "1.5.0"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -22,6 +22,28 @@ RSpec.describe Epics::Client do
22
22
 
23
23
  end
24
24
 
25
+ context 'environment settings' do
26
+ before(:each) do
27
+ ENV.delete('EPICS_VERIFY_SSL')
28
+ end
29
+
30
+ describe '#verify_ssl?' do
31
+ it 'verifies ssl by default' do
32
+ expect(subject.send(:verify_ssl?)).to eq true
33
+ end
34
+
35
+ it 'verifies ssl if there\'s something strange set to your env' do
36
+ ENV['EPICS_VERIFY_SSL'] = 'somethingstrange'
37
+ expect(subject.send(:verify_ssl?)).to eq true
38
+ end
39
+
40
+ it 'skips ssl verification if you want to' do
41
+ ENV['EPICS_VERIFY_SSL'] = 'false'
42
+ expect(subject.send(:verify_ssl?)).to eq false
43
+ end
44
+ end
45
+ end
46
+
25
47
  describe '#inspect' do
26
48
  it 'will not print the complete object' do
27
49
  expect(subject.inspect).to include("@keys=#{subject.keys.keys}")
@@ -131,13 +153,15 @@ RSpec.describe Epics::Client do
131
153
  end
132
154
  end
133
155
 
134
- describe '#C53/C52 types with zipped data' do
156
+ describe '#C53/C52/C54 types with zipped data' do
135
157
  before do
136
158
  allow(subject).to receive(:download).and_return( File.read(File.join(File.dirname(__FILE__), 'fixtures', 'test.zip') ))
137
159
  end
138
160
 
139
161
  it 'will unzip the returned data' do
140
- expect(subject.C53(:today, :yesterday)).to eq(["ebics is great\n"])
162
+ %w(C52 C53 C54).each do |c|
163
+ expect(subject.send(c, :today, :yesterday)).to eq(["ebics is great\n"])
164
+ end
141
165
  end
142
166
  end
143
167
  end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe Epics::Error::BusinessError do
4
+
5
+ subject { Epics::Error::BusinessError.new(code) }
6
+
7
+ before do
8
+ stub_const("Epics::Error::BusinessError::ERRORS", {
9
+ "123" => {
10
+ "symbol" => "BOTTMUEHLE",
11
+ "short_text" => "home of awesome",
12
+ }
13
+ })
14
+ end
15
+
16
+ let(:code) { '123' }
17
+
18
+ describe '#to_s' do
19
+
20
+ it 'returns a message composed of symbol and short text' do
21
+ expect(subject.to_s).to eql('BOTTMUEHLE - home of awesome')
22
+ end
23
+ end
24
+
25
+ describe '#code' do
26
+ it 'returns the code' do
27
+ expect(subject.code).to eql('123')
28
+ end
29
+ end
30
+
31
+ describe '#symbol' do
32
+ it 'returns the symbol' do
33
+ expect(subject.symbol).to eql('BOTTMUEHLE')
34
+ end
35
+ end
36
+
37
+ describe '#short_text' do
38
+ it 'returns the short text' do
39
+ expect(subject.short_text).to eql('home of awesome')
40
+ end
41
+ end
42
+
43
+ end
@@ -18,7 +18,8 @@ RSpec.describe Epics::GenericUploadRequest do
18
18
  end
19
19
 
20
20
  describe '#signature_value' do
21
- before { allow(OpenSSL::Random).to receive(:random_bytes).and_return(Base64.strict_decode64("7wtROfiX4tyN60cygJUSsHkhzxX1RVJa8vGNYnflvKc=")) }
21
+ before { allow(OpenSSL::Random).to receive(:random_bytes).with(16).and_return("\x01" * 16) } # fake random_key requires a 16byte lenght but is not used in this test
22
+ before { allow(OpenSSL::Random).to receive(:random_bytes).with(32).and_return(Base64.strict_decode64("7wtROfiX4tyN60cygJUSsHkhzxX1RVJa8vGNYnflvKc=")) } # digest requires 32 bytes
22
23
 
23
24
  it 'will be the signed document' do
24
25
  expect(subject.signature_value).to eq("BQBMyxGHYoAbbmbMJRFbGrvUNinY15+qeeRLF708VL+tuENnbJMO6xHLWxU1rksOnu4xDzxfua9b3IxIaxLyTTFDuVi6bbu3sBslhIt2frdigo0xBL14KUJQ/pYiMj+2pfNYhtVxzamrnvgPSLNAEn36JykK2d347chT87HlZ7CAGNBS7lJHAzRP1v7Hkc+kKttkkWCpOGk06R6FUCxxVKXmQketMEl/scsMyJ3JtBe/EcjEZdDe5WcqZYUu5ARrfEiAeyutVRZnu17c3nKwkmWl7UqFAwp16cS8IPNL4i5FGCytgKl/kyaoxaE/P1lrGOkHcCTsSR0bAbARhndfdQ==")
@@ -0,0 +1,11 @@
1
+ RSpec.describe Epics::C54 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, "2014-09-01", "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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Brillert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-13 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -157,7 +157,7 @@ description: |2
157
157
  including the INI letter generation.
158
158
 
159
159
  Furthermore it offers support for the most common download types:
160
- STA HAA HTD HPD PKT HAC HKD C52 C53
160
+ STA HAA HTD HPD PKT HAC HKD C52 C53 C54
161
161
 
162
162
  And the following upload orders:
163
163
  CD1 CDD CCT
@@ -180,6 +180,7 @@ files:
180
180
  - lib/epics.rb
181
181
  - lib/epics/c52.rb
182
182
  - lib/epics/c53.rb
183
+ - lib/epics/c54.rb
183
184
  - lib/epics/cct.rb
184
185
  - lib/epics/cd1.rb
185
186
  - lib/epics/cdb.rb
@@ -209,6 +210,7 @@ files:
209
210
  - lib/letter/ini.erb
210
211
  - spec/.DS_Store
211
212
  - spec/client_spec.rb
213
+ - spec/error_spec.rb
212
214
  - spec/fixtures/.DS_Store
213
215
  - spec/fixtures/SIZBN001.key
214
216
  - spec/fixtures/a006.pem
@@ -242,6 +244,7 @@ files:
242
244
  - spec/middleware/parse_ebics_spec.rb
243
245
  - spec/orders/c52_spec.rb
244
246
  - spec/orders/c53_spec.rb
247
+ - spec/orders/c54_spec.rb
245
248
  - spec/orders/cct_spec.rb
246
249
  - spec/orders/cd1_spec.rb
247
250
  - spec/orders/cdb_spec.rb
@@ -288,7 +291,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
288
291
  requirements:
289
292
  - - ">="
290
293
  - !ruby/object:Gem::Version
291
- version: '0'
294
+ version: '2.0'
292
295
  required_rubygems_version: !ruby/object:Gem::Requirement
293
296
  requirements:
294
297
  - - ">="
@@ -303,6 +306,7 @@ summary: a ruby implementation of the EBICS protocol
303
306
  test_files:
304
307
  - spec/.DS_Store
305
308
  - spec/client_spec.rb
309
+ - spec/error_spec.rb
306
310
  - spec/fixtures/.DS_Store
307
311
  - spec/fixtures/SIZBN001.key
308
312
  - spec/fixtures/a006.pem
@@ -336,6 +340,7 @@ test_files:
336
340
  - spec/middleware/parse_ebics_spec.rb
337
341
  - spec/orders/c52_spec.rb
338
342
  - spec/orders/c53_spec.rb
343
+ - spec/orders/c54_spec.rb
339
344
  - spec/orders/cct_spec.rb
340
345
  - spec/orders/cd1_spec.rb
341
346
  - spec/orders/cdb_spec.rb