pisoni 1.30.0 → 1.31.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: bc7b659e66478ddb954b8144e47cd83cbf80acd54e16f7f051c82f07f47c221f
4
- data.tar.gz: fb1ab6344af206a17085bf42134622fef72e57093bad247ce8efaa2b823b8ff6
3
+ metadata.gz: 5804502f649cd2bb89c6a7e696684c4226c53430e4c132e4f82fd755d4e1a96d
4
+ data.tar.gz: 354583b6d17ebdf0a5ed15c7121ab5b550ce008e3383c1fab17ac5f8a66c8a97
5
5
  SHA512:
6
- metadata.gz: 2b39b7a9ed13db3500fb782b1f1f5e75cc9d15261938f70e11788f84a96957a6f38ca3cc801bf84f7b5ee94cb4bac4a1bfed12ec9a4bc99fb5c01f73ed4ea860
7
- data.tar.gz: 1de636e31c5d8c5897eda7282283a157553a032c81f26b58378c39a342021786285b851c59bd786dbbf3f5ea536ed3cd4f564c415240887af136e46e18345c2f
6
+ metadata.gz: a25cc7464fe34178899e3239fc39d0ce394e70dfb68f9cc6f4ebe0c062dfe3f72975d2158132df9fadb65d488f18fb6f19b0fc3d0d803fb0093fb3f5f976a100
7
+ data.tar.gz: 8343b9dae4eac7195396cc48563a3df20c07b5402dd4ef5010a100bda895833664845131e91c0838d7788f32258cdb6763989c8cf02ed45e337c4748e3236e6b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  Notable changes to Pisoni will be tracked in this document.
4
4
 
