airbrake-ruby 4.1.0 → 5.0.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.
Files changed (94) hide show
  1. checksums.yaml +5 -5
  2. data/lib/airbrake-ruby/async_sender.rb +22 -96
  3. data/lib/airbrake-ruby/backtrace.rb +8 -7
  4. data/lib/airbrake-ruby/benchmark.rb +39 -0
  5. data/lib/airbrake-ruby/code_hunk.rb +1 -1
  6. data/lib/airbrake-ruby/config/processor.rb +84 -0
  7. data/lib/airbrake-ruby/config/validator.rb +9 -3
  8. data/lib/airbrake-ruby/config.rb +76 -20
  9. data/lib/airbrake-ruby/deploy_notifier.rb +1 -1
  10. data/lib/airbrake-ruby/file_cache.rb +6 -0
  11. data/lib/airbrake-ruby/filter_chain.rb +16 -1
  12. data/lib/airbrake-ruby/filters/dependency_filter.rb +1 -0
  13. data/lib/airbrake-ruby/filters/exception_attributes_filter.rb +2 -2
  14. data/lib/airbrake-ruby/filters/gem_root_filter.rb +1 -0
  15. data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +5 -5
  16. data/lib/airbrake-ruby/filters/git_repository_filter.rb +3 -0
  17. data/lib/airbrake-ruby/filters/git_revision_filter.rb +2 -0
  18. data/lib/airbrake-ruby/filters/{keys_whitelist.rb → keys_allowlist.rb} +3 -3
  19. data/lib/airbrake-ruby/filters/{keys_blacklist.rb → keys_blocklist.rb} +3 -3
  20. data/lib/airbrake-ruby/filters/keys_filter.rb +39 -20
  21. data/lib/airbrake-ruby/filters/root_directory_filter.rb +1 -0
  22. data/lib/airbrake-ruby/filters/sql_filter.rb +30 -6
  23. data/lib/airbrake-ruby/filters/system_exit_filter.rb +1 -0
  24. data/lib/airbrake-ruby/filters/thread_filter.rb +4 -2
  25. data/lib/airbrake-ruby/grouppable.rb +12 -0
  26. data/lib/airbrake-ruby/ignorable.rb +1 -0
  27. data/lib/airbrake-ruby/inspectable.rb +2 -2
  28. data/lib/airbrake-ruby/loggable.rb +2 -2
  29. data/lib/airbrake-ruby/mergeable.rb +12 -0
  30. data/lib/airbrake-ruby/monotonic_time.rb +48 -0
  31. data/lib/airbrake-ruby/notice.rb +10 -20
  32. data/lib/airbrake-ruby/notice_notifier.rb +23 -42
  33. data/lib/airbrake-ruby/performance_breakdown.rb +52 -0
  34. data/lib/airbrake-ruby/performance_notifier.rb +126 -49
  35. data/lib/airbrake-ruby/promise.rb +1 -0
  36. data/lib/airbrake-ruby/query.rb +26 -11
  37. data/lib/airbrake-ruby/queue.rb +65 -0
  38. data/lib/airbrake-ruby/remote_settings/settings_data.rb +120 -0
  39. data/lib/airbrake-ruby/remote_settings.rb +145 -0
  40. data/lib/airbrake-ruby/request.rb +20 -6
  41. data/lib/airbrake-ruby/stashable.rb +15 -0
  42. data/lib/airbrake-ruby/stat.rb +34 -24
  43. data/lib/airbrake-ruby/sync_sender.rb +3 -2
  44. data/lib/airbrake-ruby/tdigest.rb +43 -58
  45. data/lib/airbrake-ruby/thread_pool.rb +138 -0
  46. data/lib/airbrake-ruby/timed_trace.rb +58 -0
  47. data/lib/airbrake-ruby/truncator.rb +10 -4
  48. data/lib/airbrake-ruby/version.rb +11 -1
  49. data/lib/airbrake-ruby.rb +219 -53
  50. data/spec/airbrake_spec.rb +428 -9
  51. data/spec/async_sender_spec.rb +26 -110
  52. data/spec/backtrace_spec.rb +44 -44
  53. data/spec/benchmark_spec.rb +33 -0
  54. data/spec/code_hunk_spec.rb +11 -11
  55. data/spec/config/processor_spec.rb +209 -0
  56. data/spec/config/validator_spec.rb +23 -6
  57. data/spec/config_spec.rb +77 -7
  58. data/spec/deploy_notifier_spec.rb +2 -2
  59. data/spec/{file_cache.rb → file_cache_spec.rb} +2 -4
  60. data/spec/filter_chain_spec.rb +28 -1
  61. data/spec/filters/dependency_filter_spec.rb +1 -1
  62. data/spec/filters/gem_root_filter_spec.rb +9 -9
  63. data/spec/filters/git_last_checkout_filter_spec.rb +21 -4
  64. data/spec/filters/git_repository_filter.rb +1 -1
  65. data/spec/filters/git_revision_filter_spec.rb +13 -11
  66. data/spec/filters/{keys_whitelist_spec.rb → keys_allowlist_spec.rb} +29 -28
  67. data/spec/filters/{keys_blacklist_spec.rb → keys_blocklist_spec.rb} +39 -29
  68. data/spec/filters/root_directory_filter_spec.rb +9 -9
  69. data/spec/filters/sql_filter_spec.rb +110 -55
  70. data/spec/filters/system_exit_filter_spec.rb +1 -1
  71. data/spec/filters/thread_filter_spec.rb +33 -31
  72. data/spec/fixtures/project_root/code.rb +9 -9
  73. data/spec/loggable_spec.rb +17 -0
  74. data/spec/monotonic_time_spec.rb +23 -0
  75. data/spec/{notice_notifier_spec → notice_notifier}/options_spec.rb +19 -21
  76. data/spec/notice_notifier_spec.rb +20 -80
  77. data/spec/notice_spec.rb +9 -11
  78. data/spec/performance_breakdown_spec.rb +11 -0
  79. data/spec/performance_notifier_spec.rb +360 -85
  80. data/spec/query_spec.rb +11 -0
  81. data/spec/queue_spec.rb +18 -0
  82. data/spec/remote_settings/settings_data_spec.rb +365 -0
  83. data/spec/remote_settings_spec.rb +230 -0
  84. data/spec/request_spec.rb +9 -0
  85. data/spec/response_spec.rb +8 -8
  86. data/spec/spec_helper.rb +9 -13
  87. data/spec/stashable_spec.rb +23 -0
  88. data/spec/stat_spec.rb +17 -15
  89. data/spec/sync_sender_spec.rb +14 -12
  90. data/spec/tdigest_spec.rb +6 -6
  91. data/spec/thread_pool_spec.rb +187 -0
  92. data/spec/timed_trace_spec.rb +125 -0
  93. data/spec/truncator_spec.rb +12 -12
  94. metadata +55 -18
data/spec/config_spec.rb CHANGED
@@ -10,17 +10,26 @@ RSpec.describe Airbrake::Config do
10
10
  its(:app_version) { is_expected.to be_nil }
11
11
  its(:versions) { is_expected.to be_empty }
12
12
  its(:host) { is_expected.to eq('https://api.airbrake.io') }
13
- its(:endpoint) { is_expected.not_to be_nil }
13
+ its(:error_host) { is_expected.to eq('https://api.airbrake.io') }
14
+ its(:apm_host) { is_expected.to eq('https://api.airbrake.io') }
15
+ its(:error_endpoint) { is_expected.not_to be_nil }
14
16
  its(:workers) { is_expected.to eq(1) }
15
17
  its(:queue_size) { is_expected.to eq(100) }
16
18
  its(:root_directory) { is_expected.to eq(Bundler.root.realpath.to_s) }
17
19
  its(:environment) { is_expected.to be_nil }
18
20
  its(:ignore_environments) { is_expected.to be_empty }
19
21
  its(:timeout) { is_expected.to be_nil }
20
- its(:blacklist_keys) { is_expected.to be_empty }
21
- its(:whitelist_keys) { is_expected.to be_empty }
22
- its(:performance_stats) { is_expected.to be_falsey }
22
+ its(:blocklist_keys) { is_expected.to be_empty }
23
+ its(:allowlist_keys) { is_expected.to be_empty }
24
+ its(:performance_stats) { is_expected.to eq(true) }
23
25
  its(:performance_stats_flush_period) { is_expected.to eq(15) }
