logplex 0.0.5 → 0.0.7

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: ffe48a52e4f1d01b38a9fec2cfd6cba64b4e735c926616d36b3a87b2ec6a75b1
4
- data.tar.gz: c01b8e0627ae7410b4148ffcdc3ead41983df81fc161fdd1692456cd55573310
3
+ metadata.gz: 74968b946301f4fcecd000127c5bfd98b80d39ce024084ece76af5479e7a109e
4
+ data.tar.gz: 9edd68f2df748bfb7ffc2f8ffe3d4fd64251897c1c236fc5bd8229f324cb9214
5
5
  SHA512:
6
- metadata.gz: 79e429707324d1c2e057dbc3a1d9880e9449e7f8088058953568cffa2e14b4cc4204c292e07a015d6c84099b391075a6236bf521b9a931c2b0d283b8a106f79a
7
- data.tar.gz: 247a921c9096a10eda1df39b950eab655bb795438da89b650548f113d46ae206cd0bfe9786a4e07f4b31d4c65c1c5f012e12edd023b04306f3814fb613adb040
6
+ metadata.gz: f3eb73debbaaad3261d89834acee07d3c46642275926c705df4547c5dfb2da4ec09c5b17b412de8edb1baaad55da03b85a4f0985a316ac54ef0c6180278e53fc
7
+ data.tar.gz: dc60bb59e898e11e36a6728bd5f0cb7d6ecc202dd1b2df013e0e825692702020c50b264d1c6229987224c1d7c247e1f090a00022e98be86c7ad7395b89939358
@@ -0,0 +1,15 @@
1
+ version: 2.1
2
+
3
+ jobs:
4
+ test:
5
+ docker:
6
+ - image: cimg/ruby:2.7.4
7
+ steps:
8
+ - checkout
9
+ - run: bundle install
10
+ - run: bundle exec rspec
11
+
12
+ workflows:
13
+ test:
14
+ jobs:
15
+ - test
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
19
  .tags
20
+ .idea
data/CODEOWNERS ADDED
@@ -0,0 +1,2 @@
1
+ # Comment line immediately above ownership line is reserved for related gus information. Please be careful while editing.
2
+ #ECCN:Open Source
@@ -9,9 +9,10 @@ module Logplex
9
9
  Excon::Errors::Unauthorized,
10
10
  Timeout::Error].freeze
11
11
 
12
- def initialize(logplex_url = nil)
12
+ def initialize(logplex_url = nil, bearer_token: nil)
13
13
  @logplex_url = logplex_url || Logplex.configuration.logplex_url
14
14
  @token = URI(@logplex_url).password || Logplex.configuration.app_name
15
+ @auth_headers = bearer_token ? { 'Authorization' => "Bearer #{bearer_token}" } : {}
15
16
  end
16
17
 
17
18
  def publish(messages, opts={})
@@ -36,11 +37,11 @@ module Logplex
36
37
  private
37
38
 
38
39
  def api_post(message, number_messages)
39
- Excon.post(@logplex_url, body: message, headers: {
40
+ Excon.post(@logplex_url, body: message, headers: @auth_headers.merge({
40
41
  "Content-Type" => 'application/logplex-1',
41
42
  "Content-Length" => message.length,
42
43
  "Logplex-Msg-Count" => number_messages
43
- }, expects: [200, 204])
44
+ }), expects: [200, 202, 204])
44
45
  end
45
46
  end
46
47
  end
@@ -1,3 +1,3 @@
1
1
  module Logplex
2
- VERSION = "0.0.5".freeze
2
+ VERSION = "0.0.7".freeze
3
3
  end
@@ -56,6 +56,13 @@ describe Logplex::Publisher do
56
56
  expect(publisher.publish(message)).to be_truthy
57
57
  end
58
58
 
59
+ it 'does the thing with a 202' do
60
+ Excon.stub({ method: :post, password: "t.some-token", body: /hi\="there\"/ }, status: 202)
61
+ message = { hi: 'there' }
62
+ publisher = Logplex::Publisher.new('https://token:t.some-token@logplex.example.com')
63
+ expect(publisher.publish(message)).to be_truthy
64
+ end
65
+
59
66
  it 'returns true' do
60
67
  Excon.stub({ method: :post, password: "t.some-token" }, status: 204)
61
68
  message = 'I have a message for you'
@@ -95,5 +102,17 @@ describe Logplex::Publisher do
95
102
  expect(Excon).to receive(:post).with(any_args, hash_including(:headers => headers))
96
103
  Logplex::Publisher.new('https://token:t.some-token@logplex.example.com').publish(message)
97
104
  end
105
+
106
+ it "supports bearer authentication" do
107
+ message = 'hello-bearer'
108
+ headers = {
109
+ "Authorization" => 'Bearer test-bearer-token',
110
+ "Content-Type" => 'application/logplex-1',
111
+ "Content-Length" => 70,
112
+ "Logplex-Msg-Count" => 1
113
+ }
114
+ expect(Excon).to receive(:post).with(any_args, hash_including(:headers => headers))
115
+ Logplex::Publisher.new('https://logplex-next.example.com', bearer_token: 'test-bearer-token').publish(message)
116
+ end
98
117
  end
99
118
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logplex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harold Giménez
8
8
  - Heroku
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-09-13 00:00:00.000000000 Z
12
+ date: 2025-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: valcro
@@ -60,9 +60,10 @@ executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - ".circleci/config.yml"
63
64
  - ".gitignore"
64
65
  - ".rspec"
65
- - ".travis.yml"
66
+ - CODEOWNERS
66
67
  - Gemfile
67
68
  - LICENSE
68
69
  - LICENSE.txt
@@ -81,7 +82,7 @@ files:
81
82
  homepage: https://github.com/heroku/logplex-gem
82
83
  licenses: []
83
84
  metadata: {}
84
- post_install_message:
85
+ post_install_message:
85
86
  rdoc_options: []
86
87
  require_paths:
87
88
  - lib
@@ -96,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
97
  - !ruby/object:Gem::Version
97
98
  version: '0'
98
99
  requirements: []
99
- rubygems_version: 3.0.3
100
- signing_key:
100
+ rubygems_version: 3.4.6
101
+ signing_key:
101
102
  specification_version: 4
102
103
  summary: Publish and Consume Logplex messages
103
104
  test_files:
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- - 2.3.1
5
- script: bundle exec rspec