ratchetio 0.4.6 → 0.4.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.
- data/.travis.yml +3 -0
- data/CHANGELOG.md +3 -0
- data/lib/ratchetio/configuration.rb +2 -0
- data/lib/ratchetio/rails/controller_methods.rb +3 -0
- data/lib/ratchetio/version.rb +1 -1
- data/lib/ratchetio.rb +10 -2
- data/spec/controllers/home_controller_spec.rb +41 -0
- data/spec/ratchetio_spec.rb +0 -23
- data/spec/spec_helper.rb +5 -0
- metadata +2 -2
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -17,6 +17,7 @@ module Ratchetio
|
|
17
17
|
attr_accessor :person_username_method
|
18
18
|
attr_accessor :person_email_method
|
19
19
|
attr_accessor :root
|
20
|
+
attr_accessor :scrub_fields
|
20
21
|
|
21
22
|
DEFAULT_ENDPOINT = 'https://submit.ratchet.io/api/1/item/'
|
22
23
|
|
@@ -34,6 +35,7 @@ module Ratchetio
|
|
34
35
|
@person_id_method = 'id'
|
35
36
|
@person_username_method = 'username'
|
36
37
|
@person_email_method = 'email'
|
38
|
+
@scrub_fields = [:passwd, :password, :secret]
|
37
39
|
end
|
38
40
|
|
39
41
|
# allow params to be read like a hash
|
@@ -35,6 +35,7 @@ module Ratchetio
|
|
35
35
|
|
36
36
|
def ratchetio_filter_params(params)
|
37
37
|
filtered = {}
|
38
|
+
|
38
39
|
params.to_hash.each_pair do |k,v|
|
39
40
|
if v.is_a? ActionDispatch::Http::UploadedFile
|
40
41
|
# only save content_type, original_filename, and length
|
@@ -49,6 +50,8 @@ module Ratchetio
|
|
49
50
|
end
|
50
51
|
elsif v.is_a? Hash
|
51
52
|
filtered[k] = ratchetio_filter_params v
|
53
|
+
elsif Ratchetio.configuration.scrub_fields.include? k
|
54
|
+
filtered[k] = "*" * v.length
|
52
55
|
else
|
53
56
|
filtered[k] = v
|
54
57
|
end
|
data/lib/ratchetio/version.rb
CHANGED
data/lib/ratchetio.rb
CHANGED
@@ -24,6 +24,11 @@ module Ratchetio
|
|
24
24
|
def configure
|
25
25
|
yield(configuration)
|
26
26
|
end
|
27
|
+
|
28
|
+
def reconfigure
|
29
|
+
@configuration = Configuration.new
|
30
|
+
yield(configuration)
|
31
|
+
end
|
27
32
|
|
28
33
|
# Returns the configuration object.
|
29
34
|
#
|
@@ -148,8 +153,11 @@ module Ratchetio
|
|
148
153
|
|
149
154
|
uri = URI.parse(configuration.endpoint)
|
150
155
|
http = Net::HTTP.new(uri.host, uri.port)
|
151
|
-
|
152
|
-
|
156
|
+
|
157
|
+
if uri.scheme == 'https'
|
158
|
+
http.use_ssl = true
|
159
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
160
|
+
end
|
153
161
|
|
154
162
|
request = Net::HTTP::Post.new(uri.request_uri)
|
155
163
|
request.body = payload
|
@@ -3,7 +3,12 @@ require 'spec_helper'
|
|
3
3
|
describe HomeController do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
+
reset_configuration
|
6
7
|
Ratchetio.configure do |config|
|
8
|
+
config.access_token = 'aaaabbbbccccddddeeeeffff00001111'
|
9
|
+
config.environment = ::Rails.env
|
10
|
+
config.root = ::Rails.root
|
11
|
+
config.framework = "Rails: #{::Rails::VERSION::STRING}"
|
7
12
|
config.logger = logger_mock
|
8
13
|
end
|
9
14
|
end
|
@@ -84,6 +89,42 @@ describe HomeController do
|
|
84
89
|
filtered_file[:original_filename].should == file_hash[:filename]
|
85
90
|
filtered_file[:size].should == file_hash[:tempfile].size
|
86
91
|
end
|
92
|
+
|
93
|
+
it "should scrub the default scrub_fields" do
|
94
|
+
params = {
|
95
|
+
:passwd => "hidden",
|
96
|
+
:password => "hidden",
|
97
|
+
:secret => "hidden",
|
98
|
+
:notpass => "visible"
|
99
|
+
}
|
100
|
+
|
101
|
+
filtered = controller.send(:ratchetio_filter_params, params)
|
102
|
+
|
103
|
+
filtered[:passwd].should == "******"
|
104
|
+
filtered[:password].should == "******"
|
105
|
+
filtered[:secret].should == "******"
|
106
|
+
filtered[:notpass].should == "visible"
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should scrub custom scrub_fields" do
|
110
|
+
Ratchetio.configure do |config|
|
111
|
+
config.scrub_fields = [:notpass, :secret]
|
112
|
+
end
|
113
|
+
|
114
|
+
params = {
|
115
|
+
:passwd => "visible",
|
116
|
+
:password => "visible",
|
117
|
+
:secret => "hidden",
|
118
|
+
:notpass => "hidden"
|
119
|
+
}
|
120
|
+
|
121
|
+
filtered = controller.send(:ratchetio_filter_params, params)
|
122
|
+
|
123
|
+
filtered[:passwd].should == "visible"
|
124
|
+
filtered[:password].should == "visible"
|
125
|
+
filtered[:secret].should == "******"
|
126
|
+
filtered[:notpass].should == "******"
|
127
|
+
end
|
87
128
|
end
|
88
129
|
|
89
130
|
context "ratchetio_request_url" do
|
data/spec/ratchetio_spec.rb
CHANGED
@@ -285,27 +285,4 @@ describe Ratchetio do
|
|
285
285
|
'aaaabbbbccccddddeeeeffff00001111'
|
286
286
|
end
|
287
287
|
|
288
|
-
def reset_configuration
|
289
|
-
Ratchetio.configure do |config|
|
290
|
-
config.access_token = nil
|
291
|
-
config.branch = nil
|
292
|
-
config.default_logger = lambda { Logger.new(STDERR) }
|
293
|
-
config.enabled = true
|
294
|
-
config.endpoint = Ratchetio::Configuration::DEFAULT_ENDPOINT
|
295
|
-
config.environment = nil
|
296
|
-
config.exception_level_filters = {
|
297
|
-
'ActiveRecord::RecordNotFound' => 'warning',
|
298
|
-
'AbstractController::ActionNotFound' => 'warning',
|
299
|
-
'ActionController::RoutingError' => 'warning'
|
300
|
-
}
|
301
|
-
config.framework = 'Plain'
|
302
|
-
config.logger = nil
|
303
|
-
config.person_method = 'current_user'
|
304
|
-
config.person_id_method = 'id'
|
305
|
-
config.person_username_method = 'username'
|
306
|
-
config.person_email_method = 'email'
|
307
|
-
config.root = nil
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
288
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ratchetio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|