opensesame 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. data/README.md +40 -0
  2. data/app/controllers/open_sesame/application_controller.rb +2 -2
  3. data/app/controllers/open_sesame/sessions_controller.rb +26 -2
  4. data/app/helpers/open_sesame/application_helper.rb +0 -5
  5. data/app/views/open_sesame/sessions/new.html.erb +9 -5
  6. data/lib/open_sesame/configuration.rb +34 -2
  7. data/lib/open_sesame/engine.rb +21 -5
  8. data/lib/open_sesame/failure_app.rb +14 -0
  9. data/lib/open_sesame/version.rb +1 -1
  10. data/lib/open_sesame.rb +3 -1
  11. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  12. data/spec/dummy/app/controllers/home_controller.rb +4 -0
  13. data/spec/dummy/app/views/home/index.html.erb +1 -0
  14. data/spec/dummy/config/application.rb +0 -1
  15. data/spec/dummy/config/initializers/opensesame.rb +2 -0
  16. data/spec/dummy/config/routes.rb +2 -1
  17. data/spec/dummy/db/development.sqlite3 +0 -0
  18. data/spec/dummy/db/schema.rb +16 -0
  19. data/spec/dummy/log/development.log +6 -0
  20. data/spec/dummy/log/test.log +1477 -10
  21. data/spec/dummy/tmp/capybara/capybara-201205020845084431324775.html +14 -0
  22. data/spec/dummy/tmp/capybara/capybara-201205020845417136358435.html +14 -0
  23. data/spec/dummy/tmp/capybara/capybara-201205020846032430049397.html +14 -0
  24. data/spec/dummy/tmp/capybara/capybara-201205020848165144257335.html +26 -0
  25. data/spec/dummy/tmp/capybara/capybara-201205020849371072293414.html +26 -0
  26. data/spec/dummy/tmp/capybara/capybara-201205020851069360249571.html +26 -0
  27. data/spec/lib/open_sesame/configuration_spec.rb +61 -0
  28. data/spec/lib/open_sesame/sessions_spec.rb +33 -0
  29. data/spec/spec_helper.rb +7 -1
  30. metadata +63 -16
  31. data/README.rdoc +0 -3
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>Dummy</title>
6
+ <link href="/assets/application.css" media="all" rel="stylesheet" type="text/css">
7
+ <script src="/assets/application.js" type="text/javascript"></script>
8
+ </head>
9
+ <body>
10
+
11
+ <h1>Welcome Home!</h1>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>Dummy</title>
6
+ <link href="/assets/application.css" media="all" rel="stylesheet" type="text/css">
7
+ <script src="/assets/application.js" type="text/javascript"></script>
8
+ </head>
9
+ <body>
10
+
11
+ <h1>Welcome Home!</h1>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>Dummy</title>
6
+ <link href="/assets/application.css" media="all" rel="stylesheet" type="text/css">
7
+ <script src="/assets/application.js" type="text/javascript"></script>
8
+ </head>
9
+ <body>
10
+
11
+ <h1>Welcome Home!</h1>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>OpenSesame</title>
6
+ <link href="/assets/open_sesame/application.css" media="all" rel="stylesheet" type="text/css">
7
+ <script src="/assets/open_sesame/application.js" type="text/javascript"></script>
8
+ </head>
9
+ <body>
10
+
11
+ <div class="container">
12
+ <div class="inner-container">
13
+ <div id="opensesame-session">
14
+ <header class="content-header"><h1>Login</h1>
15
+ </header><p>Welcome! You have arrived at a Challengepost application requiring additional credentials. To continue, please log in via:</p>
16
+ <div class="table">
17
+ <div class="table-cell align-middle">
18
+ <a href="/welcome/auth/github" class="btn btn-large"><img alt="Github_64" src="/assets/open_sesame/github_64.png"><br><span>github</span></a>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ </div>
24
+
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>OpenSesame</title>
6
+ <link href="/assets/open_sesame/application.css" media="all" rel="stylesheet" type="text/css">
7
+ <script src="/assets/open_sesame/application.js" type="text/javascript"></script>
8
+ </head>
9
+ <body>
10
+
11
+ <div class="container">
12
+ <div class="inner-container">
13
+ <div id="opensesame-session">
14
+ <header class="content-header"><h1>Login</h1>
15
+ </header><p>Welcome! You have arrived at a Challengepost application requiring additional credentials. To continue, please log in via:</p>
16
+ <div class="table">
17
+ <div class="table-cell align-middle">
18
+ <a href="/welcome/auth/github" class="btn btn-large"><img alt="Github_64" src="/assets/open_sesame/github_64.png"><br><span>github</span></a>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ </div>
24
+
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <title>OpenSesame</title>
6
+ <link href="/assets/open_sesame/application.css" media="all" rel="stylesheet" type="text/css">
7
+ <script src="/assets/open_sesame/application.js" type="text/javascript"></script>
8
+ </head>
9
+ <body>
10
+
11
+ <div class="container">
12
+ <div class="inner-container">
13
+ <div id="opensesame-session">
14
+ <header class="content-header"><h1>Login</h1>
15
+ </header><p>Welcome! You have arrived at a Challengepost application requiring additional credentials. To continue, please log in via:</p>
16
+ <div class="table">
17
+ <div class="table-cell align-middle">
18
+ <a href="/welcome/auth/github" class="btn btn-large"><img alt="Github_64" src="/assets/open_sesame/github_64.png"><br><span>github</span></a>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ </div>
24
+
25
+ </body>
26
+ </html>
@@ -21,6 +21,11 @@ describe OpenSesame::Configuration do
21
21
  configuration.mount_prefix.should == "/foobar"
22
22
  end
23
23
 
24
+ it "auto_access sets provider to attempt auto login" do
25
+ configuration.auto_login "github"
26
+ configuration.auto_access_provider.should == "github"
27
+ end
28
+
24
29
  describe "valid?" do
25
30
  it "false when values not set" do
26
31
  configuration.organization "challengepost"
@@ -55,4 +60,60 @@ describe OpenSesame::Configuration do
55
60
  configuration.validate!.should be_true
56
61
  end
57
62
  end
63
+
64
+ describe "enabled?" do
65
+ let(:conditional) { mock('conditional', :true? => true) }
66
+
67
+ it { configuration.enabled?.should be_false }
68
+
69
+ it "true if enabled!" do
70
+ configuration.enable!
71
+ configuration.should be_enabled
72
+ end
73
+
74
+ it "false if disabled" do
75
+ configuration.disable!
76
+ configuration.should_not be_enabled
77
+ end
78
+
79
+ it "false if enable_if clause is false" do
80
+ conditional.stub!(:true?).and_return(false)
81
+ configuration.enable_if conditional.true?
82
+ configuration.should_not be_enabled
83
+ end
84
+
85
+ it "true if enable_if clause is true" do
86
+ conditional.stub!(:true?).and_return(true)
87
+ configuration.enable_if conditional.true?
88
+ configuration.should be_enabled
89
+ end
90
+
91
+ it "true if enable_if clause is false but then enabled!" do
92
+ conditional.stub!(:true?).and_return(false)
93
+ configuration.enable_if conditional.true?
94
+ configuration.enable!
95
+ configuration.should be_enabled
96
+ end
97
+
98
+ it "false if enable_if clause is true but then disabled!" do
99
+ conditional.stub!(:true?).and_return(true)
100
+ configuration.enable_if conditional.true?
101
+ configuration.disable!
102
+ configuration.should_not be_enabled
103
+ end
104
+
105
+ it "false if enabled! then supplied with enable_if clause that is false" do
106
+ configuration.enable!
107
+ conditional.stub!(:true?).and_return(false)
108
+ configuration.enable_if conditional.true?
109
+ configuration.should_not be_enabled
110
+ end
111
+
112
+ it "true if disabled! then supplied with enable_if clause that is true" do
113
+ configuration.disable!
114
+ conditional.stub!(:true?).and_return(true)
115
+ configuration.enable_if conditional.true?
116
+ configuration.should be_enabled
117
+ end
118
+ end
58
119
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Session", :type => :request do
4
+
5
+ context "successful login" do
6
+ before { setup_for_github_login } # provided by opensesame-github/capybara
7
+
8
+ it "enforces opensesame login" do
9
+ visit root_path
10
+ within("#opensesame-session") do
11
+ page.should have_content("Login")
12
+ click_link "github"
13
+ end
14
+
15
+ page.should have_content "Welcome Home"
16
+ end
17
+
18
+ it "allows auto login" do
19
+ OpenSesame.stub!(:auto_access_provider).and_return('github')
20
+ visit root_path
21
+ page.should have_content "Welcome Home"
22
+ end
23
+
24
+ end
25
+
26
+ it "tries auto login and ends up on opensesame page after failure" do
27
+ OpenSesame.stub!(:auto_access_provider).and_return('github')
28
+ visit root_path
29
+ page.should have_content "Login"
30
+ page.should_not have_content "Welcome Home"
31
+ end
32
+
33
+ end
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,8 @@ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
4
 
5
5
  require 'rspec/rails'
6
6
  require 'rspec/autorun'
7
+ require 'capybara/rspec'
8
+ require 'opensesame-github/capybara'
7
9
 
8
10
  ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
9
11
 
@@ -11,7 +13,11 @@ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
11
13
  # in spec/support/ and its subdirectories.
12
14
  Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
13
15
 
16
+ OmniAuth.config.test_mode = true
17
+
14
18
  RSpec.configure do |config|
15
19
  config.use_transactional_fixtures = true
16
20
  config.infer_base_class_for_anonymous_controllers = false
17
- end
21
+
22
+ config.include OpenSesame::Github::Capybara, :type => :request
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opensesame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-26 00:00:00.000000000Z
12
+ date: 2012-05-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70296434233900 !ruby/object:Gem::Requirement
16
+ requirement: &70284434573420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70296434233900
24
+ version_requirements: *70284434573420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bootstrap-sass
27
- requirement: &70296434233400 !ruby/object:Gem::Requirement
27
+ requirement: &70284434572500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.0.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70296434233400
35
+ version_requirements: *70284434572500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: opensesame-github
38
- requirement: &70296434233020 !ruby/object:Gem::Requirement
38
+ requirement: &70284434571740 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70296434233020
46
+ version_requirements: *70284434571740
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sqlite3
49
- requirement: &70296434232560 !ruby/object:Gem::Requirement
49
+ requirement: &70284434569740 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70296434232560
57
+ version_requirements: *70284434569740
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec-rails
60
- requirement: &70296434232060 !ruby/object:Gem::Requirement
60
+ requirement: &70284434568960 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,29 @@ dependencies:
65
65
  version: 2.9.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70296434232060
68
+ version_requirements: *70284434568960
69
+ - !ruby/object:Gem::Dependency
70
+ name: capybara
71
+ requirement: &70284434567980 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70284434567980
80
+ - !ruby/object:Gem::Dependency
81
+ name: launchy
82
+ requirement: &70284434566380 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70284434566380
69
91
  description: Rails engine for authenticating internal applications and private-access
70
92
  products
71
93
  email:
@@ -89,6 +111,7 @@ files:
89
111
  - lib/open_sesame/configuration.rb
90
112
  - lib/open_sesame/controller_helper.rb
91
113
  - lib/open_sesame/engine.rb
114
+ - lib/open_sesame/failure_app.rb
92
115
  - lib/open_sesame/version.rb
93
116
  - lib/open_sesame/view_helper.rb
94
117
  - lib/open_sesame.rb
@@ -96,11 +119,13 @@ files:
96
119
  - lib/tasks/opensesame_tasks.rake
97
120
  - MIT-LICENSE
98
121
  - Rakefile
99
- - README.rdoc
122
+ - README.md
100
123
  - spec/dummy/app/assets/javascripts/application.js
101
124
  - spec/dummy/app/assets/stylesheets/application.css
102
125
  - spec/dummy/app/controllers/application_controller.rb
126
+ - spec/dummy/app/controllers/home_controller.rb
103
127
  - spec/dummy/app/helpers/application_helper.rb
128
+ - spec/dummy/app/views/home/index.html.erb
104
129
  - spec/dummy/app/views/layouts/application.html.erb
105
130
  - spec/dummy/config/application.rb
106
131
  - spec/dummy/config/boot.rb
@@ -119,7 +144,10 @@ files:
119
144
  - spec/dummy/config/locales/en.yml
120
145
  - spec/dummy/config/routes.rb
121
146
  - spec/dummy/config.ru
147
+ - spec/dummy/db/development.sqlite3
148
+ - spec/dummy/db/schema.rb
122
149
  - spec/dummy/db/test.sqlite3
150
+ - spec/dummy/log/development.log
123
151
  - spec/dummy/log/test.log
124
152
  - spec/dummy/public/404.html
125
153
  - spec/dummy/public/422.html
@@ -128,10 +156,17 @@ files:
128
156
  - spec/dummy/Rakefile
129
157
  - spec/dummy/README.rdoc
130
158
  - spec/dummy/script/rails
159
+ - spec/dummy/tmp/capybara/capybara-201205020845084431324775.html
160
+ - spec/dummy/tmp/capybara/capybara-201205020845417136358435.html
161
+ - spec/dummy/tmp/capybara/capybara-201205020846032430049397.html
162
+ - spec/dummy/tmp/capybara/capybara-201205020848165144257335.html
163
+ - spec/dummy/tmp/capybara/capybara-201205020849371072293414.html
164
+ - spec/dummy/tmp/capybara/capybara-201205020851069360249571.html
131
165
  - spec/lib/open_sesame/configuration_spec.rb
166
+ - spec/lib/open_sesame/sessions_spec.rb
132
167
  - spec/lib/open_sesame_spec.rb
133
168
  - spec/spec_helper.rb
134
- homepage: https://github.com/challengepost/gardenwall-challengepost
169
+ homepage: https://github.com/rossta/opensesame
135
170
  licenses: []
136
171
  post_install_message:
137
172
  rdoc_options: []
@@ -145,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
180
  version: '0'
146
181
  segments:
147
182
  - 0
148
- hash: 595493029112045078
183
+ hash: -2528380639608533410
149
184
  required_rubygems_version: !ruby/object:Gem::Requirement
150
185
  none: false
151
186
  requirements:
@@ -154,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
189
  version: '0'
155
190
  segments:
156
191
  - 0
157
- hash: 595493029112045078
192
+ hash: -2528380639608533410
158
193
  requirements: []
159
194
  rubyforge_project:
160
195
  rubygems_version: 1.8.10
@@ -166,7 +201,9 @@ test_files:
166
201
  - spec/dummy/app/assets/javascripts/application.js
167
202
  - spec/dummy/app/assets/stylesheets/application.css
168
203
  - spec/dummy/app/controllers/application_controller.rb
204
+ - spec/dummy/app/controllers/home_controller.rb
169
205
  - spec/dummy/app/helpers/application_helper.rb
206
+ - spec/dummy/app/views/home/index.html.erb
170
207
  - spec/dummy/app/views/layouts/application.html.erb
171
208
  - spec/dummy/config/application.rb
172
209
  - spec/dummy/config/boot.rb
@@ -185,7 +222,10 @@ test_files:
185
222
  - spec/dummy/config/locales/en.yml
186
223
  - spec/dummy/config/routes.rb
187
224
  - spec/dummy/config.ru
225
+ - spec/dummy/db/development.sqlite3
226
+ - spec/dummy/db/schema.rb
188
227
  - spec/dummy/db/test.sqlite3
228
+ - spec/dummy/log/development.log
189
229
  - spec/dummy/log/test.log
190
230
  - spec/dummy/public/404.html
191
231
  - spec/dummy/public/422.html
@@ -194,6 +234,13 @@ test_files:
194
234
  - spec/dummy/Rakefile
195
235
  - spec/dummy/README.rdoc
196
236
  - spec/dummy/script/rails
237
+ - spec/dummy/tmp/capybara/capybara-201205020845084431324775.html
238
+ - spec/dummy/tmp/capybara/capybara-201205020845417136358435.html
239
+ - spec/dummy/tmp/capybara/capybara-201205020846032430049397.html
240
+ - spec/dummy/tmp/capybara/capybara-201205020848165144257335.html
241
+ - spec/dummy/tmp/capybara/capybara-201205020849371072293414.html
242
+ - spec/dummy/tmp/capybara/capybara-201205020851069360249571.html
197
243
  - spec/lib/open_sesame/configuration_spec.rb
244
+ - spec/lib/open_sesame/sessions_spec.rb
198
245
  - spec/lib/open_sesame_spec.rb
199
246
  - spec/spec_helper.rb
data/README.rdoc DELETED
@@ -1,3 +0,0 @@
1
- = OpenSesame
2
-
3
- This project rocks and uses MIT-LICENSE.