logplex 0.0.6 → 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 +4 -4
- data/.gitignore +1 -0
- data/lib/logplex/publisher.rb +4 -3
- data/lib/logplex/version.rb +1 -1
- data/spec/logplex/publisher_spec.rb +12 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74968b946301f4fcecd000127c5bfd98b80d39ce024084ece76af5479e7a109e
|
4
|
+
data.tar.gz: 9edd68f2df748bfb7ffc2f8ffe3d4fd64251897c1c236fc5bd8229f324cb9214
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3eb73debbaaad3261d89834acee07d3c46642275926c705df4547c5dfb2da4ec09c5b17b412de8edb1baaad55da03b85a4f0985a316ac54ef0c6180278e53fc
|
7
|
+
data.tar.gz: dc60bb59e898e11e36a6728bd5f0cb7d6ecc202dd1b2df013e0e825692702020c50b264d1c6229987224c1d7c247e1f090a00022e98be86c7ad7395b89939358
|
data/.gitignore
CHANGED
data/lib/logplex/publisher.rb
CHANGED
@@ -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, 202, 204])
|
44
|
+
}), expects: [200, 202, 204])
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
data/lib/logplex/version.rb
CHANGED
@@ -102,5 +102,17 @@ describe Logplex::Publisher do
|
|
102
102
|
expect(Excon).to receive(:post).with(any_args, hash_including(:headers => headers))
|
103
103
|
Logplex::Publisher.new('https://token:t.some-token@logplex.example.com').publish(message)
|
104
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
|
105
117
|
end
|
106
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.
|
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:
|
12
|
+
date: 2025-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: valcro
|
@@ -82,7 +82,7 @@ files:
|
|
82
82
|
homepage: https://github.com/heroku/logplex-gem
|
83
83
|
licenses: []
|
84
84
|
metadata: {}
|
85
|
-
post_install_message:
|
85
|
+
post_install_message:
|
86
86
|
rdoc_options: []
|
87
87
|
require_paths:
|
88
88
|
- lib
|
@@ -97,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
101
|
-
signing_key:
|
100
|
+
rubygems_version: 3.4.6
|
101
|
+
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: Publish and Consume Logplex messages
|
104
104
|
test_files:
|