einvoice 1.3 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8073afaa58225b965eeed8fb135712ab8b1b76c95b759324f35e875bf9eacb32
4
- data.tar.gz: ed9440ffcba86cdbf84e98b0030fb3e53c9e1b7418551c99cd102639c4921712
3
+ metadata.gz: 2393870fedb2a46c8a29d7c903b109080499b621904e46d45b505c33e8e3147c
4
+ data.tar.gz: c8ad7c8e9e6674887af0458bc00ed362e182ad39a2d30d7a4624f537e96e1c0d
5
5
  SHA512:
6
- metadata.gz: f0d297e2b70749e83b4ebf531ee49597d72ee6404a295eb3abd03c6e68e06da500cbbdfc6fe556fb8be761786b1ef4a9b11626e7e5758eda12f0cbf13420ba1d
7
- data.tar.gz: 75ca49a608cbd45bcc1fdc8575183d98ab079ec18684e073da6e944fc77f63eaa072e9e87d32e360ee8bda102dcccc9ed9b01fb3853d7a842d67368cd7de0f48
6
+ metadata.gz: d44581204a25dcd2f434510535ae5d5803263310ecbb6431590c5c9bc7398a10e63c0d9391c12d86417a2040cc5031c884fba915e7015c394ff32e14ed880801
7
+ data.tar.gz: 4076e9ef62d58aba07a0261dfee0b989d58a6eb41ade8b582e1770fde2f1f709e7a6308260a6b3312221454b1e97651489343cfc63beba4d8e86d9189868a10e
@@ -30,7 +30,10 @@ jobs:
30
30
  - name: Run tests
31
31
  run: bundle exec rspec
32
32
 
33
- - name: Publish code coverage
34
- uses: paambaati/codeclimate-action@v9
35
- env:
36
- CC_TEST_REPORTER_ID: 134e1f1cc8b60db4f2a491152c9227a6dbbfbeba5c1d05ee8b44cd78a1069f28
33
+ - name: Upload coverage to Codecov
34
+ if: matrix.ruby-version == '3.4'
35
+ uses: codecov/codecov-action@v5
36
+ with:
37
+ token: ${{ secrets.CODECOV_TOKEN }}
38
+ files: ./coverage/lcov.info
39
+ fail_ci_if_error: true
@@ -2,17 +2,30 @@ name: Daily update
2
2
  on:
3
3
  schedule:
4
4
  - cron: 0 0 * * *
5
+ workflow_dispatch:
6
+
7
+ permissions:
8
+ contents: write
9
+
5
10
  jobs:
6
11
  build:
7
- runs-on: ubuntu-22.04
12
+ runs-on: ubuntu-latest
8
13
  steps:
9
- - uses: actions/checkout@v3
10
- - uses: actions/setup-ruby@v1
11
- - name: bundle and run rake update
14
+ - uses: actions/checkout@v4
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: '3.3'
18
+ bundler-cache: true
19
+ - name: Update donation unit list
20
+ run: bundle exec rake update_donation_unit
21
+ - name: Commit and push changes
12
22
  run: |
