2013-10-28 01:29:07 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
# In the ghetto ... getting the spec to run in autospec
|
|
|
|
# thing is we need to load up all auth really early pre-fork
|
|
|
|
# it means that the require is not going to get a new copy
|
|
|
|
Auth.send(:remove_const, :OpenIdAuthenticator)
|
|
|
|
load 'auth/open_id_authenticator.rb'
|
|
|
|
|
|
|
|
describe Auth::OpenIdAuthenticator do
|
|
|
|
|
|
|
|
it "can lookup pre-existing user if trusted" do
|
|
|
|
auth = Auth::OpenIdAuthenticator.new("test", "id", trusted: true)
|
|
|
|
|
|
|
|
user = Fabricate(:user)
|
2014-03-25 23:52:50 -04:00
|
|
|
response = OpenStruct.new(identity_url: 'abc')
|
|
|
|
result = auth.after_authenticate(info: {email: user.email}, extra: {response: response})
|
2013-10-28 01:29:07 -04:00
|
|
|
result.user.should == user
|
|
|
|
end
|
2014-08-07 13:28:50 -04:00
|
|
|
|
|
|
|
it "raises an exception when email is missing" do
|
|
|
|
auth = Auth::OpenIdAuthenticator.new("test", "id", trusted: true)
|
|
|
|
response = OpenStruct.new(identity_url: 'abc')
|
|
|
|
-> { auth.after_authenticate(info: {}, extra: { response: response }) }.should raise_error(Discourse::InvalidParameters)
|
|
|
|
end
|
2013-10-28 01:29:07 -04:00
|
|
|
end
|