26
+ its(:query_stats) { is_expected.to eq(true) }
27
+ its(:job_stats) { is_expected.to eq(true) }
28
+ its(:error_notifications) { is_expected.to eq(true) }
29
+
30
+ its(:remote_config_host) do
31
+ is_expected.to eq('https://v1-production-notifier-configs.s3.amazonaws.com')
32
+ end
24
33
 
25
34
  describe "#new" do
26
35
  context "when user config is passed" do
@@ -61,13 +70,13 @@ RSpec.describe Airbrake::Config do
61
70
  end
62
71
  end
63
72
 
64
- describe "#endpoint" do
73
+ describe "#error_endpoint" do
65
74
  subject { described_class.new(valid_params.merge(user_config)) }
66
75
 
67
76
  context "when host ends with a URL with a slug with a trailing slash" do
68
77
  let(:user_config) { { host: 'https://localhost/bingo/' } }
69
78
 
70
- its(:endpoint) do
79
+ its(:error_endpoint) do
71
80
  is_expected.to eq(URI('https://localhost/bingo/api/v3/projects/1/notices'))
72
81
  end
73
82
  end
@@ -75,7 +84,7 @@ RSpec.describe Airbrake::Config do
75
84
  context "when host ends with a URL with a slug without a trailing slash" do
76
85
  let(:user_config) { { host: 'https://localhost/bingo' } }
77
86
 
78
- its(:endpoint) do
87
+ its(:error_endpoint) do
79
88
  is_expected.to eq(URI('https://localhost/api/v3/projects/1/notices'))
80
89
  end
81
90
  end
@@ -106,4 +115,65 @@ RSpec.describe Airbrake::Config do
106
115
  its(:check_configuration) { is_expected.not_to be_rejected }
107
116
  end
108
117
  end
118
+
119
+ describe "#check_performance_options" do
120
+ it "returns a promise" do
121
+ resource = Airbrake::Query.new(method: '', route: '', query: '', timing: 1)
122
+ expect(subject.check_performance_options(resource))
123
+ .to be_an(Airbrake::Promise)
124
+ end
125
+
126
+ context "when performance stats are disabled" do
127
+ before { subject.performance_stats = false }
128
+
129
+ let(:resource) do
130
+ Airbrake::Request.new(
131
+ method: 'GET', route: '/foo', status_code: 200, timing: 1,
132
+ )
133
+ end
134
+
135
+ it "returns a rejected promise" do
136
+ promise = subject.check_performance_options(resource)
137
+ expect(promise.value).to eq(
138
+ 'error' => "The Performance Stats feature is disabled",
139
+ )
140
+ end
141
+ end
142
+
143
+ context "when query stats are disabled" do
144
+ before { subject.query_stats = false }
145
+
146
+ let(:resource) do
147
+ Airbrake::Query.new(method: 'GET', route: '/foo', query: '', timing: 1)
148
+ end
149
+
150
+ it "returns a rejected promise" do
151
+ promise = subject.check_performance_options(resource)
152
+ expect(promise.value).to eq(
153
+ 'error' => "The Query Stats feature is disabled",
154
+ )
155
+ end
156
+ end
157
+
158
+ context "when job stats are disabled" do
159
+ before { subject.job_stats = false }
160
+
161
+ let(:resource) do
162
+ Airbrake::Queue.new(queue: 'foo_queue', error_count: 0, timing: 1)
163
+ end
164
+
165
+ it "returns a rejected promise" do
166
+ promise = subject.check_performance_options(resource)
167
+ expect(promise.value).to eq(
168
+ 'error' => "The Job Stats feature is disabled",
169
+ )
170
+ end
171
+ end
172
+ end
173
+
174
+ describe "#logger" do
175
+ it "sets logger level to Logger::WARN" do
176
+ expect(subject.logger.level).to eq(Logger::WARN)
177
+ end
178
+ end
109
179
  end
@@ -26,7 +26,7 @@ RSpec.describe Airbrake::DeployNotifier do
26
26
  expect_any_instance_of(Airbrake::SyncSender).to receive(:send).with(
27
27
  { environment: 'barenv' },
28
28
  instance_of(Airbrake::Promise),
29
- URI('https://api.airbrake.io/api/v4/projects/1/deploys')
29
+ URI('https://api.airbrake.io/api/v4/projects/1/deploys'),
30
30
  )
31
31
  subject.notify(environment: 'barenv')
32
32
  end
@@ -39,7 +39,7 @@ RSpec.describe Airbrake::DeployNotifier do
39
39
  expect_any_instance_of(Airbrake::SyncSender).to receive(:send).with(
40
40
  { environment: 'fooenv' },
41
41
  instance_of(Airbrake::Promise),
42
- URI('https://api.airbrake.io/api/v4/projects/1/deploys')
42
+ URI('https://api.airbrake.io/api/v4/projects/1/deploys'),
43
43
  )
44
44
  subject.notify({})
45
45
  end
@@ -1,8 +1,6 @@
1
1
  RSpec.describe Airbrake::FileCache do
2
- after do
3
- %i[banana mango].each { |k| described_class.delete(k) }
4
- expect(described_class).to be_empty
5
- end
2
+ before { described_class.reset }
3
+ after { described_class.reset }
6
4
 
7
5
  describe ".[]=" do
8
6
  context "when cache limit isn't reached" do
@@ -67,7 +67,7 @@ RSpec.describe Airbrake::FilterChain do
67
67
 
68
68
  foo_filter_mock = double
69
69
  expect(foo_filter_mock).to(
70
- receive(:name).at_least(:once).and_return('FooFilter')
70
+ receive(:name).at_least(:once).and_return('FooFilter'),
71
71
  )
72
72
  subject.delete_filter(foo_filter_mock)
73
73
 
@@ -89,4 +89,31 @@ RSpec.describe Airbrake::FilterChain do
89
89
  expect(subject.inspect).to eq('[Proc]')
90
90
  end
91
91
  end
92
+
93
+ describe "#includes?" do
94
+ context "when a custom filter class is included in the filter chain" do
95
+ it "returns true" do
96
+ klass = Class.new {}
97
+
98
+ subject.add_filter(klass.new)
99
+ expect(subject.includes?(klass)).to eq(true)
100
+ end
101
+ end
102
+
103
+ context "when Proc filter class is included in the filter chain" do
104
+ it "returns true" do
105
+ subject.add_filter(proc {})
106
+ expect(subject.includes?(Proc)).to eq(true)
107
+ end
108
+ end
109
+
110
+ context "when filter class is NOT included in the filter chain" do
111
+ it "returns false" do
112
+ klass = Class.new {}
113
+
114
+ subject.add_filter(proc {})
115
+ expect(subject.includes?(klass)).to eq(false)
116
+ end
117
+ end
118
+ end
92
119
  end
@@ -5,7 +5,7 @@ RSpec.describe Airbrake::Filters::DependencyFilter do
5
5
  it "attaches loaded dependencies to context/versions/dependencies" do
6
6
  subject.call(notice)
7
7
  expect(notice[:context][:versions][:dependencies]).to include(
8
- 'airbrake-ruby' => Airbrake::AIRBRAKE_RUBY_VERSION
8
+ 'airbrake-ruby' => Airbrake::AIRBRAKE_RUBY_VERSION,
9
9
  )
10
10
  end
11
11
  end
@@ -7,35 +7,35 @@ RSpec.describe Airbrake::Filters::GemRootFilter do
7
7
  after { 2.times { Gem.path.pop } }
8
8
 
9
9
  it "replaces gem root in the backtrace with a label" do
10
- # rubocop:disable Metrics/LineLength
10
+ # rubocop:disable Layout/LineLength
11
11
  notice[:errors].first[:backtrace] = [
12
12
  { file: "/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb" },
13
13
  { file: "#{root1}/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb" },
14
14
  { file: "/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb" },
15
- { file: "#{root2}/gems/rspec-core-3.3.2/exe/rspec" }
15
+ { file: "#{root2}/gems/rspec-core-3.3.2/exe/rspec" },
16
16
  ]
17
- # rubocop:enable Metrics/LineLength
17
+ # rubocop:enable Layout/LineLength
18
18
 
19
19
  subject.call(notice)
20
20
 
21
- # rubocop:disable Metrics/LineLength
21
+ # rubocop:disable Layout/LineLength
22
22
  expect(notice[:errors].first[:backtrace]).to(
23
23
  eq(
24
24
  [
25
25
  { file: "/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb" },
26
26
  { file: "/GEM_ROOT/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb" },
27
27
  { file: "/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb" },
28
- { file: "/GEM_ROOT/gems/rspec-core-3.3.2/exe/rspec" }
29
- ]
30
- )
28
+ { file: "/GEM_ROOT/gems/rspec-core-3.3.2/exe/rspec" },
29
+ ],
30
+ ),
31
31
  )
32
- # rubocop:enable Metrics/LineLength
32
+ # rubocop:enable Layout/LineLength
33
33
  end
34
34
 
35
35
  it "does not filter file when it is nil" do
36
36
  expect(notice[:errors].first[:file]).to be_nil
37
37
  expect { subject.call(notice) }.not_to(
38
- change { notice[:errors].first[:file] }
38
+ change { notice[:errors].first[:file] },
39
39
  )
40
40
  end
41
41
  end
@@ -21,24 +21,41 @@ RSpec.describe Airbrake::Filters::GitLastCheckoutFilter do
21
21
  end
22
22
 
23
23
  context "when .git directory exists" do
24
- before { subject.call(notice) }
24
+ context "when AIRBRAKE_DEPLOY_USERNAME env variable is set" do
25
+ before { ENV['AIRBRAKE_DEPLOY_USERNAME'] = 'deployer' }
25
26
 
26
- it "attaches last checkouted username" do
27
- expect(notice[:context][:lastCheckout][:username]).not_to be_empty
27
+ it "attaches username from the environment" do
28
+ subject.call(notice)
29
+ expect(notice[:context][:lastCheckout][:username]).to eq('deployer')
30
+ end
31
+ end
32
+
33
+ context "when AIRBRAKE_DEPLOY_USERNAME env variable is NOT set" do
34
+ before { ENV['AIRBRAKE_DEPLOY_USERNAME'] = nil }
35
+
36
+ it "attaches last checkouted username" do
37
+ subject.call(notice)
38
+ username = notice[:context][:lastCheckout][:username]
39
+ expect(username).not_to be_empty
40
+ expect(username).not_to be_nil
41
+ end
28
42
  end
29
43
 
30
44
  it "attaches last checkouted email" do
45
+ subject.call(notice)
31
46
  expect(notice[:context][:lastCheckout][:email]).to(
32
- match(/\A\w+[\w.-]*@\w+\.?\w+?\z/)
47
+ match(/\A\w+[\w.-]*@\w+\.?\w+?\z/),
33
48
  )
