appsignal 4.0.6-java → 4.0.7-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/Rakefile +9 -9
  4. data/appsignal.gemspec +22 -1
  5. data/ext/agent.rb +27 -27
  6. data/lib/appsignal/check_in.rb +1 -1
  7. data/lib/appsignal/config.rb +1 -3
  8. data/lib/appsignal/integrations/resque.rb +1 -6
  9. data/lib/appsignal/utils/hash_sanitizer.rb +4 -0
  10. data/lib/appsignal/version.rb +1 -1
  11. metadata +2 -192
  12. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
  13. data/.github/ISSUE_TEMPLATE/chore.md +0 -14
  14. data/.github/workflows/ci.yml +0 -3285
  15. data/.github/workflows/create_release_from_tag.yml +0 -62
  16. data/.gitignore +0 -35
  17. data/.gitmodules +0 -3
  18. data/.rspec +0 -4
  19. data/.yardopts +0 -8
  20. data/benchmark.rake +0 -139
  21. data/gemfiles/capistrano2.gemfile +0 -6
  22. data/gemfiles/capistrano3.gemfile +0 -7
  23. data/gemfiles/dry-monitor.gemfile +0 -5
  24. data/gemfiles/grape.gemfile +0 -5
  25. data/gemfiles/hanami-2.0.gemfile +0 -7
  26. data/gemfiles/hanami-2.1.gemfile +0 -7
  27. data/gemfiles/http5.gemfile +0 -5
  28. data/gemfiles/no_dependencies.gemfile +0 -10
  29. data/gemfiles/padrino.gemfile +0 -7
  30. data/gemfiles/psych-3.gemfile +0 -5
  31. data/gemfiles/psych-4.gemfile +0 -5
  32. data/gemfiles/que-1.gemfile +0 -5
  33. data/gemfiles/que-2.gemfile +0 -5
  34. data/gemfiles/rails-6.0.gemfile +0 -10
  35. data/gemfiles/rails-6.1.gemfile +0 -11
  36. data/gemfiles/rails-7.0.gemfile +0 -11
  37. data/gemfiles/rails-7.1.gemfile +0 -11
  38. data/gemfiles/rails-7.2.gemfile +0 -11
  39. data/gemfiles/redis-4.gemfile +0 -5
  40. data/gemfiles/redis-5.gemfile +0 -6
  41. data/gemfiles/resque-2.gemfile +0 -6
  42. data/gemfiles/sequel.gemfile +0 -10
  43. data/gemfiles/sinatra.gemfile +0 -5
  44. data/gemfiles/webmachine1.gemfile +0 -7
  45. data/gemfiles/webmachine2.gemfile +0 -6
  46. data/mono.yml +0 -16
  47. data/spec/.rubocop.yml +0 -7
  48. data/spec/lib/appsignal/auth_check_spec.rb +0 -84
  49. data/spec/lib/appsignal/capistrano2_spec.rb +0 -227
  50. data/spec/lib/appsignal/capistrano3_spec.rb +0 -284
  51. data/spec/lib/appsignal/check_in/cron_spec.rb +0 -210
  52. data/spec/lib/appsignal/check_in/scheduler_spec.rb +0 -557
  53. data/spec/lib/appsignal/cli/demo_spec.rb +0 -46
  54. data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +0 -16
  55. data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +0 -86
  56. data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1553
  57. data/spec/lib/appsignal/cli/helpers_spec.rb +0 -179
  58. data/spec/lib/appsignal/cli/install_spec.rb +0 -848
  59. data/spec/lib/appsignal/cli_spec.rb +0 -56
  60. data/spec/lib/appsignal/config_spec.rb +0 -1380
  61. data/spec/lib/appsignal/demo_spec.rb +0 -83
  62. data/spec/lib/appsignal/environment_spec.rb +0 -190
  63. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +0 -60
  64. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -21
  65. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -21
  66. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -52
  67. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -21
  68. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -84
  69. data/spec/lib/appsignal/event_formatter/rom/sql_formatter_spec.rb +0 -22
  70. data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +0 -30
  71. data/spec/lib/appsignal/event_formatter/view_component/render_formatter_spec.rb +0 -41
  72. data/spec/lib/appsignal/event_formatter_spec.rb +0 -193
  73. data/spec/lib/appsignal/extension/jruby_spec.rb +0 -46
  74. data/spec/lib/appsignal/extension_install_failure_spec.rb +0 -20
  75. data/spec/lib/appsignal/extension_spec.rb +0 -178
  76. data/spec/lib/appsignal/garbage_collection_spec.rb +0 -98
  77. data/spec/lib/appsignal/hooks/action_cable_spec.rb +0 -345
  78. data/spec/lib/appsignal/hooks/action_mailer_spec.rb +0 -55
  79. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +0 -23
  80. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +0 -99
  81. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +0 -47
  82. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +0 -47
  83. data/spec/lib/appsignal/hooks/activejob_spec.rb +0 -650
  84. data/spec/lib/appsignal/hooks/at_exit_spec.rb +0 -105
  85. data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -40
  86. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -40
  87. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -38
  88. data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +0 -83
  89. data/spec/lib/appsignal/hooks/excon_spec.rb +0 -67
  90. data/spec/lib/appsignal/hooks/gvl_spec.rb +0 -145
  91. data/spec/lib/appsignal/hooks/http_spec.rb +0 -37
  92. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -46
  93. data/spec/lib/appsignal/hooks/mri_spec.rb +0 -23
  94. data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -18
  95. data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -30
  96. data/spec/lib/appsignal/hooks/puma_spec.rb +0 -80
  97. data/spec/lib/appsignal/hooks/que_spec.rb +0 -19
  98. data/spec/lib/appsignal/hooks/rake_spec.rb +0 -144
  99. data/spec/lib/appsignal/hooks/redis_client_spec.rb +0 -218
  100. data/spec/lib/appsignal/hooks/redis_spec.rb +0 -124
  101. data/spec/lib/appsignal/hooks/resque_spec.rb +0 -27
  102. data/spec/lib/appsignal/hooks/sequel_spec.rb +0 -44
  103. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -29
  104. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +0 -115
  105. data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -63
  106. data/spec/lib/appsignal/hooks/webmachine_spec.rb +0 -24
  107. data/spec/lib/appsignal/hooks_spec.rb +0 -124
  108. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -74
  109. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +0 -454
  110. data/spec/lib/appsignal/integrations/http_spec.rb +0 -111
  111. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +0 -154
  112. data/spec/lib/appsignal/integrations/net_http_spec.rb +0 -33
  113. data/spec/lib/appsignal/integrations/object_spec.rb +0 -347
  114. data/spec/lib/appsignal/integrations/puma_spec.rb +0 -150
  115. data/spec/lib/appsignal/integrations/que_spec.rb +0 -187
  116. data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -457
  117. data/spec/lib/appsignal/integrations/resque_spec.rb +0 -155
  118. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +0 -165
  119. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +0 -640
  120. data/spec/lib/appsignal/integrations/webmachine_spec.rb +0 -136
  121. data/spec/lib/appsignal/loaders/grape_spec.rb +0 -12
  122. data/spec/lib/appsignal/loaders/hanami_spec.rb +0 -92
  123. data/spec/lib/appsignal/loaders/padrino_spec.rb +0 -273
  124. data/spec/lib/appsignal/loaders/sinatra_spec.rb +0 -44
  125. data/spec/lib/appsignal/loaders_spec.rb +0 -144
  126. data/spec/lib/appsignal/logger_spec.rb +0 -205
  127. data/spec/lib/appsignal/marker_spec.rb +0 -51
  128. data/spec/lib/appsignal/probes/gvl_spec.rb +0 -164
  129. data/spec/lib/appsignal/probes/mri_spec.rb +0 -162
  130. data/spec/lib/appsignal/probes/sidekiq_spec.rb +0 -333
  131. data/spec/lib/appsignal/probes_spec.rb +0 -414
  132. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +0 -370
  133. data/spec/lib/appsignal/rack/body_wrapper_spec.rb +0 -319
  134. data/spec/lib/appsignal/rack/event_handler_spec.rb +0 -441
  135. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +0 -201
  136. data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +0 -36
  137. data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +0 -38
  138. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +0 -126
  139. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +0 -217
  140. data/spec/lib/appsignal/rack_spec.rb +0 -243
  141. data/spec/lib/appsignal/sample_data_spec.rb +0 -238
  142. data/spec/lib/appsignal/span_spec.rb +0 -141
  143. data/spec/lib/appsignal/system_spec.rb +0 -126
  144. data/spec/lib/appsignal/transaction_spec.rb +0 -2115
  145. data/spec/lib/appsignal/transmitter_spec.rb +0 -198
  146. data/spec/lib/appsignal/utils/data_spec.rb +0 -166
  147. data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +0 -182
  148. data/spec/lib/appsignal/utils/integration_logger_spec.rb +0 -21
  149. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -153
  150. data/spec/lib/appsignal/utils/json_spec.rb +0 -44
  151. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -192
  152. data/spec/lib/appsignal_spec.rb +0 -1919
  153. data/spec/lib/puma/appsignal_spec.rb +0 -334
  154. data/spec/spec_helper.rb +0 -179
  155. data/spec/support/fixtures/generated_config.yml +0 -24
  156. data/spec/support/fixtures/projects/broken/config/appsignal.yml +0 -1
  157. data/spec/support/fixtures/projects/valid/config/appsignal.yml +0 -57
  158. data/spec/support/fixtures/projects/valid/log/.gitkeep +0 -0
  159. data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +0 -16
  160. data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +0 -56
  161. data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +0 -10
  162. data/spec/support/fixtures/projects/valid_with_rails_app/log/.gitkeep +0 -0
  163. data/spec/support/fixtures/uploaded_file.txt +0 -0
  164. data/spec/support/hanami/hanami_app.rb +0 -29
  165. data/spec/support/helpers/action_mailer_helpers.rb +0 -25
  166. data/spec/support/helpers/activejob_helpers.rb +0 -27
  167. data/spec/support/helpers/api_request_helper.rb +0 -60
  168. data/spec/support/helpers/cli_helpers.rb +0 -40
  169. data/spec/support/helpers/config_helpers.rb +0 -66
  170. data/spec/support/helpers/dependency_helper.rb +0 -155
  171. data/spec/support/helpers/directory_helper.rb +0 -27
  172. data/spec/support/helpers/env_helpers.rb +0 -41
  173. data/spec/support/helpers/environment_metdata_helper.rb +0 -16
  174. data/spec/support/helpers/example_exception.rb +0 -13
  175. data/spec/support/helpers/example_standard_error.rb +0 -13
  176. data/spec/support/helpers/loader_helper.rb +0 -21
  177. data/spec/support/helpers/log_helpers.rb +0 -36
  178. data/spec/support/helpers/rails_helper.rb +0 -28
  179. data/spec/support/helpers/std_streams_helper.rb +0 -94
  180. data/spec/support/helpers/system_helpers.rb +0 -8
  181. data/spec/support/helpers/take_at_most_helper.rb +0 -21
  182. data/spec/support/helpers/time_helpers.rb +0 -11
  183. data/spec/support/helpers/transaction_helpers.rb +0 -122
  184. data/spec/support/helpers/wait_for_helper.rb +0 -39
  185. data/spec/support/matchers/contains_log.rb +0 -26
  186. data/spec/support/matchers/have_colorized_text.rb +0 -28
  187. data/spec/support/matchers/transaction.rb +0 -200
  188. data/spec/support/mocks/appsignal_mock.rb +0 -18
  189. data/spec/support/mocks/dummy_app.rb +0 -20
  190. data/spec/support/mocks/fake_gc_profiler.rb +0 -19
  191. data/spec/support/mocks/fake_gvl_tools.rb +0 -28
  192. data/spec/support/mocks/hash_like.rb +0 -10
  193. data/spec/support/mocks/mock_probe.rb +0 -13
  194. data/spec/support/mocks/puma_mock.rb +0 -43
  195. data/spec/support/shared_examples/instrument.rb +0 -48
  196. data/spec/support/stubs/appsignal/loaders/loader_stub.rb +0 -7
  197. data/spec/support/stubs/delayed_job.rb +0 -0
  198. data/spec/support/stubs/sidekiq/api.rb +0 -4
  199. data/spec/support/testing.rb +0 -203
  200. data/support/bundler_wrapper +0 -12
  201. data/support/install_deps +0 -33
