aker-confident 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+ require 'active_record'
3
+
4
+ describe Aker::Confident::Configuration do
5
+
6
+
7
+ def verify(options)
8
+ lambda{ Aker::Confident::Configuration.new(options).verify! }
9
+ end
10
+ before(:each) do
11
+ @valid_options = {
12
+ :conf_model => Agreement,
13
+ :conf_file => __FILE__,
14
+ :conf_host_hook => Proc.new{ |env| 4}
15
+ }
16
+ end
17
+
18
+ describe "verify!" do
19
+ it "should check that agreement responds to signed?" do
20
+ @valid_options[:conf_model] = NoSignedAgreement
21
+ verify(@valid_options).should raise_error Aker::Confident::ConfigurationError
22
+ end
23
+ it "should check that agreement responds to sign" do
24
+ @valid_options[:conf_model] = NoSignAgreement
25
+ verify(@valid_options).should raise_error Aker::Confident::ConfigurationError
26
+ end
27
+
28
+ it "checks that hook responds to call" do
29
+ @valid_options[:conf_host_hook] = 4
30
+ verify(@valid_options).should raise_error Aker::Confident::ConfigurationError
31
+ end
32
+
33
+ it "is valid without hooks" do
34
+ @valid_options.delete :conf_host_hook
35
+ verify(@valid_options).should_not raise_error Aker::Confident::ConfigurationError
36
+ end
37
+
38
+ it "raises an error if no conf model is nil or blank" do
39
+ @valid_options[:conf_model] = nil
40
+ verify(@valid_options).should raise_error Aker::Confident::ConfigurationError
41
+ @valid_options[:conf_model] = ""
42
+ verify(@valid_options).should raise_error Aker::Confident::ConfigurationError
43
+ end
44
+
45
+ it "raises an error if file at conf_file path is not present" do
46
+ @valid_options[:conf_file] = "junkfilethatcouldntpossiblyexistifitdiditwouldbeahugecoincidence"
47
+ verify(@valid_options).should raise_error Aker::Confident::ConfigurationError
48
+ end
49
+
50
+ it "raises an error if no conf_file key in options" do
51
+ verify({:conf_model => Agreement}).should raise_error Aker::Confident::ConfigurationError
52
+ end
53
+
54
+ it "raises an error if conf_file is nil or blank" do
55
+ @valid_options[:conf_file] = nil
56
+ verify(@valid_options).should raise_error Aker::Confident::ConfigurationError
57
+ @valid_options[:conf_file] = ""
58
+ verify(@valid_options).should raise_error Aker::Confident::ConfigurationError
59
+ end
60
+ end
61
+
62
+ it 'works with a block of config options' do
63
+ stub_proc = Proc.new{ |env| 4 }
64
+ conf = Aker::Confident::Configuration.new.define do
65
+ conf_model Agreement
66
+ conf_file __FILE__
67
+ conf_host_hook stub_proc
68
+ end
69
+ conf.model.should == Agreement
70
+ conf.agreement.should == File.read(__FILE__)
71
+ conf.pass_through_hooks.should include stub_proc
72
+ end
73
+
74
+ it "accepts a hash of config options to set configuration" do
75
+ config = Aker::Confident::Configuration.new(@valid_options)
76
+ config.should_not be_nil
77
+ end
78
+
79
+ it "reads conf agreement from supplied file path" do
80
+ config = Aker::Confident::Configuration.new(@valid_options)
81
+ config.agreement.should == File.read(__FILE__)
82
+ end
83
+
84
+ it "sets conf model based on options" do
85
+ @valid_options[:conf_model] = Agreement
86
+ config = Aker::Confident::Configuration.new(@valid_options)
87
+ config.model.should == Agreement
88
+ end
89
+
90
+ it "returns constantized model if given string" do
91
+ @valid_options[:conf_model] = "Agreement"
92
+ config = Aker::Confident::Configuration.new(@valid_options)
93
+ config.model.should == Agreement
94
+ end
95
+
96
+
97
+ it "takes a root_url configuration option" do
98
+ @valid_options[:root_url] = "http://test.host"
99
+ config = Aker::Confident::Configuration.new(@valid_options)
100
+ config.root_url.should == "http://test.host"
101
+ end
102
+
103
+ end
@@ -0,0 +1,56 @@
1
+ #this file will be run within the context of the testbed project
2
+ require File.join(File.dirname(__FILE__), '../..', 'testbed', 'spec', 'spec_helper')
3
+
4
+ describe "Rails integration" do
5
+
6
+ context "when conf agreement is signed" do
7
+ before(:each) do
8
+ Signature.create!(:username => 'wakibbe')
9
+ end
10
+ it "should not redirect to conf_agreement", :type => :integration do
11
+ visit '/labs'
12
+ login
13
+ current_path.should =~ /labs/
14
+ visit '/logout'
15
+ end
16
+ end
17
+
18
+ context "when conf agreement is unsigned" do
19
+ before(:each) do
20
+ Signature.destroy_all
21
+ end
22
+ it "should display the conf_agreement", :type => :integration do
23
+ visit '/logout'
24
+ visit '/login'
25
+ visit '/labs'
26
+ login
27
+ page.should have_content("Don't share this, dirtbag")
28
+ end
29
+
30
+ it "should let me sign the conf agreement and redirect to original target", :type => :integration do
31
+ visit '/logout'
32
+ visit '/labs'
33
+ login
34
+ click_on 'I agree and accept the terms'
35
+ current_path.should =~ /labs/
36
+ page.should have_content("Lab")
37
+ end
38
+
39
+ it "should show me the conf agreement", :type => :integration do
40
+ visit '/logout'
41
+ visit '/labs'
42
+ login
43
+ page.should have_content("Don't share this, dirtbag")
44
+ visit '/logout'
45
+ end
46
+ end
47
+
48
+
49
+ end
50
+
51
+
52
+ def login
53
+ fill_in "username", :with => "wakibbe"
54
+ fill_in "password", :with => "password"
55
+ click_on "Log in"
56
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ describe Aker::Confident::Signer do
3
+ before(:each) do
4
+ @valid_options = {:conf_model => Agreement,
5
+ :conf_file => __FILE__}
6
+ Aker::Confident.configure(@valid_options)
7
+ @valid_user = Aker::User.new("foo")
8
+ end
9
+ it "should delegate signed? to conf_model" do
10
+ Aker::Confident.configuration.model.should_receive(:signed?).with(@valid_user)
11
+ Aker::Confident.signed?(@valid_user)
12
+ end
13
+ it "should delegate sign to conf_model" do
14
+ Aker::Confident.configuration.model.should_receive(:sign).with(@valid_user)
15
+ Aker::Confident.sign(@valid_user)
16
+ end
17
+ it "should require a bcsec user as argument to signed?" do
18
+ lambda {Aker::Confident.signed?(4)}.should raise_error ArgumentError
19
+ end
20
+ it "should require a bcsec user as argument to sign" do
21
+ lambda {Aker::Confident.sign(4)}.should raise_error ArgumentError
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ require 'lib/aker-confident'
2
+ require 'rack/test'
3
+ require 'aker/rails'
4
+
5
+
6
+ include Aker::Rails::Test::Helpers
7
+ def configure_conf
8
+ file_path = File.join(File.dirname(__FILE__), "assets/test_agreement.txt")
9
+ options = {
10
+ :conf_model => Agreement,
11
+ :conf_file => file_path,
12
+ }
13
+ Aker::Confident.configure(options)
14
+ end
15
+
16
+ class Agreement
17
+ def self.signed?(user)
18
+ end
19
+ def self.sign(user)
20
+ end
21
+ end
22
+
23
+ class NoSignAgreement
24
+ def self.signed?(user)
25
+ end
26
+ end
27
+
28
+ class NoSignedAgreement
29
+ def self.sign(user)
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,262 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aker-confident
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
11
+ platform: ruby
12
+ authors:
13
+ - William Dix
14
+ - Peter Nyberg
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2012-02-14 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: aker
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: aker-rails
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: sinatra
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: haml
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :runtime
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: schema_qualified_tables
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ type: :runtime
90
+ version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
92
+ name: rails
93
+ prerelease: false
94
+ requirement: &id006 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - "="
98
+ - !ruby/object:Gem::Version
99
+ hash: 17
100
+ segments:
101
+ - 3
102
+ - 0
103
+ - 11
104
+ version: 3.0.11
105
+ type: :development
106
+ version_requirements: *id006
107
+ - !ruby/object:Gem::Dependency
108
+ name: rspec
109
+ prerelease: false
110
+ requirement: &id007 !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ type: :development
120
+ version_requirements: *id007
121
+ - !ruby/object:Gem::Dependency
122
+ name: rspec-rails
123
+ prerelease: false
124
+ requirement: &id008 !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ hash: 3
130
+ segments:
131
+ - 0
132
+ version: "0"
133
+ type: :development
134
+ version_requirements: *id008
135
+ - !ruby/object:Gem::Dependency
136
+ name: capybara
137
+ prerelease: false
138
+ requirement: &id009 !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - "="
142
+ - !ruby/object:Gem::Version
143
+ hash: 29
144
+ segments:
145
+ - 0
146
+ - 3
147
+ - 7
148
+ version: 0.3.7
149
+ type: :development
150
+ version_requirements: *id009
151
+ - !ruby/object:Gem::Dependency
152
+ name: rack-test
153
+ prerelease: false
154
+ requirement: &id010 !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ hash: 3
160
+ segments:
161
+ - 0
162
+ version: "0"
163
+ type: :development
164
+ version_requirements: *id010
165
+ - !ruby/object:Gem::Dependency
166
+ name: sqlite3
167
+ prerelease: false
168
+ requirement: &id011 !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ hash: 3
174
+ segments:
175
+ - 0
176
+ version: "0"
177
+ type: :development
178
+ version_requirements: *id011
179
+ description: ialdskj
180
+ email:
181
+ - wjdix@northwestern.edu
182
+ executables: []
183
+
184
+ extensions: []
185
+
186
+ extra_rdoc_files: []
187
+
188
+ files:
189
+ - .gitignore
190
+ - .rbenv-version
191
+ - Gemfile
192
+ - Gemfile.lock
193
+ - LICENSE
194
+ - README
195
+ - Rakefile
196
+ - aker-confident.gemspec
197
+ - assets/templates/agreement.haml
198
+ - init_testbed.rakefile
199
+ - lib/aker-confident.rb
200
+ - lib/aker/confident.rb
201
+ - lib/aker/confident/aker_slice.rb
202
+ - lib/aker/confident/aker_user_ext.rb
203
+ - lib/aker/confident/configuration.rb
204
+ - lib/aker/confident/rack.rb
205
+ - lib/aker/confident/signer.rb
206
+ - lib/aker/confident/sinatra.rb
207
+ - lib/aker/confident/version.rb
208
+ - spec/aker_user_spec.rb
209
+ - spec/assets/test-users.yml
210
+ - spec/assets/test_agreement.txt
211
+ - spec/conf_rack_spec.rb
212
+ - spec/conf_sinatra_spec.rb
213
+ - spec/confident_spec.rb
214
+ - spec/configuration_spec.rb
215
+ - spec/integration/rails_integration_spec.rb
216
+ - spec/signer_spec.rb
217
+ - spec/spec_helper.rb
218
+ homepage: ""
219
+ licenses: []
220
+
221
+ post_install_message:
222
+ rdoc_options: []
223
+
224
+ require_paths:
225
+ - lib
226
+ required_ruby_version: !ruby/object:Gem::Requirement
227
+ none: false
228
+ requirements:
229
+ - - ">="
230
+ - !ruby/object:Gem::Version
231
+ hash: 3
232
+ segments:
233
+ - 0
234
+ version: "0"
235
+ required_rubygems_version: !ruby/object:Gem::Requirement
236
+ none: false
237
+ requirements:
238
+ - - ">="
239
+ - !ruby/object:Gem::Version
240
+ hash: 3
241
+ segments:
242
+ - 0
243
+ version: "0"
244
+ requirements: []
245
+
246
+ rubyforge_project: aker-confident
247
+ rubygems_version: 1.8.11
248
+ signing_key:
249
+ specification_version: 3
250
+ summary: Confidentiality gem for Aker
251
+ test_files:
252
+ - spec/aker_user_spec.rb
253
+ - spec/assets/test-users.yml
254
+ - spec/assets/test_agreement.txt
255
+ - spec/conf_rack_spec.rb
256
+ - spec/conf_sinatra_spec.rb
257
+ - spec/confident_spec.rb
258
+ - spec/configuration_spec.rb
259
+ - spec/integration/rails_integration_spec.rb
260
+ - spec/signer_spec.rb
261
+ - spec/spec_helper.rb
262
+ has_rdoc: