fluent-plugin-sentry-http 0.1.0 → 0.1.1

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.
data/README.md CHANGED
@@ -29,11 +29,11 @@ Plugin to accept exception input from [Sentry Clients](https://github.com/getsen
29
29
  type sentry_http
30
30
  port 8888
31
31
  bind 0.0.0.0
32
- <application 999>
32
+ <project 999>
33
33
  tag sentry.egg
34
- user aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
35
- pass bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
36
- </application>
34
+ key aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
35
+ secret bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
36
+ </project>
37
37
  </source>
38
38
  ```
39
39
 
@@ -16,27 +16,27 @@ module Fluent
16
16
  def configure(conf)
17
17
  super
18
18
  conf.elements.select {|element|
19
- element.name == 'application'
19
+ element.name == 'project'
20
20
  }.each do |element|
21
21
  @mapping[element.arg] = {
22
22
  'tag' => element['tag'],
23
- 'user' => element['user'],
24
- 'pass' => element['pass'],
23
+ 'key' => element['key'],
24
+ 'secret' => element['secret'],
25
25
  }
26
26
  end
27
27
  end
28
28
 
29
29
  def on_request(path_info, params)
30
30
  begin
31
- application = @mapping[path_info.split('/')[2]] # /api/999/store/
32
- raise 'not found' unless application
31
+ project = @mapping[path_info.split('/')[2]] # /api/999/store/
32
+ raise 'not found' unless project
33
33
  rescue
34
34
  return ['404 Not Found', {'Content-type' => 'text/plain'}, '']
35
35
  end
36
36
 
37
37
  begin
38
- user, pass = get_auth_info(params)
39
- raise 'unauthorized' unless application['user'] == user and application['pass'] == pass
38
+ key, secret = get_auth_info(params)
39
+ raise 'unauthorized' unless project['key'] == key and project['secret'] == secret
40
40
  rescue
41
41
  return ['401 Unauthorized', {'Content-type' => 'text/plain'}, '']
42
42
  end
@@ -45,7 +45,7 @@ module Fluent
45
45
  time, record = parse_params(params)
46
46
  raise 'Record not found' if record.nil?
47
47
 
48
- record['tag'] = application['tag']
48
+ record['tag'] = project['tag']
49
49
  record['time'] = time
50
50
 
51
51
  if @add_http_headers
@@ -64,7 +64,7 @@ module Fluent
64
64
  end
65
65
 
66
66
  begin
67
- router.emit(application['tag'], time, record)
67
+ router.emit(project['tag'], time, record)
68
68
  rescue
69
69
  return ['500 Internal Server Error', {'Content-type' => 'text/plain'}, "500 Internal Server Error\n#{$!}\n"]
70
70
  end
@@ -86,18 +86,18 @@ module Fluent
86
86
  end
87
87
 
88
88
  def get_auth_info(params)
89
- user = nil
90
- pass = nil
89
+ sentry_key = nil
90
+ sentry_secret = nil
91
91
  params['HTTP_X_SENTRY_AUTH'].split(', ').each do |element|
92
92
  key, value = element.split('=')
93
93
  case key
94
94
  when 'sentry_key'
95
- user = value
95
+ sentry_key = value
96
96
  when 'sentry_secret'
97
- pass = value
97
+ sentry_secret = value
98
98
  end
99
99
  end
100
- return user, pass
100
+ return sentry_key, sentry_secret
101
101
  end
102
102
  end
103
103
  end
@@ -1,7 +1,7 @@
1
1
  module Fluent
2
2
  module Plugin
3
3
  module SentryHttp
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
6
6
  end
7
7
  end
@@ -11,20 +11,20 @@ class SentryHttpInputTest < Test::Unit::TestCase
11
11
 
12
12
  PORT = unused_port
13
13
  HOST = '127.0.0.1'
14
- APPLICATION = 999
14
+ PROJECT = 999
15
15
  TAG = 'from.raven'
16
- USER = 'test_user'
17
- PASS = 'test_pass'
16
+ KEY = 'test_key'
17
+ SECRET = 'test_secret'
18
18
 
19
19
  CONFIG = %[
20
20
  port #{PORT}
21
21
  bind #{HOST}
22
22
 
23
- <application #{APPLICATION}>
23
+ <project #{PROJECT}>
24
24
  tag #{TAG}
25
- user #{USER}
26
- pass #{PASS}
27
- </application>
25
+ key #{KEY}
26
+ secret #{SECRET}
27
+ </project>
28
28
  ]
29
29
 
30
30
  def create_driver(conf=CONFIG)
@@ -36,10 +36,10 @@ class SentryHttpInputTest < Test::Unit::TestCase
36
36
  assert_equal PORT, d.instance.port
37
37
  assert_equal '127.0.0.1', d.instance.bind
38
38
 
39
- application = d.instance.mapping[APPLICATION.to_s]
40
- assert_equal TAG, application['tag']
41
- assert_equal USER, application['user']
42
- assert_equal PASS, application['pass']
39
+ project = d.instance.mapping[PROJECT.to_s]
40
+ assert_equal TAG, project['tag']
41
+ assert_equal KEY, project['key']
42
+ assert_equal SECRET, project['secret']
43
43
  end
44
44
 
45
45
  def test_success_request
@@ -48,8 +48,8 @@ class SentryHttpInputTest < Test::Unit::TestCase
48
48
  d.expect_emit TAG, time, expect_record
49
49
  d.run do
50
50
  res = post_record(
51
- APPLICATION,
52
- create_headers(time, USER, PASS),
51
+ PROJECT,
52
+ create_headers(time, KEY, SECRET),
53
53
  record_to_payload(record))
54
54
  assert_equal '200', res.code
55
55
  end
@@ -61,7 +61,7 @@ class SentryHttpInputTest < Test::Unit::TestCase
61
61
  d.run do
62
62
  res = post_record(
63
63
  998,
64
- create_headers(time, USER, PASS),
64
+ create_headers(time, KEY, SECRET),
65
65
  record_to_payload(record))
66
66
  assert_equal '404', res.code
67
67
  end
@@ -72,14 +72,14 @@ class SentryHttpInputTest < Test::Unit::TestCase
72
72
  d = create_driver
73
73
  d.run do
74
74
  res = post_record(
75
- APPLICATION,
76
- create_headers(time, 'ham', PASS),
75
+ PROJECT,
76
+ create_headers(time, 'ham', SECRET),
77
77
  record_to_payload(record))
78
78
  assert_equal '401', res.code
79
79
 
80
80
  res = post_record(
81
- APPLICATION,
82
- create_headers(time, USER, 'egg'),
81
+ PROJECT,
82
+ create_headers(time, KEY, 'egg'),
83
83
  record_to_payload(record))
84
84
  assert_equal '401', res.code
85
85
  end
@@ -90,8 +90,8 @@ class SentryHttpInputTest < Test::Unit::TestCase
90
90
  d = create_driver
91
91
  d.run do
92
92
  res = post_record(
93
- APPLICATION,
94
- create_headers(time, USER, PASS),
93
+ PROJECT,
94
+ create_headers(time, KEY, SECRET),
95
95
  'spam')
96
96
  assert_equal '400', res.code
97
97
  end
@@ -107,9 +107,9 @@ class SentryHttpInputTest < Test::Unit::TestCase
107
107
  return time, record, expect_record
108
108
  end
109
109
 
110
- def create_headers(time, user, pass)
110
+ def create_headers(time, key, secret)
111
111
  {
112
- 'X-Sentry-Auth' => "Sentry sentry_timestamp=#{time}, sentry_client=raven-python/5.2.0, sentry_version=6, sentry_key=#{user}, sentry_secret=#{pass}",
112
+ 'X-Sentry-Auth' => "Sentry sentry_timestamp=#{time}, sentry_client=raven-python/5.2.0, sentry_version=6, sentry_key=#{key}, sentry_secret=#{secret}",
113
113
  'Content-Type' => 'application/octet-stream',
114
114
  'User-Agent' => 'raven-python/5.2.0',
115
115
  }
@@ -128,9 +128,9 @@ class SentryHttpInputTest < Test::Unit::TestCase
128
128
  Base64.encode64(compressed_text)
129
129
  end
130
130
 
131
- def post_record(application, headers, payload)
131
+ def post_record(project, headers, payload)
132
132
  http = Net::HTTP.new(HOST, PORT)
133
- req = Net::HTTP::Post.new("/api/#{application}/store/", headers)
133
+ req = Net::HTTP::Post.new("/api/#{project}/store/", headers)
134
134
  req.body = payload
135
135
  http.request(req)
136
136
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - IKUTA Masahito
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2015-07-26 00:00:00 +09:00
17
+ date: 2015-08-01 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency