tight-engine 0.0.1 → 0.0.2
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/Gemfile +1 -0
- data/lib/tight-engine.rb +23 -0
- data/lib/tight-engine/defer.rb +30 -0
- data/lib/tight-engine/init.rb +120 -0
- data/lib/tight-engine/locale.rb +40 -0
- data/lib/tight-engine/render.rb +193 -0
- data/lib/tight-engine/template.rb +60 -0
- data/lib/tight-engine/url.rb +27 -0
- data/lib/tight-engine/utils.rb +62 -0
- data/lib/tight-engine/version.rb +5 -0
- data/tight-engine.gemspec +2 -2
- metadata +13 -19
- data/lib/tight-auth.rb +0 -10
- data/lib/tight-auth/access.rb +0 -148
- data/lib/tight-auth/login.rb +0 -138
- data/lib/tight-auth/login/controller.rb +0 -20
- data/lib/tight-auth/login/layout.slim +0 -10
- data/lib/tight-auth/login/new.slim +0 -37
- data/lib/tight-auth/permissions.rb +0 -180
- data/lib/tight/version.rb +0 -3
- data/test/auth_helper.rb +0 -83
- data/test/test_padrino_access.rb +0 -124
- data/test/test_padrino_auth.rb +0 -38
- data/test/test_padrino_login.rb +0 -76
data/test/test_padrino_auth.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require File.expand_path('../auth_helper', __FILE__)
|
2
|
-
|
3
|
-
Account = Character
|
4
|
-
|
5
|
-
describe "Tight::Auth" do
|
6
|
-
before do
|
7
|
-
mock_app do
|
8
|
-
enable :sessions
|
9
|
-
register Tight::Login
|
10
|
-
register Tight::Access
|
11
|
-
get(:robot_area){ 'robot_area' }
|
12
|
-
set_access :robots, :allow => :robot_area
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should login and access play nicely together' do
|
17
|
-
get '/robot_area'
|
18
|
-
assert_equal 302, status
|
19
|
-
|
20
|
-
post '/login', :email => :bender, :password => 'BBR'
|
21
|
-
get '/robot_area'
|
22
|
-
assert_equal 200, status
|
23
|
-
|
24
|
-
post '/login', :email => :leela, :password => 'TL'
|
25
|
-
get '/robot_area'
|
26
|
-
assert_equal 403, status
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should whine if the order is wrong' do
|
30
|
-
out, err = capture_io do
|
31
|
-
mock_app do
|
32
|
-
register Tight::Access
|
33
|
-
register Tight::Login
|
34
|
-
end
|
35
|
-
end
|
36
|
-
assert_match /must be registered before/, err
|
37
|
-
end
|
38
|
-
end
|
data/test/test_padrino_login.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
require File.expand_path('../auth_helper', __FILE__)
|
2
|
-
require 'padrino-helpers'
|
3
|
-
|
4
|
-
describe "Tight::Access" do
|
5
|
-
before do
|
6
|
-
mock_app do
|
7
|
-
set :credentials_accessor, :visitor
|
8
|
-
set :login_model, :character
|
9
|
-
enable :sessions
|
10
|
-
register Tight::Login
|
11
|
-
get(:index){ 'index' }
|
12
|
-
get(:restricted){ 'secret' }
|
13
|
-
helpers do
|
14
|
-
def authorized?
|
15
|
-
return !['/restricted'].include?(request.env['PATH_INFO']) unless visitor
|
16
|
-
case
|
17
|
-
when visitor.id == :bender
|
18
|
-
true
|
19
|
-
else
|
20
|
-
false
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
Character.all.each do |user|
|
26
|
-
instance_variable_set :"@#{user.id}", user
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should pass unrestricted area' do
|
31
|
-
get '/'
|
32
|
-
assert_equal 200, status
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should be redirected from restricted area to login page' do
|
36
|
-
get '/restricted'
|
37
|
-
assert_equal 302, status
|
38
|
-
get response.location
|
39
|
-
assert_equal 200, status
|
40
|
-
assert_match /<form .*<input .*/, body
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should not be able to authenticate with wrong password' do
|
44
|
-
post '/login', :email => :bender, :password => '123'
|
45
|
-
assert_equal 200, status
|
46
|
-
assert_match 'Wrong password', body
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should be able to authenticate with email and password' do
|
50
|
-
post '/login', :email => :bender, :password => 'BBR'
|
51
|
-
assert_equal 302, status
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should be redirected back' do
|
55
|
-
get '/restricted'
|
56
|
-
post response.location, :email => :bender, :password => 'BBR'
|
57
|
-
assert_match /\/restricted$/, response.location
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'should be redirected to root if no location was saved' do
|
61
|
-
post '/login', :email => :bender, :password => 'BBR'
|
62
|
-
assert_match /\/$/, response.location
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should be allowed in restricted area after logging in' do
|
66
|
-
post '/login', :email => :bender, :password => 'BBR'
|
67
|
-
get '/restricted'
|
68
|
-
assert_equal 'secret', body
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'should not be allowed in restricted area after logging in an account lacking privileges' do
|
72
|
-
post '/login', :email => :leela, :password => 'TL'
|
73
|
-
get '/restricted'
|
74
|
-
assert_equal 403, status
|
75
|
-
end
|
76
|
-
end
|