p3p 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c491a4afd145f53e99b87d7fcd14d6d4a025516
4
- data.tar.gz: 954575000f78212db0ee6d99d2b584686187343a
3
+ metadata.gz: 1efe1a6e863dfcfc6f7150b817ac34356565baac
4
+ data.tar.gz: a3707c343bcb3148b7c1b4f966ee1ec0930678dd
5
5
  SHA512:
6
- metadata.gz: 62c8cb796aa5e879e33b5ed7e81f35838a1af892a93ad3e8c608a9d144d68eed1cf1ee72d8ca42db1574c27413d314ab828e985b31f90859450fb158b12d2154
7
- data.tar.gz: 72121dfb38b9c4cf742f3597c5ac3c211f9b6fd562ba7bb114a7c99709355499a8178e03c8f50f88ca0fd92639030b7fc0d821acecf492ae468886dc0e8bb225
6
+ metadata.gz: e72a87707679893d1a54395cdbe7f53c2707e2bdc89d190637da05c3d90c21e046dcde048c18a000a3d66381d28f3eb43fe76814fb4e4a58341901df0ae5b1e3
7
+ data.tar.gz: 395a8cc7c2ca967b5f639f60e9ff8e3720db698dc43e00144454f9887260f1c1a33c28017be7fe0caee4814f6cf626a26a8c07961009a6ba9c4512e6b889a0de
@@ -0,0 +1,60 @@
1
+ Lint/HandleExceptions:
2
+ Enabled: false
3
+
4
+ Metrics/BlockNesting:
5
+ Max: 2
6
+
7
+ Metrics/LineLength:
8
+ AllowURI: true
9
+ Enabled: false
10
+
11
+ Metrics/MethodLength:
12
+ CountComments: false
13
+ Max: 15
14
+
15
+ Metrics/ParameterLists:
16
+ Max: 4
17
+ CountKeywordArgs: true
18
+
19
+ Style/AccessModifierIndentation:
20
+ EnforcedStyle: outdent
21
+
22
+ Style/CollectionMethods:
23
+ PreferredMethods:
24
+ map: 'collect'
25
+ reduce: 'inject'
26
+ find: 'detect'
27
+ find_all: 'select'
28
+
29
+ Style/Documentation:
30
+ Enabled: false
31
+
32
+ Style/DotPosition:
33
+ EnforcedStyle: trailing
34
+
35
+ Style/DoubleNegation:
36
+ Enabled: false
37
+
38
+ Style/EachWithObject:
39
+ Enabled: false
40
+
41
+ Style/Encoding:
42
+ Enabled: false
43
+
44
+ Style/HashSyntax:
45
+ EnforcedStyle: hash_rockets
46
+
47
+ Style/Lambda:
48
+ Enabled: false
49
+
50
+ Style/RaiseArgs:
51
+ EnforcedStyle: compact
52
+
53
+ Style/RegexpLiteral:
54
+ Enabled: false
55
+
56
+ Style/SpaceInsideHashLiteralBraces:
57
+ EnforcedStyle: no_space
58
+
59
+ Style/TrailingComma:
60
+ EnforcedStyleForMultiline: 'comma'
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
data/lib/p3p.rb CHANGED
@@ -1,8 +1,9 @@
1
- require "p3p/configuration"
2
- require "p3p/middleware"
3
- require "p3p/version"
4
- require "p3p/railtie" if defined?(Rails)
1
+ require 'p3p/configuration'
2
+ require 'p3p/middleware'
3
+ require 'p3p/version'
4
+ require 'p3p/railtie' if defined?(Rails)
5
5
 
6
+ # Base module
6
7
  module P3P
7
8
  class << self
8
9
  attr_writer :configuration
@@ -1,9 +1,14 @@
1
1
  module P3P
2
+ # Responsible for handling P3P configuration
2
3
  class Configuration
3
4
  DEFAULT_HEADER = 'CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'
4
5
  attr_accessor :header
5
6
 
6
7
  def initialize
8
+ set_default_header!
9
+ end
10
+
11
+ def set_default_header!
7
12
  @header = DEFAULT_HEADER
8
13
  end
9
14
  end
@@ -1,12 +1,13 @@
1
1
  module P3P
2
+ # Responsible for applying the configured P3P header to the response
2
3
  class Middleware
3
- def initialize app
4
+ def initialize(app)
4
5
  @app = app
5
6
  end
6
7
 
7
- def call env
8
+ def call(env)
8
9
  res = @app.call(env)
9
- res[1]["P3P"] = P3P.configuration.header
10
+ res[1]['P3P'] = P3P.configuration.header
10
11
  res
11
12
  end
12
13
  end
@@ -1,6 +1,7 @@
1
1
  module P3P
2
+ # Responsible for applying middleware to Rails projects
2
3
  class Railtie < Rails::Railtie
3
- initializer "p3p.middleware" do |app|
4
+ initializer 'p3p.middleware' do |app|
4
5
  app.middleware.use Middleware
5
6
  end
6
7
  end
@@ -1,3 +1,4 @@
1
+ # Gem version information
1
2
  module P3P
2
- VERSION = "1.1.1"
3
+ VERSION = '1.2.0'
3
4
  end
@@ -4,19 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'p3p/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "p3p"
7
+ gem.name = 'p3p'
8
8
  gem.version = P3P::VERSION
9
- gem.authors = ["Tom Milewski"]
10
- gem.email = ["tmilewski@gmail.com"]
11
- gem.description = %q{Inserts P3P header}
12
- gem.summary = %q{Inserts P3P headers to allow cookies to be utilized in iframe scenarios with IE.}
13
- gem.homepage = "https://github.com/tmilewski/p3p"
9
+ gem.authors = ['Tom Milewski']
10
+ gem.email = ['tmilewski@gmail.com']
11
+ gem.description = 'Inserts P3P header'
12
+ gem.summary = 'Inserts P3P headers to allow cookies to be utilized in iframe scenarios with IE.'
13
+ gem.homepage = 'https://github.com/tmilewski/p3p'
14
14
 
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
16
+ gem.executables = gem.files.grep(%r{^bin/}).collect { |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
18
+ gem.require_paths = ['lib']
19
19
 
20
- gem.add_dependency "rack"
21
- gem.add_development_dependency "rspec", "~> 3.1.0"
20
+ gem.add_dependency 'rack'
21
+ gem.add_development_dependency 'rspec', '~> 3.1.0'
22
22
  end
@@ -1,36 +1,33 @@
1
1
  require 'spec_helper'
2
2
 
3
- shared_examples "it returns the configured P3P header" do |http_verb|
4
- let(:header) { P3P::Configuration::DEFAULT_HEADER }
5
-
6
- it "should return P3P headers in a the case of a #{http_verb} request" do
7
- headers = { 'Content-Type' => 'text/html' }
8
- app = lambda { |env| [200, headers, []] }
9
- request = Rack::MockRequest.env_for('/', lint: true, fatal: true, method: http_verb)
3
+ shared_examples 'it returns configured P3P header' do |header, http_verb|
4
+ it "should return custom P3P headers in the case of a #{http_verb} request" do
5
+ headers = {'Content-Type' => 'text/html'}
6
+ app = lambda { |_env| [200, headers, []] }
7
+ request = Rack::MockRequest.env_for('/', :lint => true, :fatal => true, :method => http_verb)
10
8
  response = P3P::Middleware.new(app).call(request)
11
9
 
12
- expect(response[1]).to include("P3P" => header)
10
+ expect(response[1]).to include('P3P' => header)
13
11
  end
14
12
  end
15
13
 
16
14
  describe P3P do
17
- describe "#configure" do
18
- let(:header) { "This is not a real p3p header. Check out our privacy policy at example.com/privacy" }
15
+ describe '#configure' do
16
+ let(:header) { 'Fake p3p header' }
19
17
 
20
18
  before do
21
19
  P3P.configure do |config|
22
- config.header = header
20
+ config.header = @header
23
21
  end
24
22
  end
25
23
 
26
- it_should_behave_like "it returns the configured P3P header", "GET"
27
- it_should_behave_like "it returns the configured P3P header", "POST"
28
- it_should_behave_like "it returns the configured P3P header", "PUT"
29
- it_should_behave_like "it returns the configured P3P header", "DELETE"
30
- it_should_behave_like "it returns the configured P3P header", "HEAD"
31
- it_should_behave_like "it returns the configured P3P header", "OPTIONS"
32
- it_should_behave_like "it returns the configured P3P header", "TRACE"
33
- it_should_behave_like "it returns the configured P3P header", "CONNECT"
34
-
24
+ it_should_behave_like 'it returns configured P3P header', @header, 'GET'
25
+ it_should_behave_like 'it returns configured P3P header', @header, 'POST'
26
+ it_should_behave_like 'it returns configured P3P header', @header, 'PUT'
27
+ it_should_behave_like 'it returns configured P3P header', @header, 'DELETE'
28
+ it_should_behave_like 'it returns configured P3P header', @header, 'HEAD'
29
+ it_should_behave_like 'it returns configured P3P header', @header, 'OPTIONS'
30
+ it_should_behave_like 'it returns configured P3P header', @header, 'TRACE'
31
+ it_should_behave_like 'it returns configured P3P header', @header, 'CONNECT'
35
32
  end
36
33
  end
@@ -1,23 +1,43 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
- shared_examples "it returns P3P headers" do |http_verb|
4
- it "should return P3P headers in a the case of a #{http_verb} request" do
5
- headers = { 'Content-Type' => 'text/html' }
6
- app = lambda { |env| [200, headers, []] }
7
- request = Rack::MockRequest.env_for('/', lint: true, fatal: true, method: http_verb)
3
+ shared_examples 'it returns P3P headers' do |http_verb|
4
+ it "should return default P3P headers in the case of a #{http_verb} request" do
5
+ headers = {'Content-Type' => 'text/html'}
6
+ app = lambda { |_env| [200, headers, []] }
7
+ request = Rack::MockRequest.env_for('/', :lint => true, :fatal => true, :method => http_verb)
8
8
  response = P3P::Middleware.new(app).call(request)
9
9
 
10
- expect(response[1]).to include("P3P"=> 'CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"')
10
+ expect(response[1]).to include('P3P' => P3P::Configuration::DEFAULT_HEADER)
11
11
  end
12
12
  end
13
13
 
14
14
  describe P3P::Middleware do
15
- it_should_behave_like "it returns P3P headers", "GET"
16
- it_should_behave_like "it returns P3P headers", "POST"
17
- it_should_behave_like "it returns P3P headers", "PUT"
18
- it_should_behave_like "it returns P3P headers", "DELETE"
19
- it_should_behave_like "it returns P3P headers", "HEAD"
20
- it_should_behave_like "it returns P3P headers", "OPTIONS"
21
- it_should_behave_like "it returns P3P headers", "TRACE"
22
- it_should_behave_like "it returns P3P headers", "CONNECT"
15
+ describe '.initialize' do
16
+ it 'should set the default header' do
17
+ expect_any_instance_of(P3P::Configuration).to receive(:set_default_header!)
18
+ P3P.configure { |_config| }
19
+ end
20
+ end
21
+
22
+ describe '.set_default_header!' do
23
+ it 'should set the default header' do
24
+ header = 'abc123'
25
+ default_header = P3P::Configuration::DEFAULT_HEADER
26
+
27
+ P3P.configure { |c| c.header = header }
28
+ expect(P3P.configuration.header).to eq header
29
+
30
+ P3P.configuration.set_default_header!
31
+ expect(P3P.configuration.header).to eq default_header
32
+ end
33
+ end
34
+
35
+ it_should_behave_like 'it returns P3P headers', 'GET'
36
+ it_should_behave_like 'it returns P3P headers', 'POST'
37
+ it_should_behave_like 'it returns P3P headers', 'PUT'
38
+ it_should_behave_like 'it returns P3P headers', 'DELETE'
39
+ it_should_behave_like 'it returns P3P headers', 'HEAD'
40
+ it_should_behave_like 'it returns P3P headers', 'OPTIONS'
41
+ it_should_behave_like 'it returns P3P headers', 'TRACE'
42
+ it_should_behave_like 'it returns P3P headers', 'CONNECT'
23
43
  end
@@ -1,7 +1,12 @@
1
- require "rack"
2
- require "p3p"
1
+ require 'rack'
2
+ require 'p3p'
3
3
 
4
4
  RSpec.configure do |config|
5
5
  config.color = true
6
6
  config.formatter = :documentation
7
+ config.order = :random
8
+
9
+ config.after(:each) do
10
+ P3P.configuration.set_default_header!
11
+ end
7
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: p3p
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Milewski
@@ -46,6 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
+ - ".rubocop.yml"
49
50
  - Gemfile
50
51
  - LICENSE.txt
51
52
  - README.md