openstax_accounts 7.13.0 → 8.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/openstax/accounts/application_controller.rb +1 -1
- data/app/controllers/openstax/accounts/dev/accounts_controller.rb +1 -1
- data/app/controllers/openstax/accounts/dev/base_controller.rb +1 -1
- data/app/controllers/openstax/accounts/sessions_controller.rb +7 -8
- data/app/handlers/openstax/accounts/sessions_callback.rb +17 -37
- data/app/models/openstax/accounts/account.rb +33 -1
- data/app/models/openstax/accounts/group.rb +12 -8
- data/app/models/openstax/accounts/group_nesting.rb +8 -7
- data/app/representers/openstax/accounts/api/v1/unclaimed_account_representer.rb +1 -7
- data/app/routines/openstax/accounts/find_or_create_account.rb +9 -9
- data/app/routines/openstax/accounts/find_or_create_from_sso.rb +23 -0
- data/app/routines/openstax/accounts/sync_accounts.rb +1 -6
- data/config/routes.rb +11 -11
- data/db/migrate/0_create_openstax_accounts_accounts.rb +1 -1
- data/db/migrate/10_assign_missing_uuids_for_local_accounts.rb +2 -2
- data/db/migrate/11_add_support_identifier_to_accounts_accounts.rb +1 -1
- data/db/migrate/12_add_is_test_to_accounts_accounts.rb +1 -1
- data/db/migrate/13_add_school_type_to_accounts_accounts.rb +1 -1
- data/db/migrate/1_create_openstax_accounts_groups.rb +1 -1
- data/db/migrate/2_create_openstax_accounts_group_members.rb +1 -1
- data/db/migrate/3_create_openstax_accounts_group_owners.rb +1 -1
- data/db/migrate/4_create_openstax_accounts_group_nestings.rb +1 -1
- data/db/migrate/5_add_faculty_status_to_accounts_accounts.rb +1 -1
- data/db/migrate/6_add_salesforce_contact_id_to_accounts_accounts.rb +1 -1
- data/db/migrate/7_change_accounts_openstax_uid_to_be_nullable.rb +1 -1
- data/db/migrate/8_change_accounts_username_to_be_nullable.rb +1 -1
- data/db/migrate/9_add_uuid_and_role_to_accounts_accounts.rb +1 -1
- data/lib/omniauth/strategies/openstax.rb +6 -23
- data/lib/openstax/accounts/configuration.rb +16 -0
- data/lib/openstax/accounts/current_user_manager.rb +20 -0
- data/lib/openstax/accounts/has_many_through_groups/active_record/base.rb +5 -5
- data/lib/openstax/accounts/sso.rb +61 -0
- data/lib/openstax/accounts/version.rb +1 -1
- data/lib/openstax_accounts.rb +6 -7
- data/lib/tasks/sync.rake +3 -3
- data/spec/factories/openstax_accounts_account.rb +1 -1
- data/spec/factories/openstax_accounts_group.rb +3 -3
- data/spec/factories/openstax_accounts_group_member.rb +1 -1
- data/spec/factories/openstax_accounts_group_nesting.rb +1 -1
- data/spec/factories/openstax_accounts_group_owner.rb +1 -1
- metadata +34 -212
- data/Rakefile +0 -22
- data/spec/cassettes/OpenStax_Accounts_FindOrCreateAccount/can_create_users.yml +0 -303
- data/spec/controllers/openstax/accounts/dev/accounts_controller_spec.rb +0 -27
- data/spec/controllers/openstax/accounts/forwards_params_spec.rb +0 -75
- data/spec/controllers/openstax/accounts/sessions_controller_spec.rb +0 -71
- data/spec/controllers/openstax/accounts/uses_this_engine_controller_spec.rb +0 -22
- data/spec/dummy/README.md +0 -1
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/access_policies/account_access_policy.rb +0 -11
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/controllers/api/application_groups_controller.rb +0 -11
- data/spec/dummy/app/controllers/api/application_users_controller.rb +0 -15
- data/spec/dummy/app/controllers/api/dummy_controller.rb +0 -12
- data/spec/dummy/app/controllers/api/group_members_controller.rb +0 -11
- data/spec/dummy/app/controllers/api/group_nestings_controller.rb +0 -11
- data/spec/dummy/app/controllers/api/group_owners_controller.rb +0 -11
- data/spec/dummy/app/controllers/api/groups_controller.rb +0 -15
- data/spec/dummy/app/controllers/api/users_controller.rb +0 -15
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/controllers/oauth_controller.rb +0 -10
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/models/anonymous_user.rb +0 -48
- data/spec/dummy/app/models/ownership.rb +0 -7
- data/spec/dummy/app/models/user.rb +0 -29
- data/spec/dummy/config.ru +0 -5
- data/spec/dummy/config/application.rb +0 -23
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -15
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -40
- data/spec/dummy/config/environments/production.rb +0 -82
- data/spec/dummy/config/environments/test.rb +0 -39
- data/spec/dummy/config/initializers/access_policies.rb +0 -1
- data/spec/dummy/config/initializers/assets.rb +0 -8
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/doorkeeper.rb +0 -75
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/openstax_accounts.rb +0 -14
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -45
- data/spec/dummy/config/secrets.yml +0 -8
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/1000_create_users.rb +0 -11
- data/spec/dummy/db/migrate/1001_create_ownerships.rb +0 -11
- data/spec/dummy/db/schema.rb +0 -113
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -5137
- data/spec/dummy/log/test.log +0 -162651
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/handlers/openstax/accounts/accounts_search_spec.rb +0 -63
- data/spec/handlers/openstax/accounts/dev/accounts_search_spec.rb +0 -55
- data/spec/handlers/openstax/accounts/sessions_callback_spec.rb +0 -119
- data/spec/lib/openstax/accounts/api_spec.rb +0 -212
- data/spec/lib/openstax/accounts/configuration_spec.rb +0 -39
- data/spec/lib/openstax/accounts/current_user_manager_spec.rb +0 -157
- data/spec/lib/openstax/accounts/has_many_through_groups/active_record/base_spec.rb +0 -57
- data/spec/models/openstax/accounts/account_spec.rb +0 -114
- data/spec/models/openstax/accounts/anonymous_account_spec.rb +0 -9
- data/spec/models/openstax/accounts/group_spec.rb +0 -51
- data/spec/routines/openstax/accounts/create_group_spec.rb +0 -32
- data/spec/routines/openstax/accounts/find_or_create_account_spec.rb +0 -76
- data/spec/routines/openstax/accounts/search_accounts_shared_examples.rb +0 -160
- data/spec/routines/openstax/accounts/search_accounts_spec.rb +0 -6
- data/spec/routines/openstax/accounts/search_local_accounts_spec.rb +0 -6
- data/spec/routines/openstax/accounts/sync_accounts_spec.rb +0 -101
- data/spec/routines/openstax/accounts/sync_groups_spec.rb +0 -143
- data/spec/spec_helper.rb +0 -109
- data/spec/vcr_helper.rb +0 -14
data/Rakefile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'bundler/setup'
|
5
|
-
rescue LoadError
|
6
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
-
end
|
8
|
-
|
9
|
-
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
10
|
-
load 'rails/tasks/engine.rake'
|
11
|
-
|
12
|
-
Bundler::GemHelper.install_tasks
|
13
|
-
|
14
|
-
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each { |f| load f }
|
15
|
-
|
16
|
-
require 'rspec/core'
|
17
|
-
require 'rspec/core/rake_task'
|
18
|
-
|
19
|
-
desc 'Run all specs in spec directory (excluding plugin specs)'
|
20
|
-
RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
|
21
|
-
|
22
|
-
task default: :spec
|
@@ -1,303 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: post
|
5
|
-
uri: http://localhost:2999/oauth/token
|
6
|
-
body:
|
7
|
-
encoding: UTF-8
|
8
|
-
string: client_id=6f3dbfdbb87bf28db1c8279f44c39ea3c3a702ae4303ebcb5a5d8067dc040f85&client_secret=a439ff2377713b3372f8044062f23ad1eb515237e1711cbe6f442c1bea935373&grant_type=client_credentials
|
9
|
-
headers:
|
10
|
-
User-Agent:
|
11
|
-
- Faraday v0.9.2
|
12
|
-
Content-Type:
|
13
|
-
- application/x-www-form-urlencoded
|
14
|
-
Accept-Encoding:
|
15
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
-
Accept:
|
17
|
-
- "*/*"
|
18
|
-
response:
|
19
|
-
status:
|
20
|
-
code: 200
|
21
|
-
message: OK
|
22
|
-
headers:
|
23
|
-
X-Frame-Options:
|
24
|
-
- SAMEORIGIN
|
25
|
-
X-Xss-Protection:
|
26
|
-
- 1; mode=block
|
27
|
-
X-Content-Type-Options:
|
28
|
-
- nosniff
|
29
|
-
Cache-Control:
|
30
|
-
- no-store
|
31
|
-
Pragma:
|
32
|
-
- no-cache
|
33
|
-
Content-Type:
|
34
|
-
- application/json; charset=utf-8
|
35
|
-
P3p:
|
36
|
-
- CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
|
37
|
-
Etag:
|
38
|
-
- W/"da2f9b92fc82c5fa07f64029a71cff95"
|
39
|
-
X-Request-Id:
|
40
|
-
- 26a0a272-9fcf-42c9-a702-357b46a5c070
|
41
|
-
X-Runtime:
|
42
|
-
- '0.030377'
|
43
|
-
Connection:
|
44
|
-
- close
|
45
|
-
Server:
|
46
|
-
- thin
|
47
|
-
body:
|
48
|
-
encoding: UTF-8
|
49
|
-
string: '{"access_token":"c31fe09157c9801c88356a972d0e0c95aa13081cea77ae45f098b5dc7f614642","token_type":"bearer","created_at":1497844427}'
|
50
|
-
http_version:
|
51
|
-
recorded_at: Mon, 19 Jun 2017 03:53:47 GMT
|
52
|
-
- request:
|
53
|
-
method: post
|
54
|
-
uri: http://localhost:2999/api/user/find-or-create
|
55
|
-
body:
|
56
|
-
encoding: UTF-8
|
57
|
-
string: '{"email":"alice@example.com","username":null,"password":null,"first_name":null,"last_name":null,"full_name":null,"salesforce_contact_id":null,"faculty_status":null,"role":null,"school_type":null}'
|
58
|
-
headers:
|
59
|
-
User-Agent:
|
60
|
-
- Faraday v0.9.2
|
61
|
-
Accept:
|
62
|
-
- application/vnd.accounts.openstax.v1
|
63
|
-
Content-Type:
|
64
|
-
- application/json
|
65
|
-
Authorization:
|
66
|
-
- Bearer c31fe09157c9801c88356a972d0e0c95aa13081cea77ae45f098b5dc7f614642
|
67
|
-
Accept-Encoding:
|
68
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
69
|
-
response:
|
70
|
-
status:
|
71
|
-
code: 201
|
72
|
-
message: Created
|
73
|
-
headers:
|
74
|
-
X-Frame-Options:
|
75
|
-
- SAMEORIGIN
|
76
|
-
X-Xss-Protection:
|
77
|
-
- 1; mode=block
|
78
|
-
X-Content-Type-Options:
|
79
|
-
- nosniff
|
80
|
-
Date:
|
81
|
-
- Mon, 19 Jun 2017 03:53:47 GMT
|
82
|
-
Content-Type:
|
83
|
-
- application/json; charset=utf-8
|
84
|
-
P3p:
|
85
|
-
- CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
|
86
|
-
Etag:
|
87
|
-
- W/"c61c434670d5436a6af8a75c120f5bdf"
|
88
|
-
Cache-Control:
|
89
|
-
- max-age=0, private, must-revalidate
|
90
|
-
X-Request-Id:
|
91
|
-
- 4d8fb993-d7ef-4820-9248-8c830caf1b78
|
92
|
-
X-Runtime:
|
93
|
-
- '0.227730'
|
94
|
-
Connection:
|
95
|
-
- close
|
96
|
-
Server:
|
97
|
-
- thin
|
98
|
-
body:
|
99
|
-
encoding: UTF-8
|
100
|
-
string: '{"id":18,"uuid":"8c5c819f-d9d9-46e7-98b9-d737fc0f13fe","support_identifier":"cs_6f3b305b"}'
|
101
|
-
http_version:
|
102
|
-
recorded_at: Mon, 19 Jun 2017 03:53:47 GMT
|
103
|
-
- request:
|
104
|
-
method: post
|
105
|
-
uri: http://localhost:2999/oauth/token
|
106
|
-
body:
|
107
|
-
encoding: UTF-8
|
108
|
-
string: client_id=6f3dbfdbb87bf28db1c8279f44c39ea3c3a702ae4303ebcb5a5d8067dc040f85&client_secret=a439ff2377713b3372f8044062f23ad1eb515237e1711cbe6f442c1bea935373&grant_type=client_credentials
|
109
|
-
headers:
|
110
|
-
User-Agent:
|
111
|
-
- Faraday v0.9.2
|
112
|
-
Content-Type:
|
113
|
-
- application/x-www-form-urlencoded
|
114
|
-
Accept-Encoding:
|
115
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
116
|
-
Accept:
|
117
|
-
- "*/*"
|
118
|
-
response:
|
119
|
-
status:
|
120
|
-
code: 200
|
121
|
-
message: OK
|
122
|
-
headers:
|
123
|
-
X-Frame-Options:
|
124
|
-
- SAMEORIGIN
|
125
|
-
X-Xss-Protection:
|
126
|
-
- 1; mode=block
|
127
|
-
X-Content-Type-Options:
|
128
|
-
- nosniff
|
129
|
-
Cache-Control:
|
130
|
-
- no-store
|
131
|
-
Pragma:
|
132
|
-
- no-cache
|
133
|
-
Content-Type:
|
134
|
-
- application/json; charset=utf-8
|
135
|
-
P3p:
|
136
|
-
- CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
|
137
|
-
Etag:
|
138
|
-
- W/"c7a634c41cb04b393e0cd348d63efec1"
|
139
|
-
X-Request-Id:
|
140
|
-
- b977409f-0914-4eac-832e-3d406140ef24
|
141
|
-
X-Runtime:
|
142
|
-
- '0.023528'
|
143
|
-
Connection:
|
144
|
-
- close
|
145
|
-
Server:
|
146
|
-
- thin
|
147
|
-
body:
|
148
|
-
encoding: UTF-8
|
149
|
-
string: '{"access_token":"1c4df98e8f1b07b4dd33aa81150262c829999aaf0564721c423f01c263c2114f","token_type":"bearer","created_at":1497844427}'
|
150
|
-
http_version:
|
151
|
-
recorded_at: Mon, 19 Jun 2017 03:53:47 GMT
|
152
|
-
- request:
|
153
|
-
method: post
|
154
|
-
uri: http://localhost:2999/api/user/find-or-create
|
155
|
-
body:
|
156
|
-
encoding: UTF-8
|
157
|
-
string: '{"email":null,"username":"alice","password":null,"first_name":null,"last_name":null,"full_name":null,"salesforce_contact_id":null,"faculty_status":null,"role":null,"school_type":null}'
|
158
|
-
headers:
|
159
|
-
User-Agent:
|
160
|
-
- Faraday v0.9.2
|
161
|
-
Accept:
|
162
|
-
- application/vnd.accounts.openstax.v1
|
163
|
-
Content-Type:
|
164
|
-
- application/json
|
165
|
-
Authorization:
|
166
|
-
- Bearer 1c4df98e8f1b07b4dd33aa81150262c829999aaf0564721c423f01c263c2114f
|
167
|
-
Accept-Encoding:
|
168
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
169
|
-
response:
|
170
|
-
status:
|
171
|
-
code: 201
|
172
|
-
message: Created
|
173
|
-
headers:
|
174
|
-
X-Frame-Options:
|
175
|
-
- SAMEORIGIN
|
176
|
-
X-Xss-Protection:
|
177
|
-
- 1; mode=block
|
178
|
-
X-Content-Type-Options:
|
179
|
-
- nosniff
|
180
|
-
Date:
|
181
|
-
- Mon, 19 Jun 2017 03:53:47 GMT
|
182
|
-
Content-Type:
|
183
|
-
- application/json; charset=utf-8
|
184
|
-
P3p:
|
185
|
-
- CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
|
186
|
-
Etag:
|
187
|
-
- W/"a6c213351d9df66ee31997f7ed447fbc"
|
188
|
-
Cache-Control:
|
189
|
-
- max-age=0, private, must-revalidate
|
190
|
-
X-Request-Id:
|
191
|
-
- ee7c0cba-d530-4a21-b94c-5adf7efb994a
|
192
|
-
X-Runtime:
|
193
|
-
- '0.067316'
|
194
|
-
Connection:
|
195
|
-
- close
|
196
|
-
Server:
|
197
|
-
- thin
|
198
|
-
body:
|
199
|
-
encoding: UTF-8
|
200
|
-
string: '{"id":19,"uuid":"c1ebaa86-b8ef-4100-9213-a16ca741d47f","support_identifier":"cs_edc0b069"}'
|
201
|
-
http_version:
|
202
|
-
recorded_at: Mon, 19 Jun 2017 03:53:47 GMT
|
203
|
-
- request:
|
204
|
-
method: post
|
205
|
-
uri: http://localhost:2999/oauth/token
|
206
|
-
body:
|
207
|
-
encoding: UTF-8
|
208
|
-
string: client_id=6f3dbfdbb87bf28db1c8279f44c39ea3c3a702ae4303ebcb5a5d8067dc040f85&client_secret=a439ff2377713b3372f8044062f23ad1eb515237e1711cbe6f442c1bea935373&grant_type=client_credentials
|
209
|
-
headers:
|
210
|
-
User-Agent:
|
211
|
-
- Faraday v0.9.2
|
212
|
-
Content-Type:
|
213
|
-
- application/x-www-form-urlencoded
|
214
|
-
Accept-Encoding:
|
215
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
216
|
-
Accept:
|
217
|
-
- "*/*"
|
218
|
-
response:
|
219
|
-
status:
|
220
|
-
code: 200
|
221
|
-
message: OK
|
222
|
-
headers:
|
223
|
-
X-Frame-Options:
|
224
|
-
- SAMEORIGIN
|
225
|
-
X-Xss-Protection:
|
226
|
-
- 1; mode=block
|
227
|
-
X-Content-Type-Options:
|
228
|
-
- nosniff
|
229
|
-
Cache-Control:
|
230
|
-
- no-store
|
231
|
-
Pragma:
|
232
|
-
- no-cache
|
233
|
-
Content-Type:
|
234
|
-
- application/json; charset=utf-8
|
235
|
-
P3p:
|
236
|
-
- CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
|
237
|
-
Etag:
|
238
|
-
- W/"a0d885d8947b3be5da25673a937640fc"
|
239
|
-
X-Request-Id:
|
240
|
-
- 21711558-b1df-4a12-b141-1e0a073f71db
|
241
|
-
X-Runtime:
|
242
|
-
- '0.022856'
|
243
|
-
Connection:
|
244
|
-
- close
|
245
|
-
Server:
|
246
|
-
- thin
|
247
|
-
body:
|
248
|
-
encoding: UTF-8
|
249
|
-
string: '{"access_token":"21bb7c60df067e7354ec7e3b2e83d2d39831aece5938d20e8e68e6ea52ab59ff","token_type":"bearer","created_at":1497844427}'
|
250
|
-
http_version:
|
251
|
-
recorded_at: Mon, 19 Jun 2017 03:53:47 GMT
|
252
|
-
- request:
|
253
|
-
method: post
|
254
|
-
uri: http://localhost:2999/api/user/find-or-create
|
255
|
-
body:
|
256
|
-
encoding: UTF-8
|
257
|
-
string: '{"email":null,"username":"alice2","password":"abcdefghijklmnop","first_name":null,"last_name":null,"full_name":null,"salesforce_contact_id":null,"faculty_status":null,"role":null,"school_type":null}'
|
258
|
-
headers:
|
259
|
-
User-Agent:
|
260
|
-
- Faraday v0.9.2
|
261
|
-
Accept:
|
262
|
-
- application/vnd.accounts.openstax.v1
|
263
|
-
Content-Type:
|
264
|
-
- application/json
|
265
|
-
Authorization:
|
266
|
-
- Bearer 21bb7c60df067e7354ec7e3b2e83d2d39831aece5938d20e8e68e6ea52ab59ff
|
267
|
-
Accept-Encoding:
|
268
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
269
|
-
response:
|
270
|
-
status:
|
271
|
-
code: 201
|
272
|
-
message: Created
|
273
|
-
headers:
|
274
|
-
X-Frame-Options:
|
275
|
-
- SAMEORIGIN
|
276
|
-
X-Xss-Protection:
|
277
|
-
- 1; mode=block
|
278
|
-
X-Content-Type-Options:
|
279
|
-
- nosniff
|
280
|
-
Date:
|
281
|
-
- Mon, 19 Jun 2017 03:53:48 GMT
|
282
|
-
Content-Type:
|
283
|
-
- application/json; charset=utf-8
|
284
|
-
P3p:
|
285
|
-
- CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
|
286
|
-
Etag:
|
287
|
-
- W/"1574b45433f3e6117795d9e71a8a7fc9"
|
288
|
-
Cache-Control:
|
289
|
-
- max-age=0, private, must-revalidate
|
290
|
-
X-Request-Id:
|
291
|
-
- 818cfe0a-9264-43c8-a73f-48cfbea35672
|
292
|
-
X-Runtime:
|
293
|
-
- '0.142613'
|
294
|
-
Connection:
|
295
|
-
- close
|
296
|
-
Server:
|
297
|
-
- thin
|
298
|
-
body:
|
299
|
-
encoding: UTF-8
|
300
|
-
string: '{"id":20,"uuid":"76c36a75-5b5a-4dbd-8800-5c1916c6f1f2","support_identifier":"cs_bccb058a"}'
|
301
|
-
http_version:
|
302
|
-
recorded_at: Mon, 19 Jun 2017 03:53:48 GMT
|
303
|
-
recorded_with: VCR 3.0.3
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module OpenStax::Accounts
|
4
|
-
module Dev
|
5
|
-
RSpec.describe AccountsController, type: :controller do
|
6
|
-
routes { Engine.routes }
|
7
|
-
|
8
|
-
let!(:account) { FactoryBot.create :openstax_accounts_account,
|
9
|
-
username: 'some_user',
|
10
|
-
openstax_uid: 10 }
|
11
|
-
|
12
|
-
it 'should allow users not in production to become other users' do
|
13
|
-
expect(controller.current_account).to eq(AnonymousAccount.instance)
|
14
|
-
expect(controller.current_account.is_anonymous?).to eq(true)
|
15
|
-
post :become, id: account.openstax_uid
|
16
|
-
expect(controller.current_account).to eq(account)
|
17
|
-
expect(controller.current_account.is_anonymous?).to eq(false)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should not set X-Frame-Options header' do
|
21
|
-
get :index
|
22
|
-
expect(response.header['X-Frame-Options']).to be_nil
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe "Forwards params", type: :request do
|
4
|
-
|
5
|
-
class ForwardsParamsController < OpenStax::Accounts::ApplicationController
|
6
|
-
before_filter :set_login_param
|
7
|
-
before_filter :authenticate_user!
|
8
|
-
|
9
|
-
def action_needing_authentication; end
|
10
|
-
|
11
|
-
def set_login_param
|
12
|
-
login_params[:signup_at] = "foo"
|
13
|
-
login_params[:go] = "bar"
|
14
|
-
login_params[:sp] = "blah"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
before(:all) do
|
19
|
-
Rails.application.routes.send(:eval_block, Proc.new do
|
20
|
-
get '/forwards_params_route' => 'forwards_params#action_needing_authentication'
|
21
|
-
end)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should forward signup_at' do
|
25
|
-
test_forwards(key: :signup_at, value: "foo")
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should forward go" do
|
29
|
-
test_forwards(key: :go, value: "bar")
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should forward go" do
|
33
|
-
test_forwards(key: :sp, value: "blah")
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_forwards(key:, value:)
|
37
|
-
silence_omniauth do
|
38
|
-
get '/forwards_params_route'
|
39
|
-
|
40
|
-
expect(redirect_path).to eq "/accounts/login"
|
41
|
-
expect(redirect_query_hash).to include(key => value)
|
42
|
-
|
43
|
-
with_stubbing(false) do
|
44
|
-
get redirect_path_and_query
|
45
|
-
end
|
46
|
-
|
47
|
-
expect(redirect_path).to eq "/accounts/auth/openstax"
|
48
|
-
expect(redirect_query_hash).to include(key => value)
|
49
|
-
|
50
|
-
get redirect_path_and_query
|
51
|
-
|
52
|
-
expect(redirect_path).to eq("/oauth/authorize")
|
53
|
-
expect(redirect_query_hash).to include(key => value)
|
54
|
-
|
55
|
-
# This last redirect was to Accounts, so we don't follow it
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def redirect_path
|
60
|
-
redirect_uri.path
|
61
|
-
end
|
62
|
-
|
63
|
-
def redirect_path_and_query
|
64
|
-
"#{redirect_uri.path}?#{redirect_uri.query}"
|
65
|
-
end
|
66
|
-
|
67
|
-
def redirect_query_hash
|
68
|
-
Rack::Utils.parse_nested_query(redirect_uri.query).symbolize_keys
|
69
|
-
end
|
70
|
-
|
71
|
-
def redirect_uri
|
72
|
-
expect(response.code).to eq "302"
|
73
|
-
uri = URI.parse(response.headers["Location"])
|
74
|
-
end
|
75
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module OpenStax::Accounts
|
4
|
-
RSpec.describe SessionsController, type: :controller do
|
5
|
-
routes { Engine.routes }
|
6
|
-
|
7
|
-
let!(:account) { FactoryBot.create :openstax_accounts_account,
|
8
|
-
username: 'some_user',
|
9
|
-
openstax_uid: 10 }
|
10
|
-
|
11
|
-
after(:all) {
|
12
|
-
OpenStax::Accounts.configuration.logout_redirect_url = nil
|
13
|
-
OpenStax::Accounts.configuration.return_to_url_approver = nil
|
14
|
-
}
|
15
|
-
|
16
|
-
it 'should redirect users to the login path' do
|
17
|
-
c = controller
|
18
|
-
get :new
|
19
|
-
expect(response).to redirect_to(c.dev_accounts_path)
|
20
|
-
expect(response.code).to eq('302')
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should authenticate users based on the oauth callback' do
|
24
|
-
# TODO
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should let users logout' do
|
28
|
-
controller.sign_in account
|
29
|
-
expect(controller.current_account).to eq(account)
|
30
|
-
expect(controller.current_account.is_anonymous?).to eq(false)
|
31
|
-
delete :destroy
|
32
|
-
expect(controller.current_account).to eq(AnonymousAccount.instance)
|
33
|
-
expect(controller.current_account.is_anonymous?).to eq(true)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should get signout redirect URL from configured setting' do
|
37
|
-
my_lambda = ->(request) { "http://www.google.com" }
|
38
|
-
OpenStax::Accounts.configuration.logout_redirect_url = my_lambda
|
39
|
-
|
40
|
-
allow(OpenStax::Accounts.configuration).to receive(:enable_stubbing?) {false}
|
41
|
-
expect(my_lambda).to receive(:call).with(anything())
|
42
|
-
|
43
|
-
controller.sign_in account
|
44
|
-
delete :destroy
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should store specified url for redirection after to login if approved' do
|
48
|
-
OpenStax::Accounts.configuration.return_to_url_approver = ->(url) { true }
|
49
|
-
allow(OpenStax::Accounts.configuration).to receive(:enable_stubbing?) {false}
|
50
|
-
get :new, return_to: "https://woohoo"
|
51
|
-
expect(session["accounts_return_to"]).to eq "https://woohoo"
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should not store specified url for redirection after login if not approved' do
|
55
|
-
OpenStax::Accounts.configuration.return_to_url_approver = ->(url) { false }
|
56
|
-
allow(OpenStax::Accounts.configuration).to receive(:enable_stubbing?) {false}
|
57
|
-
get :new, return_to: "https://woohoo"
|
58
|
-
expect(session["accounts_return_to"]).to eq nil
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should give the return_to url to the config approver' do
|
62
|
-
my_lambda = ->(url) { true }
|
63
|
-
OpenStax::Accounts.configuration.return_to_url_approver = my_lambda
|
64
|
-
|
65
|
-
allow(OpenStax::Accounts.configuration).to receive(:enable_stubbing?) {false}
|
66
|
-
expect(my_lambda).to receive(:call).with("http://jimmy")
|
67
|
-
|
68
|
-
get :new, return_to: 'http://jimmy'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|