34
49
  end
35
50
 
36
51
  it "attaches last checkouted revision" do
52
+ subject.call(notice)
37
53
  expect(notice[:context][:lastCheckout][:revision]).not_to be_empty
38
54
  expect(notice[:context][:lastCheckout][:revision].size).to eq(40)
39
55
  end
40
56
 
41
57
  it "attaches last checkouted time" do
58
+ subject.call(notice)
42
59
  expect(notice[:context][:lastCheckout][:time]).not_to be_empty
43
60
  expect(notice[:context][:lastCheckout][:time].size).to eq(25)
44
61
  end
@@ -46,7 +46,7 @@ RSpec.describe Airbrake::Filters::GitRepositoryFilter do
46
46
  it "attaches context/repository" do
47
47
  subject.call(notice)
48
48
  expect(notice[:context][:repository]).to eq(
49
- 'ssh://git@github.com/airbrake/airbrake-ruby.git'
49
+ 'ssh://git@github.com/airbrake/airbrake-ruby.git',
50
50
  )
51
51
  end
52
52
  end
@@ -1,7 +1,9 @@
1
1
  RSpec.describe Airbrake::Filters::GitRevisionFilter do
2
2
  subject { described_class.new('root/dir') }
3
3
 
4
- let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
4
+ # 'let!', not 'let' to make sure Notice doesn't call File.exist? with
5
+ # unexpected arguments.
6
+ let!(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
5
7
 
6
8
  context "when context/revision is defined" do
7
9
  it "doesn't attach anything to context/revision" do
@@ -42,7 +44,7 @@ RSpec.describe Airbrake::Filters::GitRevisionFilter do
42
44
  context "and also when HEAD doesn't start with 'ref: '" do
43
45
  before do
44
46
  expect(File).to(
45
- receive(:read).with('root/dir/.git/HEAD').and_return('refs/foo')
47
+ receive(:read).with('root/dir/.git/HEAD').and_return('refs/foo'),
46
48
  )
47
49
  end
48
50
 
@@ -55,17 +57,17 @@ RSpec.describe Airbrake::Filters::GitRevisionFilter do
55
57
  context "and also when HEAD starts with 'ref: " do
56
58
  before do
57
59
  expect(File).to(
58
- receive(:read).with('root/dir/.git/HEAD').and_return("ref: refs/foo\n")
60
+ receive(:read).with('root/dir/.git/HEAD').and_return("ref: refs/foo\n"),
59
61
  )
60
62
  end
61
63
 
62
64
  context "when the ref exists" do
63
65
  before do
64
66
  expect(File).to(
65
- receive(:exist?).with('root/dir/.git/refs/foo').and_return(true)
67
+ receive(:exist?).with('root/dir/.git/refs/foo').and_return(true),
66
68
  )
67
69
  expect(File).to(
68
- receive(:read).with('root/dir/.git/refs/foo').and_return("d34db33f\n")
70
+ receive(:read).with('root/dir/.git/refs/foo').and_return("d34db33f\n"),
69
71
  )
70
72
  end
71
73
 
@@ -78,14 +80,14 @@ RSpec.describe Airbrake::Filters::GitRevisionFilter do
78
80
  context "when the ref doesn't exist" do
79
81
  before do
80
82
  expect(File).to(
81
- receive(:exist?).with('root/dir/.git/refs/foo').and_return(false)
83
+ receive(:exist?).with('root/dir/.git/refs/foo').and_return(false),
82
84
  )
83
85
  end
84
86
 
85
87
  context "and when '.git/packed-refs' exists" do
86
88
  before do
87
89
  expect(File).to(
88
- receive(:exist?).with('root/dir/.git/packed-refs').and_return(true)
90
+ receive(:exist?).with('root/dir/.git/packed-refs').and_return(true),
89
91
  )
90
92
  expect(File).to(
91
93
  receive(:readlines).with('root/dir/.git/packed-refs').and_return(
@@ -93,9 +95,9 @@ RSpec.describe Airbrake::Filters::GitRevisionFilter do
93
95
  "# pack-refs with: peeled fully-peeled\n",
94
96
  "ccb316eecff79c7528d1ad43e5fa165f7a44d52e refs/tags/v3.0.30\n",
95
97
  "^d358900f73ee5bfd6ca3a592cf23ac6e82df83c1",
96
- "d34db33f refs/foo\n"
97
- ]
98
- )
98
+ "d34db33f refs/foo\n",
99
+ ],
100
+ ),
99
101
  )
100
102
  end
101
103
 
@@ -108,7 +110,7 @@ RSpec.describe Airbrake::Filters::GitRevisionFilter do
108
110
  context "and when '.git/packed-refs' doesn't exist" do
109
111
  before do
110
112
  expect(File).to(
111
- receive(:exist?).with('root/dir/.git/packed-refs').and_return(false)
113
+ receive(:exist?).with('root/dir/.git/packed-refs').and_return(false),
112
114
  )
113
115
  end
114
116
 
@@ -1,4 +1,4 @@
1
- RSpec.describe Airbrake::Filters::KeysWhitelist do
1
+ RSpec.describe Airbrake::Filters::KeysAllowlist do
2
2
  subject { described_class.new(patterns) }
3
3
 
4
4
  let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
@@ -19,8 +19,8 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
19
19
  [/\Abin/],
20
20
  [
21
21
  { bingo: 'bango', bongo: 'bish', bash: 'bosh' },
22
- { bingo: 'bango', bongo: '[Filtered]', bash: '[Filtered]' }
23
- ]
22
+ { bingo: 'bango', bongo: '[Filtered]', bash: '[Filtered]' },
23
+ ],
24
24
  )
25
25
  end
26
26
 
@@ -30,8 +30,8 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
30
30
  [:bongo],
31
31
  [
32
32
  { bongo: 'bish', bash: 'bosh', bbashh: 'bboshh' },
33
- { bongo: 'bish', bash: '[Filtered]', bbashh: '[Filtered]' }
34
- ]
33
+ { bongo: 'bish', bash: '[Filtered]', bbashh: '[Filtered]' },
34
+ ],
35
35
  )
36
36
  end
37
37
 
@@ -41,8 +41,8 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
41
41
  ['bash'],
42
42
  [
43
43
  { bingo: 'bango', bongo: 'bish', bash: 'bosh' },
44
- { bingo: '[Filtered]', bongo: '[Filtered]', bash: 'bosh' }
45
- ]
44
+ { bingo: '[Filtered]', bongo: '[Filtered]', bash: 'bosh' },
45
+ ],
46
46
  )
47
47
  end
48
48
 
@@ -53,8 +53,8 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
53
53
  [proc { 'bongo' }, :bash],
54
54
  [
55
55
  { bingo: 'bango', bongo: 'bish', bash: 'bosh' },
56
- { bingo: '[Filtered]', bongo: 'bish', bash: 'bosh' }
57
- ]
56
+ { bingo: '[Filtered]', bongo: 'bish', bash: 'bosh' },
57
+ ],
58
58
  )
59
59
  end
60
60
 
@@ -64,16 +64,16 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
64
64
  [proc { Object.new }],
65
65
  [
66
66
  { bingo: 'bango', bongo: 'bish', bash: 'bosh' },
67
- { bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' }
68
- ]
67
+ { bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' },
68
+ ],
69
69
  )
70
70
 
71
71
  it "logs an error" do
72
72
  expect(Airbrake::Loggable.instance).to receive(:error).with(
73
- /KeysWhitelist is invalid.+patterns: \[#<Object:.+>\]/
73
+ /KeysAllowlist is invalid.+patterns: \[#<Object:.+>\]/,
74
74
  )
75
- keys_whitelist = described_class.new(patterns)
76
- keys_whitelist.call(notice)
75
+ keys_allowlist = described_class.new(patterns)
76
+ keys_allowlist.call(notice)
77
77
  end
78
78
  end
79
79
 
@@ -83,10 +83,10 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
83
83
  context "and when the filter is called once" do
84
84
  it "logs an error" do
85
85
  expect(Airbrake::Loggable.instance).to receive(:error).with(
86
- /KeysWhitelist is invalid.+patterns: \[#<Proc:.+>\]/
86
+ /KeysAllowlist is invalid.+patterns: \[#<Proc:.+>\]/,
87
87
  )
88
- keys_whitelist = described_class.new(patterns)
89
- keys_whitelist.call(notice)
88
+ keys_allowlist = described_class.new(patterns)
89
+ keys_allowlist.call(notice)
90
90
  end
91
91
 
92
92
  include_examples(
@@ -94,8 +94,8 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
94
94
  [proc { proc { ['bingo'] } }],
95
95
  [
96
96
  { bingo: 'bango', bongo: 'bish', bash: 'bosh' },
97
- { bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' }
98
- ]
97
+ { bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' },
98
+ ],
99
99
  )
100
100
  end
101
101
  end
@@ -107,16 +107,16 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
107
107
  [Object.new],
108
108
  [
109
109
  { bingo: 'bango', bongo: 'bish', bash: 'bosh' },
110
- { bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' }
111
- ]
110
+ { bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' },
111
+ ],
112
112
  )
113
113
 
114
114
  it "logs an error" do
115
115
  expect(Airbrake::Loggable.instance).to receive(:error).with(
116
- /KeysWhitelist is invalid.+patterns: \[#<Object:.+>\]/
116
+ /KeysAllowlist is invalid.+patterns: \[#<Object:.+>\]/,
117
117
  )
118
- keys_whitelist = described_class.new(patterns)
119
- keys_whitelist.call(notice)
118
+ keys_allowlist = described_class.new(patterns)
119
+ keys_allowlist.call(notice)
120
120
  end
121
121
  end
122
122
 
@@ -127,8 +127,8 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
127
127
  %w[bongo bish],
128
128
  [
129
129
  { bingo: 'bango', bongo: { bish: 'bash' } },
130
- { bingo: '[Filtered]', bongo: { bish: 'bash' } }
131
- ]
130
+ { bingo: '[Filtered]', bongo: { bish: 'bash' } },
131
+ ],
132
132
  )
133
133
  end
134
134
 
@@ -151,6 +151,7 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
151
151
  # thing. One is a Java exception, the other is a Ruby exception.
152
152
  # Likely a bug: https://github.com/jruby/jruby/issues/1903
153
153
  raise ex unless RUBY_ENGINE == 'jruby'
154
+
154
155
  expect { subject.call(notice) }.to raise_error(java.lang.StackOverflowError)
155
156
  end
156
157
  end
@@ -166,7 +167,7 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
166
167
  notice[:context][:url] = 'http://localhost:3000/crash?foo=bar&baz=bongo&bish=bash'
167
168
  subject.call(notice)
168
169
  expect(notice[:context][:url]).to(
169
- eq('http://localhost:3000/crash?foo=[Filtered]&baz=[Filtered]&bish=bash')
170
+ eq('http://localhost:3000/crash?foo=[Filtered]&baz=[Filtered]&bish=bash'),
170
171
  )
171
172
  end
172
173
  end
@@ -177,7 +178,7 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
177
178
  'http://localhost:3000/cra]]]sh?foo=bar&baz=bongo&bish=bash'
178
179
  subject.call(notice)
179
180
  expect(notice[:context][:url]).to(
180
- eq('http://localhost:3000/cra]]]sh?foo=bar&baz=bongo&bish=bash')
181
+ eq('http://localhost:3000/cra]]]sh?foo=bar&baz=bongo&bish=bash'),
181
182
  )
182
183
  end
183
184
  end