appsignal 2.1.0.alpha.3 → 2.1.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +43 -0
- data/.rubocop_todo.yml +289 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +11 -1
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/appsignal.gemspec +1 -0
- data/bin/appsignal +2 -2
- data/ext/agent.yml +11 -11
- data/ext/extconf.rb +33 -33
- data/gemfiles/rails-4.2.gemfile +4 -0
- data/gemfiles/resque.gemfile +4 -0
- data/lib/appsignal.rb +58 -54
- data/lib/appsignal/auth_check.rb +15 -16
- data/lib/appsignal/capistrano.rb +4 -4
- data/lib/appsignal/cli.rb +28 -28
- data/lib/appsignal/cli/diagnose.rb +11 -11
- data/lib/appsignal/cli/helpers.rb +1 -1
- data/lib/appsignal/cli/install.rb +38 -38
- data/lib/appsignal/cli/notify_of_deploy.rb +1 -1
- data/lib/appsignal/config.rb +73 -71
- data/lib/appsignal/event_formatter.rb +8 -8
- data/lib/appsignal/event_formatter/action_view/render_formatter.rb +4 -4
- data/lib/appsignal/event_formatter/active_record/instantiation_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +9 -7
- data/lib/appsignal/event_formatter/faraday/request_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +6 -6
- data/lib/appsignal/event_formatter/moped/query_formatter.rb +56 -43
- data/lib/appsignal/extension.rb +5 -5
- data/lib/appsignal/hooks.rb +28 -26
- data/lib/appsignal/hooks/active_support_notifications.rb +2 -2
- data/lib/appsignal/hooks/celluloid.rb +1 -1
- data/lib/appsignal/hooks/data_mapper.rb +2 -2
- data/lib/appsignal/hooks/delayed_job.rb +1 -1
- data/lib/appsignal/hooks/mongo_ruby_driver.rb +1 -1
- data/lib/appsignal/hooks/net_http.rb +4 -4
- data/lib/appsignal/hooks/passenger.rb +2 -2
- data/lib/appsignal/hooks/puma.rb +4 -4
- data/lib/appsignal/hooks/rake.rb +1 -1
- data/lib/appsignal/hooks/redis.rb +1 -1
- data/lib/appsignal/hooks/sequel.rb +2 -2
- data/lib/appsignal/hooks/shoryuken.rb +8 -8
- data/lib/appsignal/hooks/sidekiq.rb +16 -15
- data/lib/appsignal/hooks/unicorn.rb +1 -1
- data/lib/appsignal/hooks/webmachine.rb +1 -1
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +6 -6
- data/lib/appsignal/integrations/data_mapper.rb +2 -3
- data/lib/appsignal/integrations/delayed_job_plugin.rb +5 -5
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +6 -6
- data/lib/appsignal/integrations/padrino.rb +8 -8
- data/lib/appsignal/integrations/railtie.rb +5 -5
- data/lib/appsignal/integrations/resque.rb +4 -5
- data/lib/appsignal/integrations/resque_active_job.rb +3 -6
- data/lib/appsignal/integrations/sinatra.rb +2 -2
- data/lib/appsignal/integrations/webmachine.rb +2 -3
- data/lib/appsignal/js_exception_transaction.rb +10 -10
- data/lib/appsignal/marker.rb +3 -3
- data/lib/appsignal/rack/generic_instrumentation.rb +10 -9
- data/lib/appsignal/rack/js_exception_catcher.rb +7 -6
- data/lib/appsignal/rack/rails_instrumentation.rb +9 -8
- data/lib/appsignal/rack/sinatra_instrumentation.rb +19 -17
- data/lib/appsignal/rack/streaming_listener.rb +9 -8
- data/lib/appsignal/system.rb +19 -17
- data/lib/appsignal/transaction.rb +97 -40
- data/lib/appsignal/transmitter.rb +23 -30
- data/lib/appsignal/utils.rb +3 -3
- data/lib/appsignal/utils/params_sanitizer.rb +1 -1
- data/lib/appsignal/utils/query_params_sanitizer.rb +1 -1
- data/lib/appsignal/version.rb +2 -2
- data/spec/.rubocop.yml +4 -0
- data/spec/lib/appsignal/auth_check_spec.rb +7 -7
- data/spec/lib/appsignal/capistrano2_spec.rb +41 -41
- data/spec/lib/appsignal/capistrano3_spec.rb +43 -44
- data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +9 -11
- data/spec/lib/appsignal/cli_spec.rb +9 -9
- data/spec/lib/appsignal/config_spec.rb +88 -86
- data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +9 -9
- data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +4 -4
- data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +4 -4
- data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +12 -12
- data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +4 -4
- data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +23 -23
- data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +29 -30
- data/spec/lib/appsignal/event_formatter_spec.rb +28 -28
- data/spec/lib/appsignal/extension_spec.rb +15 -15
- data/spec/lib/appsignal/garbage_collection_profiler_spec.rb +6 -5
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +12 -12
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +34 -34
- data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +3 -3
- data/spec/lib/appsignal/hooks/net_http_spec.rb +10 -10
- data/spec/lib/appsignal/hooks/rake_spec.rb +7 -7
- data/spec/lib/appsignal/hooks/redis_spec.rb +6 -6
- data/spec/lib/appsignal/hooks/shoryuken_spec.rb +21 -22
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +48 -45
- data/spec/lib/appsignal/hooks/webmachine_spec.rb +2 -2
- data/spec/lib/appsignal/hooks_spec.rb +16 -17
- data/spec/lib/appsignal/integrations/data_mapper_spec.rb +7 -8
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +19 -19
- data/spec/lib/appsignal/integrations/object_spec.rb +3 -3
- data/spec/lib/appsignal/integrations/padrino_spec.rb +44 -44
- data/spec/lib/appsignal/integrations/railtie_spec.rb +13 -13
- data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +7 -7
- data/spec/lib/appsignal/integrations/resque_spec.rb +8 -8
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +7 -7
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +15 -15
- data/spec/lib/appsignal/js_exception_transaction_spec.rb +23 -23
- data/spec/lib/appsignal/marker_spec.rb +8 -8
- data/spec/lib/appsignal/minutely_spec.rb +6 -6
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +7 -7
- data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +13 -13
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +11 -11
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +21 -21
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +36 -36
- data/spec/lib/appsignal/system/container_spec.rb +1 -1
- data/spec/lib/appsignal/transaction_spec.rb +213 -184
- data/spec/lib/appsignal/transmitter_spec.rb +20 -20
- data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +19 -19
- data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +41 -41
- data/spec/lib/appsignal/utils_spec.rb +41 -37
- data/spec/lib/appsignal_spec.rb +150 -142
- data/spec/spec_helper.rb +18 -18
- data/spec/support/delegate_matcher.rb +6 -6
- data/spec/support/helpers/api_request_helper.rb +2 -2
- data/spec/support/helpers/config_helpers.rb +3 -3
- data/spec/support/helpers/dependency_helper.rb +13 -13
- data/spec/support/helpers/directory_helper.rb +5 -5
- data/spec/support/helpers/env_helpers.rb +14 -14
- data/spec/support/helpers/system_helpers.rb +3 -3
- data/spec/support/helpers/transaction_helpers.rb +10 -10
- metadata +20 -2
@@ -1,21 +1,21 @@
|
|
1
1
|
describe Appsignal::Transmitter do
|
2
2
|
let(:config) { project_fixture_config }
|
3
|
-
let(:action) {
|
3
|
+
let(:action) { "action" }
|
4
4
|
let(:log) { StringIO.new }
|
5
5
|
let(:instance) { Appsignal::Transmitter.new(action, config) }
|
6
6
|
before do
|
7
|
-
config.config_hash[:hostname] =
|
7
|
+
config.config_hash[:hostname] = "app1.local"
|
8
8
|
config.logger = Logger.new(log)
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#uri" do
|
12
12
|
subject { instance.uri.to_s }
|
13
13
|
|
14
|
-
it { should include
|
15
|
-
it { should include
|
16
|
-
it { should include
|
17
|
-
it { should include
|
18
|
-
it { should include
|
14
|
+
it { should include "https://push.appsignal.com/1/action?" }
|
15
|
+
it { should include "api_key=abc" }
|
16
|
+
it { should include "hostname=app1.local" }
|
17
|
+
it { should include "name=TestApp" }
|
18
|
+
it { should include "environment=production" }
|
19
19
|
it { should include "gem_version=#{Appsignal::VERSION}" }
|
20
20
|
end
|
21
21
|
|
@@ -29,8 +29,8 @@ describe Appsignal::Transmitter do
|
|
29
29
|
).with(
|
30
30
|
:body => Appsignal::Utils::Gzip.compress("{\"the\":\"payload\"}"),
|
31
31
|
:headers => {
|
32
|
-
|
33
|
-
|
32
|
+
"Content-Encoding" => "gzip",
|
33
|
+
"Content-Type" => "application/json; charset=UTF-8"
|
34
34
|
}
|
35
35
|
).to_return(
|
36
36
|
:status => 200
|
@@ -38,7 +38,7 @@ describe Appsignal::Transmitter do
|
|
38
38
|
end
|
39
39
|
subject { instance.transmit(:the => :payload) }
|
40
40
|
|
41
|
-
it { should eq
|
41
|
+
it { should eq "200" }
|
42
42
|
|
43
43
|
context "with ca_file_path config option set" do
|
44
44
|
context "when not existing file" do
|
@@ -47,7 +47,7 @@ describe Appsignal::Transmitter do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it "ignores the config and logs a warning" do
|
50
|
-
expect(subject).to eq
|
50
|
+
expect(subject).to eq "200"
|
51
51
|
expect(log.string).to_not include "Ignoring non-existing or unreadable " \
|
52
52
|
"`ca_file_path`: #{config[:ca_file_path]}"
|
53
53
|
end
|
@@ -59,7 +59,7 @@ describe Appsignal::Transmitter do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it "ignores the config and logs a warning" do
|
62
|
-
expect(subject).to eq
|
62
|
+
expect(subject).to eq "200"
|
63
63
|
expect(log.string).to include "Ignoring non-existing or unreadable " \
|
64
64
|
"`ca_file_path`: #{config[:ca_file_path]}"
|
65
65
|
end
|
@@ -73,7 +73,7 @@ describe Appsignal::Transmitter do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it "ignores the config and logs a warning" do
|
76
|
-
expect(subject).to eq
|
76
|
+
expect(subject).to eq "200"
|
77
77
|
expect(log.string).to include "Ignoring non-existing or unreadable " \
|
78
78
|
"`ca_file_path`: #{config[:ca_file_path]}"
|
79
79
|
end
|
@@ -84,14 +84,14 @@ describe Appsignal::Transmitter do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
describe "#http_post" do
|
87
|
-
subject { instance.send(:http_post,
|
87
|
+
subject { instance.send(:http_post, "the" => "payload") }
|
88
88
|
|
89
89
|
its(:body) { should eq Appsignal::Utils::Gzip.compress("{\"the\":\"payload\"}") }
|
90
90
|
its(:path) { should eq instance.uri.request_uri }
|
91
91
|
|
92
92
|
it "should have the correct headers" do
|
93
|
-
subject[
|
94
|
-
subject[
|
93
|
+
subject["Content-Type"].should eq "application/json; charset=UTF-8"
|
94
|
+
subject["Content-Encoding"].should eq "gzip"
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -99,7 +99,7 @@ describe Appsignal::Transmitter do
|
|
99
99
|
subject { instance.send(:http_client) }
|
100
100
|
|
101
101
|
context "with a http uri" do
|
102
|
-
let(:config) { project_fixture_config(
|
102
|
+
let(:config) { project_fixture_config("test") }
|
103
103
|
|
104
104
|
it { should be_instance_of(Net::HTTP) }
|
105
105
|
its(:proxy?) { should be_false }
|
@@ -107,7 +107,7 @@ describe Appsignal::Transmitter do
|
|
107
107
|
end
|
108
108
|
|
109
109
|
context "with a https uri" do
|
110
|
-
let(:config) { project_fixture_config(
|
110
|
+
let(:config) { project_fixture_config("production") }
|
111
111
|
|
112
112
|
it { should be_instance_of(Net::HTTP) }
|
113
113
|
its(:proxy?) { should be_false }
|
@@ -117,10 +117,10 @@ describe Appsignal::Transmitter do
|
|
117
117
|
end
|
118
118
|
|
119
119
|
context "with a proxy" do
|
120
|
-
let(:config) { project_fixture_config(
|
120
|
+
let(:config) { project_fixture_config("production", :http_proxy => "http://localhost:8080") }
|
121
121
|
|
122
122
|
its(:proxy?) { should be_true }
|
123
|
-
its(:proxy_address) { should eq
|
123
|
+
its(:proxy_address) { should eq "localhost" }
|
124
124
|
its(:proxy_port) { should eq 8080 }
|
125
125
|
end
|
126
126
|
end
|
@@ -2,8 +2,8 @@ describe Appsignal::Utils::ParamsSanitizer do
|
|
2
2
|
let(:file) { uploaded_file }
|
3
3
|
let(:params) do
|
4
4
|
{
|
5
|
-
:text =>
|
6
|
-
|
5
|
+
:text => "string",
|
6
|
+
"string" => "string key value",
|
7
7
|
:file => file,
|
8
8
|
:float => 0.0,
|
9
9
|
:bool_true => true,
|
@@ -11,13 +11,13 @@ describe Appsignal::Utils::ParamsSanitizer do
|
|
11
11
|
:nil => nil,
|
12
12
|
:int => 1,
|
13
13
|
:hash => {
|
14
|
-
:nested_text =>
|
14
|
+
:nested_text => "string",
|
15
15
|
:nested_array => [
|
16
|
-
|
17
|
-
|
16
|
+
"something",
|
17
|
+
"else",
|
18
18
|
file,
|
19
19
|
{
|
20
|
-
:key =>
|
20
|
+
:key => "value",
|
21
21
|
:file => file
|
22
22
|
}
|
23
23
|
]
|
@@ -30,10 +30,10 @@ describe Appsignal::Utils::ParamsSanitizer do
|
|
30
30
|
subject { sanitized_params }
|
31
31
|
|
32
32
|
it { should be_instance_of Hash }
|
33
|
-
its([:text]) { should eq(
|
34
|
-
its([
|
33
|
+
its([:text]) { should eq("string") }
|
34
|
+
its(["string"]) { should eq("string key value") }
|
35
35
|
its([:file]) { should be_instance_of String }
|
36
|
-
its([:file]) { should include
|
36
|
+
its([:file]) { should include "::UploadedFile" }
|
37
37
|
its([:float]) { should eq(0.0) }
|
38
38
|
its([:bool_true]) { should be(true) }
|
39
39
|
its([:bool_false]) { should be(false) }
|
@@ -50,24 +50,24 @@ describe Appsignal::Utils::ParamsSanitizer do
|
|
50
50
|
subject { sanitized_params[:hash] }
|
51
51
|
|
52
52
|
it { should be_instance_of Hash }
|
53
|
-
its([:nested_text]) { should eq(
|
53
|
+
its([:nested_text]) { should eq("string") }
|
54
54
|
|
55
55
|
describe ":nested_array" do
|
56
56
|
subject { sanitized_params[:hash][:nested_array] }
|
57
57
|
|
58
58
|
it { should be_instance_of Array }
|
59
|
-
its([0]) { should eq(
|
60
|
-
its([1]) { should eq(
|
59
|
+
its([0]) { should eq("something") }
|
60
|
+
its([1]) { should eq("else") }
|
61
61
|
its([2]) { should be_instance_of String }
|
62
|
-
its([2]) { should include
|
62
|
+
its([2]) { should include "::UploadedFile" }
|
63
63
|
|
64
64
|
describe ":nested_hash" do
|
65
65
|
subject { sanitized_params[:hash][:nested_array][3] }
|
66
66
|
|
67
67
|
it { should be_instance_of Hash }
|
68
|
-
its([:key]) { should eq(
|
68
|
+
its([:key]) { should eq("value") }
|
69
69
|
its([:file]) { should be_instance_of String }
|
70
|
-
its([:file]) { should include
|
70
|
+
its([:file]) { should include "::UploadedFile" }
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -81,7 +81,7 @@ describe Appsignal::Utils::ParamsSanitizer do
|
|
81
81
|
its([:text]) { should eq(described_class::FILTERED) }
|
82
82
|
its([:hash]) { should eq(described_class::FILTERED) }
|
83
83
|
its([:file]) { should be_instance_of String }
|
84
|
-
its([:file]) { should include
|
84
|
+
its([:file]) { should include "::UploadedFile" }
|
85
85
|
its([:float]) { should eq(0.0) }
|
86
86
|
its([:bool_true]) { should be(true) }
|
87
87
|
its([:bool_false]) { should be(false) }
|
@@ -93,7 +93,7 @@ describe Appsignal::Utils::ParamsSanitizer do
|
|
93
93
|
described_class.sanitize(params, :filter_parameters => %w(string))
|
94
94
|
end
|
95
95
|
|
96
|
-
its([
|
96
|
+
its(["string"]) { should eq("[FILTERED]") }
|
97
97
|
end
|
98
98
|
|
99
99
|
describe ":hash" do
|
@@ -102,7 +102,7 @@ describe Appsignal::Utils::ParamsSanitizer do
|
|
102
102
|
end
|
103
103
|
subject { sanitized_params[:hash] }
|
104
104
|
|
105
|
-
its([:nested_text]) { should eq(
|
105
|
+
its([:nested_text]) { should eq("[FILTERED]") }
|
106
106
|
|
107
107
|
describe ":nested_array" do
|
108
108
|
describe ":nested_hash" do
|
@@ -111,7 +111,7 @@ describe Appsignal::Utils::ParamsSanitizer do
|
|
111
111
|
end
|
112
112
|
subject { sanitized_params[:hash][:nested_array][3] }
|
113
113
|
|
114
|
-
its([:key]) { should eq(
|
114
|
+
its([:key]) { should eq("[FILTERED]") }
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
@@ -4,70 +4,70 @@ describe Appsignal::Utils::QueryParamsSanitizer do
|
|
4
4
|
subject { described_class.sanitize(value, true) }
|
5
5
|
|
6
6
|
context "when value is a hash" do
|
7
|
-
let(:value) { {
|
7
|
+
let(:value) { { "foo" => "bar" } }
|
8
8
|
|
9
9
|
it "should only return the first level of the object" do
|
10
|
-
expect(subject).to eq(
|
10
|
+
expect(subject).to eq("foo" => "?")
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should not modify source value" do
|
14
14
|
subject
|
15
|
-
expect(value).to eq(
|
15
|
+
expect(value).to eq("foo" => "bar")
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context "when value is a nested hash" do
|
20
|
-
let(:value) { {
|
20
|
+
let(:value) { { "foo" => { "bar" => "baz" } } }
|
21
21
|
|
22
22
|
it "should only return the first level of the object" do
|
23
|
-
expect(subject).to eq(
|
23
|
+
expect(subject).to eq("foo" => "?")
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should not modify source value" do
|
27
27
|
subject
|
28
|
-
expect(value).to eq(
|
28
|
+
expect(value).to eq("foo" => { "bar" => "baz" })
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
context "when value is an array of hashes" do
|
33
|
-
let(:value) { [
|
33
|
+
let(:value) { ["foo" => "bar"] }
|
34
34
|
|
35
35
|
it "should sanitize all hash values with a questionmark" do
|
36
|
-
expect(subject).to eq(
|
36
|
+
expect(subject).to eq("foo" => "?")
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should not modify source value" do
|
40
40
|
subject
|
41
|
-
expect(value).to eq([
|
41
|
+
expect(value).to eq(["foo" => "bar"])
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
context "when value is an array" do
|
46
|
-
let(:value) { [
|
46
|
+
let(:value) { ["foo", "bar"] }
|
47
47
|
|
48
48
|
it "should only return the first level of the object" do
|
49
|
-
expect(subject).to eq(
|
49
|
+
expect(subject).to eq("?")
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should not modify source value" do
|
53
53
|
subject
|
54
|
-
expect(value).to eq([
|
54
|
+
expect(value).to eq(["foo", "bar"])
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
context "when value is a mixed array" do
|
59
|
-
let(:value) { [nil,
|
59
|
+
let(:value) { [nil, "foo", "bar"] }
|
60
60
|
|
61
61
|
it "should sanitize all hash values with a single questionmark" do
|
62
|
-
expect(subject).to eq(
|
62
|
+
expect(subject).to eq("?")
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
context "when value is a string" do
|
67
|
-
let(:value) {
|
67
|
+
let(:value) { "foo" }
|
68
68
|
|
69
69
|
it "should sanitize all hash values with a questionmark" do
|
70
|
-
expect(subject).to eq(
|
70
|
+
expect(subject).to eq("?")
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -76,65 +76,65 @@ describe Appsignal::Utils::QueryParamsSanitizer do
|
|
76
76
|
subject { described_class.sanitize(value, false) }
|
77
77
|
|
78
78
|
context "when value is a hash" do
|
79
|
-
let(:value) { {
|
79
|
+
let(:value) { { "foo" => "bar" } }
|
80
80
|
|
81
81
|
it "should sanitize all hash values with a questionmark" do
|
82
|
-
expect(subject).to eq(
|
82
|
+
expect(subject).to eq("foo" => "?")
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should not modify source value" do
|
86
86
|
subject
|
87
|
-
expect(value).to eq(
|
87
|
+
expect(value).to eq("foo" => "bar")
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
context "when value is a nested hash" do
|
92
|
-
let(:value) { {
|
92
|
+
let(:value) { { "foo" => { "bar" => "baz" } } }
|
93
93
|
|
94
94
|
it "should replaces values" do
|
95
|
-
expect(subject).to eq(
|
95
|
+
expect(subject).to eq("foo" => { "bar" => "?" })
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should not modify source value" do
|
99
99
|
subject
|
100
|
-
expect(value).to eq(
|
100
|
+
expect(value).to eq("foo" => { "bar" => "baz" })
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
104
|
context "when value is an array of hashes" do
|
105
|
-
let(:value) { [
|
105
|
+
let(:value) { ["foo" => "bar"] }
|
106
106
|
|
107
107
|
it "should sanitize all hash values with a questionmark" do
|
108
|
-
expect(subject).to eq([
|
108
|
+
expect(subject).to eq(["foo" => "?"])
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should not modify source value" do
|
112
112
|
subject
|
113
|
-
expect(value).to eq([
|
113
|
+
expect(value).to eq(["foo" => "bar"])
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
117
|
context "when value is an array" do
|
118
|
-
let(:value) { [
|
118
|
+
let(:value) { ["foo", "bar"] }
|
119
119
|
|
120
120
|
it "should sanitize all hash values with a single questionmark" do
|
121
|
-
expect(subject).to eq([
|
121
|
+
expect(subject).to eq(["?"])
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
125
|
context "when value is a mixed array" do
|
126
|
-
let(:value) { [nil,
|
126
|
+
let(:value) { [nil, "foo", "bar"] }
|
127
127
|
|
128
128
|
it "should sanitize all hash values with a single questionmark" do
|
129
|
-
expect(subject).to eq([
|
129
|
+
expect(subject).to eq(["?"])
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
133
|
context "when value is a string" do
|
134
|
-
let(:value) {
|
134
|
+
let(:value) { "bar" }
|
135
135
|
|
136
136
|
it "should sanitize all hash values with a questionmark" do
|
137
|
-
expect(subject).to eq(
|
137
|
+
expect(subject).to eq("?")
|
138
138
|
end
|
139
139
|
end
|
140
140
|
end
|
@@ -145,18 +145,18 @@ describe Appsignal::Utils::QueryParamsSanitizer do
|
|
145
145
|
subject { described_class.sanitize(value) }
|
146
146
|
|
147
147
|
context "when dots are in the key" do
|
148
|
-
let(:value) { {
|
148
|
+
let(:value) { { "foo.bar" => "bar" } }
|
149
149
|
|
150
150
|
it "should not sanitize the key" do
|
151
|
-
expect(subject).to eql(
|
151
|
+
expect(subject).to eql("foo.bar" => "?")
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
155
|
context "when key is a symbol" do
|
156
|
-
let(:value) { {:ismaster =>
|
156
|
+
let(:value) { { :ismaster => "bar" } }
|
157
157
|
|
158
158
|
it "should sanitize the key" do
|
159
|
-
expect(subject).to eql(:ismaster =>
|
159
|
+
expect(subject).to eql(:ismaster => "?")
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|
@@ -165,26 +165,26 @@ describe Appsignal::Utils::QueryParamsSanitizer do
|
|
165
165
|
subject { described_class.sanitize(value, false, :mongodb) }
|
166
166
|
|
167
167
|
context "when no dots are in the key" do
|
168
|
-
let(:value) { {
|
168
|
+
let(:value) { { "foo" => "bar" } }
|
169
169
|
|
170
170
|
it "should not sanitize the key" do
|
171
|
-
expect(subject).to eql(
|
171
|
+
expect(subject).to eql("foo" => "?")
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
175
|
context "when dots are in the key" do
|
176
|
-
let(:value) { {
|
176
|
+
let(:value) { { "foo.bar" => "bar" } }
|
177
177
|
|
178
178
|
it "should sanitize the key" do
|
179
|
-
expect(subject).to eql(
|
179
|
+
expect(subject).to eql("foo.?" => "?")
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
183
|
context "when key is a symbol" do
|
184
|
-
let(:value) { {:ismaster =>
|
184
|
+
let(:value) { { :ismaster => "bar" } }
|
185
185
|
|
186
186
|
it "should sanitize the key" do
|
187
|
-
expect(subject).to eql(
|
187
|
+
expect(subject).to eql("ismaster" => "?")
|
188
188
|
end
|
189
189
|
end
|
190
190
|
end
|
@@ -7,54 +7,56 @@ describe Appsignal::Utils do
|
|
7
7
|
context "with a valid hash body" do
|
8
8
|
let(:body) do
|
9
9
|
{
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
"the" => "payload",
|
11
|
+
"int" => 1,
|
12
|
+
"float" => 1.0,
|
13
13
|
1 => true,
|
14
|
-
nil =>
|
15
|
-
:foo => [1, 2,
|
16
|
-
|
17
|
-
|
14
|
+
nil => "test",
|
15
|
+
:foo => [1, 2, "three", { "foo" => "bar" }],
|
16
|
+
"bar" => nil,
|
17
|
+
"baz" => { "foo" => "bʊr", "arr" => [1, 2] }
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
21
|
it { should eq Appsignal::Utils.data_generate(body) }
|
22
22
|
it { should_not eq Appsignal::Utils.data_generate({}) }
|
23
|
-
it { should_not eq
|
23
|
+
it { should_not eq "a string" }
|
24
24
|
its(:to_s) { should eq %({"":"test","1":true,"bar":null,"baz":{"arr":[1,2],"foo":"bʊr"},"float":1.0,"foo":[1,2,"three",{"foo":"bar"}],"int":1,"the":"payload"}) }
|
25
25
|
end
|
26
26
|
|
27
27
|
context "with a valid array body" do
|
28
28
|
let(:body) do
|
29
|
-
[1,
|
29
|
+
[1, "string", 10, { "foo" => "bʊr" }]
|
30
30
|
end
|
31
31
|
|
32
32
|
its(:to_s) { should eq %([1,\"string\",10,{\"foo\":\"bʊr\"}]) }
|
33
33
|
end
|
34
34
|
|
35
35
|
context "with a body that contains strings with invalid utf-8 content" do
|
36
|
-
let(:string_with_invalid_utf8) { [0x61, 0x61, 0x85].pack(
|
37
|
-
let(:body)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
36
|
+
let(:string_with_invalid_utf8) { [0x61, 0x61, 0x85].pack("c*") }
|
37
|
+
let(:body) do
|
38
|
+
{
|
39
|
+
"field_one" => [0x61, 0x61].pack("c*"),
|
40
|
+
:field_two => string_with_invalid_utf8,
|
41
|
+
"field_three" => [
|
42
|
+
"one", string_with_invalid_utf8
|
43
|
+
],
|
44
|
+
"field_four" => {
|
45
|
+
"one" => string_with_invalid_utf8
|
46
|
+
}
|
45
47
|
}
|
46
|
-
|
48
|
+
end
|
47
49
|
|
48
50
|
its(:to_s) { should eq %({"field_four":{"one":"aa�"},"field_one":"aa","field_three":["one","aa�"],"field_two":"aa�"}) }
|
49
51
|
end
|
50
52
|
|
51
53
|
context "with an invalid body" do
|
52
|
-
let(:body) {
|
54
|
+
let(:body) { "body" }
|
53
55
|
|
54
56
|
it "should raise a type error" do
|
55
|
-
expect
|
57
|
+
expect do
|
56
58
|
subject
|
57
|
-
|
59
|
+
end.to raise_error TypeError
|
58
60
|
end
|
59
61
|
end
|
60
62
|
end
|
@@ -65,12 +67,12 @@ describe Appsignal::Utils do
|
|
65
67
|
context "with a valid body" do
|
66
68
|
let(:body) do
|
67
69
|
{
|
68
|
-
|
70
|
+
"the" => "payload",
|
69
71
|
1 => true,
|
70
|
-
nil =>
|
71
|
-
:foo => [1, 2,
|
72
|
-
|
73
|
-
|
72
|
+
nil => "test",
|
73
|
+
:foo => [1, 2, "three"],
|
74
|
+
"bar" => nil,
|
75
|
+
"baz" => { "foo" => "bar" }
|
74
76
|
}
|
75
77
|
end
|
76
78
|
|
@@ -78,17 +80,19 @@ describe Appsignal::Utils do
|
|
78
80
|
end
|
79
81
|
|
80
82
|
context "with a body that contains strings with invalid utf-8 content" do
|
81
|
-
let(:string_with_invalid_utf8) { [0x61, 0x61, 0x85].pack(
|
82
|
-
let(:body)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
let(:string_with_invalid_utf8) { [0x61, 0x61, 0x85].pack("c*") }
|
84
|
+
let(:body) do
|
85
|
+
{
|
86
|
+
"field_one" => [0x61, 0x61].pack("c*"),
|
87
|
+
:field_two => string_with_invalid_utf8,
|
88
|
+
"field_three" => [
|
89
|
+
"one", string_with_invalid_utf8
|
90
|
+
],
|
91
|
+
"field_four" => {
|
92
|
+
"one" => string_with_invalid_utf8
|
93
|
+
}
|
90
94
|
}
|
91
|
-
|
95
|
+
end
|
92
96
|
|
93
97
|
it { should eq %({"field_one":"aa","field_two":"aa�","field_three":["one","aa�"],"field_four":{"one":"aa�"}}) }
|
94
98
|
end
|