onelinejson 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/onelinejson.rb CHANGED
@@ -18,6 +18,12 @@ module Onelinejson
18
18
  /^HTTP_AUTHORIZATION$/,
19
19
  /.*HIDDEN.*/,
20
20
  ]
21
+
22
+ REJECTED_PARAMS = [
23
+ "password",
24
+ "password_confirmation"
25
+ ]
26
+
21
27
  ELIP = "\xe2\x80\xa6"
22
28
  LOG_MAX_LENGTH = 16384
23
29
  ENTRY_MAX_LENGTH = 128
@@ -80,8 +86,9 @@ module Onelinejson
80
86
  params.reject do |k,v|
81
87
  k == 'controller' ||
82
88
  k == 'action' ||
83
- v.is_a?(ActionDispatch::Http::UploadedFile) ||
84
- v.is_a?(Hash)
89
+ (defined?(ActionDispatch) && v.is_a?(ActionDispatch::Http::UploadedFile)) ||
90
+ v.is_a?(Hash) ||
91
+ REJECTED_PARAMS.include?(k.to_s.downcase)
85
92
  end
86
93
  end
87
94
 
@@ -1,3 +1,3 @@
1
1
  module Onelinejson
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -19,12 +19,37 @@ describe Onelinejson::AppControllerMethods do
19
19
  end
20
20
 
21
21
  describe '.extract_headers' do
22
+ let(:headers) { {"HTTP_X" => 0, "HTTP_AUTHORIZATION" => 1} }
23
+ let(:extracted) { Onelinejson::AppControllerMethods.extract_headers(headers) }
24
+ it "rejects Authorization" do
25
+ expect(extracted).to eq({"HTTP_X" => 0})
26
+ end
27
+
22
28
  context 'when rails 3' do
23
- it 'extracts'
29
+ let(:headers) { stub(env: {"HTTP_X" => 0}) }
30
+ it 'extracts' do
31
+ expect(extracted).to eq({"HTTP_X" => 0})
32
+ end
24
33
  end
25
34
 
26
35
  context 'when rails 4' do
27
- it 'extracts'
36
+ let(:headers) { stub(to_hash: {"HTTP_X" => 0}) }
37
+ it 'extracts' do
38
+ expect(extracted).to eq({"HTTP_X" => 0})
39
+ end
40
+ end
41
+ end
42
+
43
+ describe '.extract_params' do
44
+ let(:params) { {password: 0, "password" => 1, "password_confirmation" => 2, "x" => 3} }
45
+ let(:extracted) { Onelinejson::AppControllerMethods.extract_params(params) }
46
+
47
+ it 'rejects password' do
48
+ expect(extracted).to eq({"x" => 3})
49
+ end
50
+
51
+ it 'rejects password_confirmation' do
52
+ expect(extracted).to eq({"x" => 3})
28
53
  end
29
54
  end
30
55
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onelinejson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
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: 2014-03-20 00:00:00.000000000 Z
12
+ date: 2014-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lograge
@@ -60,7 +60,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
60
  version: '0'
61
61
  segments:
62
62
  - 0
63
- hash: -4410736805529295176
63
+ hash: 1245502309369756739
64
64
  required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  version: '0'
70
70
  segments:
71
71
  - 0
72
- hash: -4410736805529295176
72
+ hash: 1245502309369756739
73
73
  requirements: []
74
74
  rubyforge_project:
75
75
  rubygems_version: 1.8.23