13
- bundle install --jobs 4 --retry 3
14
- bundle exec rake update_donation_unit
15
- - uses: mikeal/publish-to-github-action@master
16
- env:
17
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18
- BRANCH_NAME: 'main'
23
+ if git diff --quiet; then
24
+ echo "Donation unit list is up to date"
25
+ exit 0
26
+ fi
27
+ git config user.name "github-actions[bot]"
28
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
29
+ git add lib/einvoice/donation_unit_list.json
30
+ git commit -m "Automated donation unit list update"
31
+ git push
data/CHANGELOG.md ADDED
@@ -0,0 +1,53 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/).
7
+
8
+ ## [1.4.0] - 2026-08-08
9
+
10
+ ### Changed
11
+ - **TLS certificate verification is now enabled by default.** Previously every
12
+ request was sent with `ssl: { verify: false }`, regardless of configuration.
13
+ If you were relying on that behavior (e.g. against an endpoint with an
14
+ incomplete certificate chain), set `config.ssl_verify = false` or pass
15
+ `ssl_verify: false` to `Provider.new` to restore the old behavior.
16
+ - `Client` now delegates to the provider via `public_send` instead of `send`,
17
+ and implements `respond_to_missing?`. Private provider methods (e.g.
18
+ `encrypt`, `connection`) are no longer reachable through `Client`.
19
+
20
+ ### Fixed
21
+ - `TotalValidator` comparison was inverted and compared a `String` against an
22
+ `Integer`, so it never actually validated anything. It now correctly fails
23
+ when `total` doesn't match the sum of item totals.
24
+ - `AllowanceNumberValidator` and `IssueItem#invoiceTime`'s format regexp had
25
+ broken escape sequences (`\A` and `\d` collapsing to literal characters in a
26
+ double-quoted string), causing them to reject all valid input.
27
+ - `ItemListValidator` pushed directly onto `record.errors[:itemList]`, which
28
+ is deprecated in Rails 6.1 and removed in 7.0. It now uses `errors.add` and
29
+ actually registers errors again.
30
+ - Tradevan response decoding used `JSON.load`, which is unsafe for untrusted
31
+ input. Switched to `JSON.parse`.
32
+ - `lib/einvoice/donation_unit_list.json` was stale since 2023-12 (the
33
+ scheduled update workflow had been silently broken), causing
34
+ `DonationUnitValidator` to reject currently valid donation codes and accept
35
+ retired ones. The list has been refreshed (~340 entries changed).
36
+
37
+ ### Added
38
+ - Specs for `Client` delegation, `Configuration#ssl_verify`,
39
+ `Provider#connection` SSL behavior, the validator fixes above, and the
40
+ previously-untested `decode_tradevan` middleware.
41
+
42
+ ### Internal
43
+ - CI coverage reporting migrated from Code Climate (discontinued) to Codecov.
44
+ - The scheduled `cron.yml` workflow that refreshes the donation unit list
45
+ has been repaired — it depended on two archived GitHub Actions
46
+ (`actions/setup-ruby`, `mikeal/publish-to-github-action`) and hadn't run
47
+ successfully since 2023-12.
48
+
49
+ ---
50
+
51
+ Versions prior to 1.4.0 were not tracked in this file. See the
52
+ [release history](https://github.com/abookyun/einvoice/releases) and
53
+ [commit log](https://github.com/abookyun/einvoice/commits/main/) for earlier changes.
data/Gemfile CHANGED
@@ -3,7 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in einvoice.gemspec
4
4
  gemspec
5
5
 
6
- # Integrate CodeClimate Code Coverage into TravisCI
7
- # https://github.com/codeclimate/test-reporter/issues/413
8
- gem 'simplecov', require: false, group: :test
9
- gem "simplecov_json_formatter", require: false, group: :test
6
+ gem "ostruct", require: false, group: :development
7
+ gem "simplecov", require: false, group: :test
8
+ gem "simplecov-lcov", require: false, group: :test
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Einvoice
2
2
  [![Build Status](https://github.com/abookyun/einvoice/actions/workflows/build.yml/badge.svg)](https://github.com/abookyun/einvoice/actions/workflows/build.yml)
3
- [![Code Climate](https://codeclimate.com/github/abookyun/einvoice/badges/gpa.svg)](https://codeclimate.com/github/abookyun/einvoice)
4
- [![Test Coverage](https://codeclimate.com/github/abookyun/einvoice/badges/coverage.svg)](https://codeclimate.com/github/abookyun/einvoice/coverage)
3
+ [![codecov](https://codecov.io/github/abookyun/einvoice/graph/badge.svg?token=yxJNmXiUyp)](https://codecov.io/github/abookyun/einvoice)
5
4
 
6
5
  ## What's E-Invoice
7
6
 
@@ -42,8 +41,25 @@ Einvoice.configure do |config|
42
41
  config.client_secret = ENV['EINVOICE_CLIENT_SECRET']
43
42
  config.encryption_keys = ENV['ENCRYPTION_KEYS']
44
43
  config.format = "json"
44
+ # config.ssl_verify = false # disable TLS certificate verification (default: true)
45
45
  end
46
46
  ```
47
+ ### SSL certificate verification
48
+
49
+ By default, `einvoice` verifies the TLS certificate of the configured
50
+ endpoint (`config.ssl_verify` defaults to `true`). If you need to disable
51
+ this — for example when testing against an endpoint with an incomplete
52
+ certificate chain — you can opt out:
53
+
54
+ ```ruby
55
+ config.ssl_verify = false
56
+ ```
57
+
58
+ Or per-provider:
59
+
60
+ ```ruby
61
+ Einvoice::Tradevan::Provider.new(ssl_verify: false)
62
+ ```
47
63
 
48
64
  ### Initialize
49
65
 
@@ -7,7 +7,15 @@ module Einvoice
7
7
  end
8
8
 
9
9
  def method_missing(m, *args, &block)
10
- provider.send(m, *args, &block)
10
+ if provider.respond_to?(m)
11
+ provider.public_send(m, *args, &block)
12
+ else
13
+ super
14
+ end
15
+ end
16
+
17
+ def respond_to_missing?(m, include_private = false)
18
+ provider.respond_to?(m) || super
11
19
  end
12
20
  end
13
21
  end
@@ -8,7 +8,8 @@ module Einvoice
8
8
  :client_id,
9
9
  :client_secret,
10
10
  :encryption_keys,
11
- :format
11
+ :format,
12
+ :ssl_verify
12
13
  ].freeze
13
14
 
14
15
  DEFAULT_CLIENT_ID = nil
@@ -17,6 +18,7 @@ module Einvoice
17
18
  DEFAULT_ENDPOINT_URL = nil
18
19
  DEFAULT_FORMAT = ""
19
20
  DEFAULT_ENCRYPTION_KEYS = {}
21
+ DEFAULT_SSL_VERIFY = true
20
22
 
21
23
  attr_accessor *VALID_OPTIONS_KEYS
22
24
 
@@ -41,6 +43,7 @@ module Einvoice
41
43
  self.endpoint_url = DEFAULT_ENDPOINT_URL
42
44
  self.encryption_keys = DEFAULT_ENCRYPTION_KEYS
43
45
  self.format = DEFAULT_FORMAT
46
+ self.ssl_verify = DEFAULT_SSL_VERIFY
44
47
  end
45
48
  end
46
49
  end
@@ -8,7 +8,8 @@ module Einvoice
8
8
  def connection(options = {})
9
9
  connection_options = {
10
10
  headers: { "Accept" => "application/#{format}; charset=utf-8" },
11
- url: endpoint
11
+ url: endpoint,
12
+ ssl: { verify: ssl_verify != false }
12
13
  }.merge(options)
13
14
 
14
15
  ::Faraday::Connection.new(connection_options) do |connection|