shield 0.1.0.rc1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/cuba.rb CHANGED
@@ -1,20 +1,8 @@
1
1
  require File.expand_path("helper", File.dirname(__FILE__))
2
-
3
- class User < Struct.new(:id)
4
- extend Shield::Model
5
-
6
- def self.[](id)
7
- User.new(1) unless id.to_s.empty?
8
- end
9
-
10
- def self.authenticate(username, password)
11
- User.new(1001) if username == "quentin" && password == "password"
12
- end
13
- end
2
+ require File.expand_path("user", File.dirname(__FILE__))
14
3
 
15
4
  Cuba.use Rack::Session::Cookie
16
-
17
- Cuba.send :include, Shield::Helpers
5
+ Cuba.plugin Shield::Helpers
18
6
 
19
7
  Cuba.define do
20
8
  on get, "public" do
@@ -50,17 +38,6 @@ scope do
50
38
  Cuba
51
39
  end
52
40
 
53
- def assert_redirected_to(path)
54
- unless last_response.status == 302
55
- flunk
56
- end
57
- assert_equal path, URI(last_response.headers["Location"]).path
58
- end
59
-
60
- def session
61
- last_request.env["rack.session"]
62
- end
63
-
64
41
  setup do
65
42
  clear_cookies
66
43
  end
data/test/helper.rb CHANGED
@@ -4,7 +4,19 @@ require "shield"
4
4
  require "cutest"
5
5
  require "rack/test"
6
6
  require "cuba"
7
+ require "sinatra/base"
7
8
 
8
9
  class Cutest::Scope
9
10
  include Rack::Test::Methods
10
- end
11
+
12
+ def assert_redirected_to(path)
13
+ unless last_response.status == 302
14
+ flunk
15
+ end
16
+ assert_equal path, URI(last_response.headers["Location"]).path
17
+ end
18
+
19
+ def session
20
+ last_request.env["rack.session"]
21
+ end
22
+ end
data/test/model.rb CHANGED
@@ -42,4 +42,4 @@ test "authenticate" do
42
42
  assert user == User.authenticate("quentin", "pass")
43
43
  assert nil == User.authenticate("unknown", "pass")
44
44
  assert nil == User.authenticate("quentin", "wrongpass")
45
- end
45
+ end
data/test/sinatra.rb CHANGED
@@ -1,17 +1,5 @@
1
1
  require File.expand_path("helper", File.dirname(__FILE__))
2
- require "sinatra/base"
3
-
4
- class User < Struct.new(:id)
5
- extend Shield::Model
6
-
7
- def self.[](id)
8
- User.new(1) unless id.to_s.empty?
9
- end
10
-
11
- def self.authenticate(username, password)
12
- User.new(1001) if username == "quentin" && password == "password"
13
- end
14
- end
2
+ require File.expand_path("user", File.dirname(__FILE__))
15
3
 
16
4
  class SinatraApp < Sinatra::Base
17
5
  enable :sessions
@@ -50,23 +38,6 @@ scope do
50
38
  SinatraApp.new
51
39
  end
52
40
 
53
- def assert_redirected_to(path)
54
- unless last_response.status == 302
55
- flunk
56
- end
57
- assert_equal path, URI(last_response.headers["Location"]).path
58
- end
59
-
60
- def session
61
- last_request.env["rack.session"]
62
- end
63
-
64
- def debug
65
- require "open3"
66
- out, _, _ = Open3.capture3("elinks -dump", stdin_data: last_response.body)
67
- puts out
68
- end
69
-
70
41
  setup do
71
42
  clear_cookies
72
43
  end
@@ -113,4 +84,4 @@ scope do
113
84
 
114
85
  assert_equal nil, session[:remember_for]
115
86
  end
116
- end
87
+ end
data/test/user.rb ADDED
@@ -0,0 +1,21 @@
1
+ class User
2
+ extend Shield::Model
3
+
4
+ def self.[](id)
5
+ User.new(1001) unless id.to_s.empty?
6
+ end
7
+
8
+ def self.fetch(username)
9
+ User.new(1001) if username == "quentin"
10
+ end
11
+
12
+ attr :id
13
+
14
+ def initialize(id)
15
+ @id = id
16
+ end
17
+
18
+ def crypted_password
19
+ @crypted_password ||= Shield::Password.encrypt("password")
20
+ end
21
+ end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shield
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc1
5
- prerelease: 6
4
+ version: 0.1.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michel Martens
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-01-21 00:00:00.000000000 Z
14
+ date: 2012-03-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: cutest
18
- requirement: &2156273880 !ruby/object:Gem::Requirement
18
+ requirement: &70247759932460 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '0'
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *2156273880
26
+ version_requirements: *70247759932460
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: cuba
29
- requirement: &2156272920 !ruby/object:Gem::Requirement
29
+ requirement: &70247759931940 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
- version_requirements: *2156272920
37
+ version_requirements: *70247759931940
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: sinatra
40
- requirement: &2156271720 !ruby/object:Gem::Requirement
40
+ requirement: &70247759931460 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *2156271720
48
+ version_requirements: *70247759931460
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: rack-test
51
- requirement: &2156270860 !ruby/object:Gem::Requirement
51
+ requirement: &70247759930920 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: '0'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *2156270860
59
+ version_requirements: *70247759930920
60
60
  description: ! "\n Provides all the protocol you need in order to do authentication
61
61
  on\n your rack application. The implementation specifics can be found in\n http://github.com/cyx/shield-contrib\n
62
62
  \ "
@@ -80,6 +80,7 @@ files:
80
80
  - test/password.rb
81
81
  - test/shield.rb
82
82
  - test/sinatra.rb
83
+ - test/user.rb
83
84
  homepage: http://github.com/cyx/shield
84
85
  licenses: []
85
86
  post_install_message:
@@ -95,9 +96,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
96
  required_rubygems_version: !ruby/object:Gem::Requirement
96
97
  none: false
97
98
  requirements:
98
- - - ! '>'
99
+ - - ! '>='
99
100
  - !ruby/object:Gem::Version
100
- version: 1.3.1
101
+ version: '0'
101
102
  requirements: []
102
103
  rubyforge_project: shield
103
104
  rubygems_version: 1.8.11