@@ -1,198 +0,0 @@
1
- describe Appsignal::Transmitter do
2
- let(:config) do
3
- build_config(:options => { :hostname => "app1.local" }, :logger => Logger.new(log))
4
- end
5
- let(:base_uri) { "action" }
6
- let(:log) { StringIO.new }
7
- let(:instance) { Appsignal::Transmitter.new(base_uri, config) }
8
-
9
- describe "#uri" do
10
- let(:uri) { instance.uri }
11
-
12
- it "returns a URI object with configuration data" do
13
- expect(uri.to_s).to start_with(config[:endpoint])
14
- expect(uri.path).to eq("/1/action")
15
- expect(CGI.parse(uri.query)).to eq(
16
- "api_key" => ["abc"],
17
- "hostname" => ["app1.local"],
18
- "name" => ["TestApp"],
19
- "environment" => ["production"],
20
- "gem_version" => [Appsignal::VERSION]
21
- )
22
- end
23
-
24
- context "when base_uri argument is a full URI" do
25
- let(:base_uri) { "http://foo.bar/path" }
26
-
27
- it "uses the full URI" do
28
- expect(uri.to_s).to start_with("#{base_uri}?")
29
- end
30
- end
31
-
32
- context "when base_uri argument is only a path" do
33
- it "uses the config[:endpoint] base" do
34
- expect(uri.to_s).to start_with("#{config[:endpoint]}/1/#{base_uri}?")
35
- end
36
- end
37
- end
38
-
39
- describe "#transmit" do
40
- before do
41
- stub_request(:post, "https://push.appsignal.com/1/action").with(
42
- :query => {
43
- :api_key => "abc",
44
- :environment => "production",
45
- :gem_version => Appsignal::VERSION,
46
- :hostname => config[:hostname],
47
- :name => "TestApp"
48
- },
49
- :body => "{\"the\":\"payload\"}",
50
- :headers => {
51
- "Content-Type" => "application/json; charset=UTF-8"
52
- }
53
- ).to_return(:status => 200)
54
- end
55
-
56
- let(:response) { instance.transmit({ :the => :payload }) }
57
-
58
- it "returns Net::HTTP response" do
59
- expect(response).to be_kind_of(Net::HTTPResponse)
60
- expect(response.code).to eq "200"
61
- end
62
-
63
- describe "with :ndjson format" do
64
- before do
65
- stub_request(:post, "https://push.appsignal.com/1/action").with(
66
- :query => {
67
- :api_key => "abc",
68
- :environment => "production",
69
- :gem_version => Appsignal::VERSION,
70
- :hostname => config[:hostname],
71
- :name => "TestApp"
72
- },
73
- :body => "{\"the\":\"payload\"}\n{\"part\":\"two\"}",
74
- :headers => {
75
- "Content-Type" => "application/x-ndjson; charset=UTF-8"
76
- }
77
- ).to_return(:status => 200)
78
- end
79
-
80
- let(:response) do
81
- instance.transmit([{ :the => :payload }, { :part => :two }], :format => :ndjson)
82
- end
83
-
84
- it "returns Net::HTTP response" do
85
- expect(response).to be_kind_of(Net::HTTPResponse)
86
- expect(response.code).to eq "200"
87
- end
88
- end
89
-
90
- context "with ca_file_path config option set" do
91
- context "when file does not exist" do
92
- before do
93
- config.config_hash[:ca_file_path] = File.join(resources_dir, "cacert.pem")
94
- end
95
-
96
- it "ignores the config and logs a warning" do
97
- expect(response).to be_kind_of(Net::HTTPResponse)
98
- expect(response.code).to eq "200"
99
- expect(log.string).to_not include "Ignoring non-existing or unreadable " \
100
- "`ca_file_path`: #{config[:ca_file_path]}"
101
- end
102
- end
103
-
104
- context "when not existing file" do
105
- before do
106
- config.config_hash[:ca_file_path] = File.join(tmp_dir, "ca_file_that_does_not_exist")
107
- end
108
-
109
- it "ignores the config and logs a warning" do
110
- expect(response).to be_kind_of(Net::HTTPResponse)
111
- expect(response.code).to eq "200"
112
- expect(log.string).to include "Ignoring non-existing or unreadable " \
113
- "`ca_file_path`: #{config[:ca_file_path]}"
114
- end
115
- end
116
-
117
- context "when not readable file" do
118
- let(:file) { File.join(tmp_dir, "ca_file") }
119
- before do
120
- config.config_hash[:ca_file_path] = file
121
- File.open(file, "w") { |f| f.chmod 0o000 }
122
- end
123
-
124
- it "ignores the config and logs a warning" do
125
- expect(response).to be_kind_of(Net::HTTPResponse)
126
- expect(response.code).to eq "200"
127
- expect(log.string).to include "Ignoring non-existing or unreadable " \
128
- "`ca_file_path`: #{config[:ca_file_path]}"
129
- end
130
-
131
- after { File.delete file }
132
- end
133
- end
134
- end
135
-
136
- describe "#http_post" do
137
- subject { instance.send(:http_post, { "the" => "payload" }, :format => :json) }
138
-
139
- it "sets the path" do
140
- expect(subject.path).to eq instance.uri.request_uri
141
- end
142
-
143
- it "sets the correct headers" do
144
- expect(subject["Content-Type"]).to eq "application/json; charset=UTF-8"
145
- end
146
-
147
- it "serialises the payload to JSON" do
148
- expect(subject.body).to eq "{\"the\":\"payload\"}"
149
- end
150
-
151
- describe "with :ndjson format" do
152
- subject do
153
- instance.send(:http_post, [{ "the" => "payload" }, { "part" => "two" }], :format => :ndjson)
154
- end
155
-
156
- it "sets the correct headers" do
157
- expect(subject["Content-Type"]).to eq "application/x-ndjson; charset=UTF-8"
158
- end
159
-
160
- it "serialises the payload to NDJSON" do
161
- expect(subject.body).to eq "{\"the\":\"payload\"}\n{\"part\":\"two\"}"
162
- end
163
- end
164
- end
165
-
166
- describe "#http_client" do
167
- subject { instance.send(:http_client) }
168
-
169
- context "with a http uri" do
170
- let(:config) { build_config(:env => :test) }
171
-
172
- it { expect(subject).to be_instance_of(Net::HTTP) }
173
- it { expect(subject.proxy?).to be_falsy }
174
- it { expect(subject.use_ssl?).to be_falsy }
175
- end
176
-
177
- context "with a https uri" do
178
- let(:config) { build_config(:env => :production) }
179
-
180
- it { expect(subject).to be_instance_of(Net::HTTP) }
181
- it { expect(subject.proxy?).to be_falsy }
182
- it { expect(subject.use_ssl?).to be_truthy }
183
- it { expect(subject.verify_mode).to eq OpenSSL::SSL::VERIFY_PEER }
184
- it { expect(subject.ca_file).to eq config[:ca_file_path] }
185
- end
186
-
187
- context "with a proxy" do
188
- let(:config) { build_config(:options => { :http_proxy => "http://localhost:8080" }) }
189
-
190
- it "is of Net::HTTP class" do
191
- expect(subject).to be_instance_of(Net::HTTP)
192
- end
193
- it { expect(subject.proxy?).to be_truthy }
194
- it { expect(subject.proxy_address).to eq "localhost" }
195
- it { expect(subject.proxy_port).to eq 8080 }
196
- end
197
- end
198
- end
@@ -1,166 +0,0 @@
1
- describe Appsignal::Utils::Data do
2
- describe ".generate" do
3
- subject { Appsignal::Utils::Data.generate(body) }
4
-
5
- context "when extension is not loaded", :extension_installation_failure do
6
- around do |example|
7
- Appsignal::Testing.without_testing { example.run }
8
- end
9
-
10
- context "with valid hash body" do
11
- let(:body) { hash_body }
12
-
13
- it "does not error and returns MockData class" do
14
- expect(subject).to be_kind_of(Appsignal::Extension::MockData)
15
- expect(subject.to_s).to eql("{}")
16
- end
17
- end
18
-
19
- context "with valid array body" do
20
- let(:body) { array_body }
21
-
22
- it "does not error and returns MockData class" do
23
- expect(subject).to be_kind_of(Appsignal::Extension::MockData)
24
- expect(subject.to_s).to eql("{}")
25
- end
26
- end
27
-
28
- context "with an invalid body" do
29
- let(:body) { "body" }
30
-
31
- it "raise a type error" do
32
- expect do
33
- subject
34
- end.to raise_error TypeError
35
- end
36
- end
37
- end
38
-
39
- context "when extension is loaded" do
40
- context "with a valid hash body" do
41
- let(:body) { hash_body }
42
-
43
- it "returns a valid Data object" do
44
- is_expected.to eq Appsignal::Utils::Data.generate(body)
45
- is_expected.to_not eq Appsignal::Utils::Data.generate({})
46
- end
47
-
48
- describe "#to_s" do
49
- it "returns a serialized hash" do
50
- # rubocop:disable Style/StringConcatenation
51
- expect(subject.to_s).to eq %({"":"test",) +
52
- %("1":true,) +
53
- %("bar":null,) +
54
- %("baz":{"arr":[1,2],"foo":"bʊr"},) +
55
- %("float":1.0,) +
56
- %("foo":[1,2,"three",{"foo":"bar"}],) +
57
- %("int":1,) +
58
- %("int61":#{1 << 61},) +
59
- %("int62":#{1 << 62},) +
60
- %("int63":"bigint:#{1 << 63}",) +
61
- %("int64":"bigint:#{1 << 64}",) +
62
- %("the":"payload"})
63
- # rubocop:enable Style/StringConcatenation
64
- end
65
- end
66
- end
67
-
68
- context "with a valid array body" do
69
- let(:body) { array_body }
70
-
71
- it "returns a valid Data object" do
72
- is_expected.to eq Appsignal::Utils::Data.generate(body)
73
- is_expected.to_not eq Appsignal::Utils::Data.generate({})
74
- end
75
-
76
- describe "#to_s" do
77
- it "returns a serialized array" do
78
- # rubocop:disable Style/StringConcatenation, Style/RedundantStringEscape
79
- expect(subject.to_s).to eq %([null,) +
80
- %(true,) +
81
- %(false,) +
82
- %(\"string\",) +
83
- %(1,) +
84
- %(1.0,) +
85
- %(#{1 << 61},) +
86
- %(#{1 << 62},) +
87
- %("bigint:#{1 << 63}",) +
88
- %("bigint:#{1 << 64}",) +
89
- %({\"arr\":[1,2,\"three\"],\"foo\":\"bʊr\"}])
90
- # rubocop:enable Style/StringConcatenation, Style/RedundantStringEscape
91
- end
92
- end
93
- end
94
-
95
- context "with a body that contains strings with invalid utf-8 content" do
96
- let(:string_with_invalid_utf8) { [0x61, 0x61, 0x85].pack("c*") }
97
- let(:body) do
98
- {
99
- "field_one" => [0x61, 0x61].pack("c*"),
100
- :field_two => string_with_invalid_utf8,
101
- "field_three" => [
102
- "one", string_with_invalid_utf8
103
- ],
104
- "field_four" => {
105
- "one" => string_with_invalid_utf8
106
- }
107
- }
108
- end
109
-
110
- describe "#to_s" do
111
- it "returns a JSON representation in a String" do
112
- # rubocop:disable Style/StringConcatenation
113
- expect(subject.to_s).to eq %({"field_four":{"one":"aa�"},) +
114
- %("field_one":"aa",) +
115
- %("field_three":["one","aa�"],) +
116
- %("field_two":"aa�"})
117
- # rubocop:enable Style/StringConcatenation
118
- end
119
- end
120
- end
121
-
122
- context "with an invalid body" do
123
- let(:body) { "body" }
124
-
125
- it "raises a type error" do
126
- expect do
127
- subject
128
- end.to raise_error TypeError
129
- end
130
- end
131
- end
132
- end
133
-
134
- def hash_body
135
- {
136
- "the" => "payload",
137
- "int" => 1, # Fixnum
138
- "int61" => 1 << 61, # Fixnum
139
- "int62" => 1 << 62, # Bignum, this one still works
140
- "int63" => 1 << 63, # Bignum, turnover point for C, too big for long
141
- "int64" => 1 << 64, # Bignum
142
- "float" => 1.0,
143
- 1 => true,
144
- nil => "test",
145
- :foo => [1, 2, "three", { "foo" => "bar" }],
146
- "bar" => nil,
147
- "baz" => { "foo" => "bʊr", "arr" => [1, 2] }
148
- }
149
- end
150
-
151
- def array_body
152
- [
153
- nil,
154
- true,
155
- false,
156
- "string",
157
- 1, # Fixnum
158
- 1.0, # Float
159
- 1 << 61, # Fixnum
160
- 1 << 62, # Bignum, this one still works
161
- 1 << 63, # Bignum, turnover point for C, too big for long
162
- 1 << 64, # Bignum
163
- { "arr" => [1, 2, "three"], "foo" => "bʊr" }
164
- ]
165
- end
166
- end
@@ -1,182 +0,0 @@
1
- describe Appsignal::Utils::HashSanitizer do
2
- let(:file) { uploaded_file }
3
- let(:some_array) { [1, 2, 3] }
4
- let(:some_hash) { { :a => 1, :b => 2 } }
5
- let(:params) do
6
- {
7
- :text => "string",
8
- "string" => "string key value",
9
- :file => file,
10
- :float => 0.0,
11
- :bool_true => true,
12
- :bool_false => false,
13
- # Non-recursive appearances of the same array instance
14
- :some_arrays => [some_array, some_array],
15
- # Non-recursive appearances of the same hash instance
16
- :some_hashes => { :a => some_hash, :b => some_hash },
17
- :nil => nil,
18
- :int => 1, # Fixnum
19
- :int64 => 1 << 64, # Bignum
20
- :hash => {
21
- :nested_text => "string",
22
- :nested_array => [
23
- "something",
24
- "else",
25
- file,
26
- {
27
- :key => "value",
28
- :file => file
29
- }.tap do |hsh|
30
- # Recursive hash-in-hash (should be [:nested_array][3][:recursive_hash])
31
- hsh[:recursive_hash] = hsh
32
- end
33
- ].tap do |ary|
34
- # Recursive array-in-array (should be [:nested_array][4])
35
- ary << ary
36
- # Recursive array-in-hash (should be [:nested_array][3][:recursive_array])
37
- ary[3][:recursive_array] = ary
38
- end
39
- }.tap do |hsh|
40
- # Recursive hash-in-array (should be [:nested_array][5])
41
- hsh[:nested_array] << hsh
42
- end
43
- }
44
- end
45
-
46
- describe ".sanitize" do
47
- let(:sanitized_params) { described_class.sanitize(params) }
48
- subject { sanitized_params }
49
-
50
- it "returns a sanitized Hash" do
51
- expect(subject).to_not eq(params)
52
- is_expected.to be_instance_of Hash
53
- expect(subject[:text]).to eq("string")
54
- expect(subject["string"]).to eq("string key value")
55
- expect(subject[:file]).to be_instance_of String
56
- expect(subject[:file]).to include "::UploadedFile"
57
- expect(subject[:float]).to eq(0.0)
58
- expect(subject[:bool_true]).to be(true)
59
- expect(subject[:bool_false]).to be(false)
60
- expect(subject[:nil]).to be_nil
61
- expect(subject[:int]).to eq(1)
62
- expect(subject[:int64]).to eq(1 << 64)
63
- expect(subject[:some_arrays]).to eq([[1, 2, 3], [1, 2, 3]])
64
- expect(subject[:some_hashes]).to eq({ :a => { :a => 1, :b => 2 },
65
- :b => { :a => 1, :b => 2 } })
66
- end
67
-
68
- it "does not change the original params" do
69
- subject
70
- expect(params[:file]).to eq(file)
71
- expect(params[:hash][:nested_array][2]).to eq(file)
72
- end
73
-
74
- describe ":hash key" do
75
- subject { sanitized_params[:hash] }
76
-
77
- it "returns a sanitized Hash" do
78
- expect(subject).to_not eq(params[:hash])
79
- is_expected.to be_instance_of Hash
80
- expect(subject[:nested_text]).to eq("string")
81
- end
82
-
83
- describe ":nested_array key" do
84
- subject { sanitized_params[:hash][:nested_array] }
85
-
86
- it "returns a sanitized Array" do
87
- expect(subject).to_not eq(params[:hash][:nested_array])
88
- is_expected.to be_instance_of Array
89
- expect(subject[0]).to eq("something")
90
- expect(subject[1]).to eq("else")
91
- expect(subject[2]).to be_instance_of String
92
- expect(subject[2]).to include "::UploadedFile"
93
- end
94
-
95
- describe "nested hash" do
96
- subject { sanitized_params[:hash][:nested_array][3] }
97
-
98
- it "returns a sanitized Hash" do
99
- expect(subject).to_not eq(params[:hash][:nested_array][3])
100
- is_expected.to be_instance_of Hash
101
- expect(subject[:key]).to eq("value")
102
- expect(subject[:file]).to be_instance_of String
103
- expect(subject[:file]).to include "::UploadedFile"
104
- end
105
-
106
- it "replaces a recursive array" do
107
- expect(subject[:recursive_array]).to eq("[RECURSIVE VALUE]")
108
- end
109
-
110
- it "replaces a recursive hash" do
111
- expect(subject[:recursive_hash]).to eq("[RECURSIVE VALUE]")
112
- end
113
- end
114
-
115
- describe "nested array" do
116
- it "replaces a recursive array" do
117
- expect(sanitized_params[:hash][:nested_array][4]).to eq("[RECURSIVE VALUE]")
118
- end
119
-
120
- it "replaces a recursive hash" do
121
- expect(sanitized_params[:hash][:nested_array][5]).to eq("[RECURSIVE VALUE]")
122
- end
123
- end
124
- end
125
- end
126
-
127
- context "with filter_keys" do
128
- let(:sanitized_params) do
129
- described_class.sanitize(params, %w[text hash])
130
- end
131
- subject { sanitized_params }
132
-
133
- it "returns a sanitized Hash with the given keys filtered out" do
134
- expect(subject).to_not eq(params)
135
- expect(subject[:text]).to eq(described_class::FILTERED)
136
- expect(subject[:hash]).to eq(described_class::FILTERED)
137
-
138
- expect(subject[:file]).to be_instance_of String
139
- expect(subject[:file]).to include "::UploadedFile"
140
- expect(subject[:float]).to eq(0.0)
141
- expect(subject[:bool_true]).to be(true)
142
- expect(subject[:bool_false]).to be(false)
143
- expect(subject[:nil]).to be_nil
144
- expect(subject[:int]).to eq(1)
145
- end
146
-
147
- context "with strings as key filter values" do
148
- let(:sanitized_params) do
149
- described_class.sanitize(params, %w[string])
150
- end
151
-
152
- it "sanitizes values" do
153
- expect(subject["string"]).to eq("[FILTERED]")
154
- end
155
- end
156
-
157
- describe ":hash key" do
158
- let(:sanitized_params) do
159
- described_class.sanitize(params, %w[nested_text])
160
- end
161
- subject { sanitized_params[:hash] }
162
-
163
- it "sanitizes values in nested hashes" do
164
- expect(subject[:nested_text]).to eq("[FILTERED]")
165
- end
166
-
167
- describe ":nested_array" do
168
- describe ":nested_hash" do
169
- let(:sanitized_params) do
170
- described_class.sanitize(params, %w[key])
171
- end
172
- subject { sanitized_params[:hash][:nested_array][3] }
173
-
174
- it "sanitizes values in deeply nested hashes and arrays" do
175
- expect(subject[:key]).to eq("[FILTERED]")
176
- end
177
- end
178
- end
179
- end
180
- end
181
- end
182
- end
@@ -1,21 +0,0 @@
1
- describe Appsignal::Utils::IntegrationLogger do
2
- let(:log_stream) { std_stream }
3
- let(:logs) { log_contents(log_stream) }
4
- let(:logger) do
5
- Appsignal::Utils::IntegrationLogger.new(log_stream).tap do |l|
6
- l.formatter = logger_formatter
7
- end
8
- end
9
-
10
- it "logs messages" do
11
- logger.debug("debug message")
12
- logger.info("info message")
13
- logger.warn("warning message")
14
- logger.error("error message")
15
-
16
- expect(logs).to contains_log(:debug, "debug message")
17
- expect(logs).to contains_log(:info, "info message")
18
- expect(logs).to contains_log(:warn, "warning message")
19
- expect(logs).to contains_log(:error, "error message")
20
- end
21
- end