5
+ ## 1.31.0 - 2026-07-03
6
+
7
+ ### Added
8
+
9
+ - Batch update support for applications via `Application.save_batch`. [#37](https://github.com/3scale/pisoni/pull/37)
10
+ - Qlty integration for code quality and coverage reporting, replacing codeclimate. [#39](https://github.com/3scale/pisoni/pull/39)
11
+
12
+ ### Changed
13
+
14
+ - Updated Faraday dependency to allow >= 2.14.3 (removed <= 2.9 cap). [#36](https://github.com/3scale/pisoni/pull/36)
15
+ - Minimum Ruby version bumped from 2.6 to 3.0 (required by Faraday >= 2.9). [#36](https://github.com/3scale/pisoni/pull/36)
16
+ - CircleCI now requires manual approval before running builds. [#38](https://github.com/3scale/pisoni/pull/38)
17
+ - Pinned minitest to ~> 5.0 to prevent breakage from minitest 6. [#36](https://github.com/3scale/pisoni/pull/36)
18
+
5
19
  ## 1.30.0 - 2024-02-29
6
20
 
7
21
  ### Changed
data/Gemfile CHANGED
@@ -3,8 +3,9 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  group :test do
6
- gem 'minitest'
7
- gem "codeclimate-test-reporter", require: nil
6
+ gem 'minitest', '~> 5.0'
7
+ gem 'simplecov', require: false
8
+ gem 'simplecov_json_formatter', require: false
8
9
  end
9
10
 
10
11
  group :development, :test do
data/Makefile CHANGED
@@ -1,78 +1,24 @@
1
- MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
2
- PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
1
+ COMPOSE ?= podman-compose
3
2
 
4
- include $(PROJECT_PATH)/.env
3
+ .PHONY: deps_up
4
+ deps_up:
5
+ $(COMPOSE) up -d
5
6
 
6
- include $(PROJECT_PATH)/mk/compose.mk
7
- COMPOSE ?= $(COMPOSE_BIN) -f $(PROJECT_PATH)/docker/docker-compose.yml -f $(PROJECT_PATH)/docker/docker-compose.apisonator.yml
8
-
9
- CI_IMAGE_REPO ?= quay.io/3scale
10
- CI_IMAGE_NAME ?= pisoni-ci
11
- CI_IMAGE ?= $(CI_IMAGE_REPO)/$(CI_IMAGE_NAME)
12
- CI_DOCKERFILE ?= $(PROJECT_PATH)/docker/Dockerfile.ci
13
-
14
- include $(PROJECT_PATH)/mk/ci-image.mk
15
- include $(PROJECT_PATH)/mk/ci.mk
16
-
17
- all: clean pull build test
18
-
19
- $(call ci_build_target,ci-pull,pull)
20
- $(call ci_build_target,ci-test,test)
21
- $(call ci_build_target,ci-compose-config,compose-config)
7
+ .PHONY: deps_down
8
+ deps_down:
9
+ - $(COMPOSE) down
22
10
 
23
- .PHONY: compose-config
24
- compose-config: compose
25
- $(COMPOSE) config
11
+ .PHONY: run_test
12
+ run_test:
13
+ THREESCALE_CORE_INTERNAL_API=http://user:password@localhost:3001 bundle exec rake test
26
14
 
27
15
  .PHONY: test
28
- test: run_test clean
29
-
30
- .PHONY: bash
31
- bash: run clean
32
-
33
- .PHONY: dev
34
- dev: run
35
-
36
- .PHONY: run
37
- run: compose
38
- $(COMPOSE) run --rm test /bin/bash
39
-
40
- .PHONY: run_test
41
- run_test: compose
42
- $(COMPOSE) run --rm -e COVERAGE=$(COVERAGE) test
16
+ test: deps_up run_test deps_down
43
17
 
44
18
  .PHONY: license_finder
45
- license_finder: compose
46
- $(COMPOSE) run --rm -e COVERAGE=$(COVERAGE) test bundle exec rake license_finder:check
47
-
48
- .PHONY: build
49
- build: compose
50
- $(COMPOSE) build
51
-
52
- .PHONY: pull
53
- pull: compose
54
- $(COMPOSE) pull
19
+ license_finder:
20
+ $(COMPOSE) run --rm -e COVERAGE=$(COVERAGE) pisoni bundle exec rake license_finder:check
55
21
 
56
22
  .PHONY: stop
57
- stop: compose
23
+ stop:
58
24
  $(COMPOSE) stop
59
-
60
- .PHONY: clean
61
- clean: stop
62
- - $(COMPOSE) rm -f -v
63
-
64
- .PHONY: up
65
- up: compose
66
- $(COMPOSE) up --abort-on-container-exit --exit-code-from test -t 2 --remove-orphans
67
-
68
- .PHONY: down
69
- down: clean
70
- - $(COMPOSE) down
71
-
72
- .PHONY: destroy
73
- destroy: clean
74
- $(COMPOSE) down -v --remove-orphans --rmi local
75
-
76
- .PHONY: destroy-all
77
- destroy-all: clean
78
- $(COMPOSE) down -v --remove-orphans --rmi all
data/README.md CHANGED
@@ -23,22 +23,16 @@ where x.y.z is the version you aim for.
23
23
 
24
24
  ## Development
25
25
 
26
- ### Environment set up
26
+ ### Running tests with `make` and `podman-compose`
27
27
 
28
- We are using [Docker Compose](https://docs.docker.com/compose/) to run the tests
29
- in an isolated environment.
28
+ We are using [podman-compose](https://github.com/containers/podman-compose) to run the dependencies (redis and apisonator) for the tests.
29
+ You need to have it installed locally.
30
30
 
31
- You should first `make pull build` to download the needed images and build the
32
- one used for actual testing and development.
31
+ You can run the test suite (with the required dependencies) by executing `make test`.
33
32
 
34
- You can then run `make test` to run the test suite, and `make dev` to enter
35
- a container in which the code is sync'ed back to your host.
33
+ For cleaning up the dependencies containers, you can run `make deps_down`.
36
34
 
37
- For cleaning up containers, volumes and networks you can run `make clean` and
38
- `make destroy`. If you want to also get rid of pulled images, run `make
39
- destroy-all`.
40
-
41
- ### Running tests
35
+ ### Running tests locally
42
36
 
43
37
  You can run both tests & specs with:
44
38
 
@@ -63,6 +63,11 @@ module ThreeScale
63
63
  api_do_delete(attributes, api_options, &blk)[:ok]
64
64
  end
65
65
 
66
+ def api_update_batch(attributes, api_options = {}, &blk)
67
+ ret = api_do_put(attributes, api_options.merge(prefix: ''), &blk)
68
+ ret[:response_json]
69
+ end
70
+
66
71
  # Helpers
67
72
 
68
73
  def api_do_get(attributes, api_options = {}, &blk)
@@ -25,6 +25,11 @@ module ThreeScale
25
25
  end
26
26
  private_class_method :key_uri
27
27
 
28
+ def self.batch_uri(service_id)
29
+ "#{base_uri(service_id)}batch"
30
+ end
31
+ private_class_method :batch_uri
32
+
28
33
  def self.load(service_id, id)
29
34
  api_read({}, uri: app_uri(service_id, id))
30
35
  end
@@ -38,6 +43,10 @@ module ThreeScale
38
43
  api_delete({}, uri: app_uri(service_id, id))
39
44
  end
40
45
 
46
+ def self.save_batch(service_id, applications)
47
+ api_update_batch({ applications: applications }, uri: batch_uri(service_id))
48
+ end
49
+
41
50
  def initialize(attributes = {})
42
51
  @state = :active
43
52
  super(attributes)
@@ -1,5 +1,5 @@
1
1
  module ThreeScale
2
2
  module Core
3
- VERSION = '1.30.0'
3
+ VERSION = '1.31.0'
4
4
  end
5
5
  end
data/pisoni.gemspec CHANGED
@@ -18,8 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.description = 'Client for the Apisonator internal API for model data.'
19
19
  s.license = 'Apache-2.0'
20
20
 
21
- # faraday v2.9.0 removes support for Ruby 2.7, see https://github.com/lostisland/faraday/releases/tag/v2.9.0
22
- s.add_runtime_dependency 'faraday', '~> 2.0', '<= 2.9'
21
+ s.add_runtime_dependency 'faraday', '~> 2.0', '>= 2.14.3'
23
22
  s.add_runtime_dependency 'json', '~> 2.7', '>= 2.7.1'
24
23
  s.add_runtime_dependency 'injectedlogger', '0.0.13'
25
24
  s.add_runtime_dependency 'faraday-net_http_persistent', '~> 2.1'
@@ -40,5 +39,5 @@ Gem::Specification.new do |s|
40
39
 
41
40
  s.rdoc_options = ["--charset=UTF-8"]
42
41
 
43
- s.required_ruby_version = '>= 2.6.0'
42
+ s.required_ruby_version = '>= 3.0.0'
44
43
  end
@@ -0,0 +1,19 @@
1
+ version: '3'
2
+ services:
3
+
4
+ redis:
5
+ image: redis:6.2-alpine
6
+
7
+ apisonator:
8
+ image: quay.io/3scale/apisonator:latest
9
+ ports:
10
+ - "3001:3001"
11
+ environment:
12
+ CONFIG_INTERNAL_API_USER: user
13
+ CONFIG_INTERNAL_API_PASSWORD: password
14
+ CONFIG_QUEUES_MASTER_NAME: redis://redis:6379
15
+ CONFIG_REDIS_PROXY: redis://redis:6379
16
+ RACK_ENV: test
17
+ command: 3scale_backend start -p 3001
18
+ depends_on:
19
+ - redis
@@ -269,6 +269,99 @@ module ThreeScale
269
269
  end
270
270
  end
271
271
 
272
+ describe '.save_batch' do
273
+ let(:service_id) { 2001 }
274
+
275
+ before do
276
+ Application.delete(service_id, 'batch_app_1')
277
+ Application.delete(service_id, 'batch_app_2')
278
+ Application.delete(service_id, 'batch_app_3')
279
+ end
280
+
281
+ it 'creates multiple applications in a single request' do
282
+ apps = [
283
+ { id: 'batch_app_1', state: 'active', plan_id: '100', plan_name: 'Gold',
284
+ redirect_url: 'http://example.com', user_key: 'uk_batch_1' },
285
+ { id: 'batch_app_2', state: 'suspended', plan_id: '101', plan_name: 'Silver' }
286
+ ]
287
+
288
+ result = Application.save_batch(service_id, apps)
289
+
290
+ result[:status].must_equal 'completed'
291
+ result[:total].must_equal 2
292
+ result[:successful].must_equal 2
293
+ result[:failed].must_equal 0
294
+
295
+ app1 = Application.load(service_id, 'batch_app_1')
296
+ app1.wont_be_nil
297
+ app1.plan_name.must_equal 'Gold'
298
+
299
+ app2 = Application.load(service_id, 'batch_app_2')
300
+ app2.wont_be_nil
301
+ app2.plan_name.must_equal 'Silver'
302
+ end
303
+
304
+ it 'reports failures for invalid applications without blocking valid ones' do
305
+ apps = [
306
+ { id: 'batch_app_1', state: 'active', plan_id: '100', plan_name: 'Gold' },
307
+ { id: 'batch_app_3', plan_id: '102', plan_name: 'Bronze' }
308
+ ]
309
+
310
+ result = Application.save_batch(service_id, apps)
311
+
312
+ result[:status].must_equal 'completed'
313
+ result[:total].must_equal 2
314
+ result[:successful].must_equal 1
315
+ result[:failed].must_equal 1
316
+
317
+ result[:failures].wont_be_nil
318
+ result[:failures].size.must_equal 1
319
+ result[:failures][0][:id].must_equal 'batch_app_3'
320
+
321
+ Application.load(service_id, 'batch_app_1').wont_be_nil
322
+ end
323
+
324
+ it 'returns modified status for existing applications' do
325
+ Application.save(service_id: service_id, id: 'batch_app_1',
326
+ state: 'active', plan_id: '100', plan_name: 'Old')
327
+
328
+ apps = [
329
+ { id: 'batch_app_1', state: 'active', plan_id: '200', plan_name: 'New' }
330
+ ]
331
+
332
+ result = Application.save_batch(service_id, apps)
333
+
334
+ result[:successful].must_equal 1
335
+ result[:applications][0][:status].must_equal 'modified'
336
+
337
+ app = Application.load(service_id, 'batch_app_1')
338
+ app.plan_name.must_equal 'New'
339
+ end
340
+
341
+ it 'handles empty applications array' do
342
+ result = Application.save_batch(service_id, [])
343
+
344
+ result[:status].must_equal 'completed'
345
+ result[:total].must_equal 0
346
+ result[:successful].must_equal 0
347
+ result[:failed].must_equal 0
348
+ end
349
+
350
+ it 'saves user keys and application keys' do
351
+ apps = [
352
+ { id: 'batch_app_1', state: 'active', plan_id: '100', plan_name: 'Gold',
353
+ user_key: 'uk_batch_test', application_keys: ['ak1', 'ak2'] }
354
+ ]
355
+
356
+ result = Application.save_batch(service_id, apps)
357
+
358
+ result[:successful].must_equal 1
359
+ result[:applications][0][:application][:user_key].must_equal 'uk_batch_test'
360
+ result[:applications][0][:application][:application_keys].must_include 'ak1'
361
+ result[:applications][0][:application][:application_keys].must_include 'ak2'
362
+ end
363
+ end
364
+
272
365
  describe 'by_key' do
273
366
  let(:key) { 'a_key' }
274
367
  let(:key_with_special_chars) { SPECIAL_CHARACTERS }
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  if ENV['COVERAGE'] && !ENV['COVERAGE'].empty?
2
- require 'codeclimate-test-reporter'
2
+ require 'simplecov'
3
+ require 'simplecov_json_formatter'
3
4
  SimpleCov.start do
4
- formatter ENV['CODECLIMATE_REPO_TOKEN'] ?
5
- CodeClimate::TestReporter::Formatter :
5
+ formatter SimpleCov::Formatter::MultiFormatter.new([
6
+ SimpleCov::Formatter::JSONFormatter,
6
7
  SimpleCov::Formatter::HTMLFormatter
8
+ ])
7
9
  add_filter '/spec/'
8
10
  end
9
11
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pisoni
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.30.0
4
+ version: 1.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Martinez Ruiz
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-03-05 00:00:00.000000000 Z
10
+ date: 2026-07-03 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: faraday
@@ -17,9 +16,9 @@ dependencies:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
18
  version: '2.0'
20
- - - "<="
19
+ - - ">="
21
20
  - !ruby/object:Gem::Version
22
- version: '2.9'
21
+ version: 2.14.3
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +26,9 @@ dependencies:
27
26
  - - "~>"
28
27
  - !ruby/object:Gem::Version
29
28
  version: '2.0'
30
- - - "<="
29
+ - - ">="
31
30
  - !ruby/object:Gem::Version
32
- version: '2.9'
31
+ version: 2.14.3
33
32
  - !ruby/object:Gem::Dependency
34
33
  name: json
35
34
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +130,7 @@ files:
131
130
  - lib/3scale_core.rb
132
131
  - lib/pisoni.rb
133
132
  - pisoni.gemspec
133
+ - podman-compose.yml
134
134
  - spec/alert_limit_spec.rb
135
135
  - spec/application_key_spec.rb
136
136
  - spec/application_referrer_filter_spec.rb
@@ -149,7 +149,6 @@ homepage: https://github.com/3scale/pisoni
149
149
  licenses:
150
150
  - Apache-2.0
151
151
  metadata: {}
152
- post_install_message:
153
152
  rdoc_options:
154
153
  - "--charset=UTF-8"
155
154
  require_paths:
@@ -158,15 +157,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
157
  requirements:
159
158
  - - ">="
160
159
  - !ruby/object:Gem::Version
161
- version: 2.6.0
160
+ version: 3.0.0
162
161
  required_rubygems_version: !ruby/object:Gem::Requirement
163
162
  requirements:
164
163
  - - ">="
165
164
  - !ruby/object:Gem::Version
166
165
  version: '0'
167
166
  requirements: []
168
- rubygems_version: 3.1.6
169
- signing_key:
167
+ rubygems_version: 4.0.4
170
168
  specification_version: 4
171
169
  summary: Client for the Apisonator internal API for model data
172
170
  test_files: