[ARVADOS] updated: 69141a18be1821daf4816046e65b2aea75a975be
git at public.curoverse.com
git at public.curoverse.com
Tue May 6 21:46:52 EDT 2014
Summary of changes:
.../app/controllers/user_sessions_controller.rb | 3 +-
services/api/app/models/arvados_model.rb | 2 +
services/api/app/models/user.rb | 4 +++
.../api/test/integration/user_sessions_test.rb | 28 ++++++++++++++++++++
4 files changed, 35 insertions(+), 2 deletions(-)
create mode 100644 services/api/test/integration/user_sessions_test.rb
via 69141a18be1821daf4816046e65b2aea75a975be (commit)
from ba764a7a0878b9cf0dd8d22ad4e12774d8e5f550 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 69141a18be1821daf4816046e65b2aea75a975be
Author: Tom Clegg <tom at curoverse.com>
Date: Tue May 6 21:46:04 2014 -0400
Fix crash creating new user during initial login. Add test.
diff --git a/services/api/app/controllers/user_sessions_controller.rb b/services/api/app/controllers/user_sessions_controller.rb
index 3d4b05a..0b80877 100644
--- a/services/api/app/controllers/user_sessions_controller.rb
+++ b/services/api/app/controllers/user_sessions_controller.rb
@@ -9,7 +9,6 @@ class UserSessionsController < ApplicationController
# omniauth callback method
def create
omniauth = env['omniauth.auth']
- #logger.debug "+++ #{omniauth}"
identity_url_ok = (omniauth['info']['identity_url'].length > 0) rescue false
unless identity_url_ok
@@ -58,7 +57,7 @@ class UserSessionsController < ApplicationController
# "unauthorized":
Thread.current[:user] = user
- user.save!
+ user.save or raise Exception.new(user.errors.messages)
omniauth.delete('extra')
diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb
index 2bf1376..006eb90 100644
--- a/services/api/app/models/arvados_model.rb
+++ b/services/api/app/models/arvados_model.rb
@@ -247,6 +247,7 @@ class ArvadosModel < ActiveRecord::Base
def maybe_update_modified_by_fields
update_modified_by_fields if self.changed? or self.new_record?
+ true
end
def update_modified_by_fields
@@ -255,6 +256,7 @@ class ArvadosModel < ActiveRecord::Base
self.modified_at = Time.now
self.modified_by_user_uuid = current_user ? current_user.uuid : nil
self.modified_by_client_uuid = current_api_client ? current_api_client.uuid : nil
+ true
end
def ensure_serialized_attribute_type
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 81cae98..6bba194 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -177,6 +177,10 @@ class User < ArvadosModel
protected
+ def ensure_ownership_path_leads_to_user
+ true
+ end
+
def permission_to_update
# users must be able to update themselves (even if they are
# inactive) in order to create sessions
diff --git a/services/api/test/integration/user_sessions_test.rb b/services/api/test/integration/user_sessions_test.rb
new file mode 100644
index 0000000..321a5ac
--- /dev/null
+++ b/services/api/test/integration/user_sessions_test.rb
@@ -0,0 +1,28 @@
+require 'test_helper'
+
+class UserSessionsApiTest < ActionDispatch::IntegrationTest
+ test 'create new user during omniauth callback' do
+ mock = {
+ 'provider' => 'josh_id',
+ 'uid' => 'https://edward.example.com',
+ 'info' => {
+ 'identity_url' => 'https://edward.example.com',
+ 'name' => 'Edward Example',
+ 'first_name' => 'Edward',
+ 'last_name' => 'Example',
+ 'email' => 'edward at example.com',
+ },
+ }
+ client_url = 'https://wb.example.com'
+ post('/auth/josh_id/callback',
+ {return_to: client_url},
+ {'omniauth.auth' => mock})
+ assert_response :redirect, 'Did not redirect to client with token'
+ assert_equal(0, @response.redirect_url.index(client_url),
+ 'Redirected to wrong address after succesful login: was ' +
+ @response.redirect_url + ', expected ' + client_url + '[...]')
+ assert_not_nil(@response.redirect_url.index('api_token='),
+ 'Expected api_token in query string of redirect url ' +
+ @response.redirect_url)
+ end
+end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list