mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:41:24 +08:00
Authenticate with Discourse via OAuth2
See https://github.com/michaelkirk/discourse_oauth2_example for an example of how you might integrate your existing oauth2 provider's authentication via a Discourse plugin.
This commit is contained in:
@ -164,4 +164,25 @@ describe Users::OmniauthCallbacksController do
|
||||
|
||||
end
|
||||
|
||||
describe 'oauth2' do
|
||||
before do
|
||||
Discourse.stubs(:auth_providers).returns([stub(name: 'my_oauth2_provider', type: :oauth2)])
|
||||
request.env["omniauth.auth"] = { uid: 'my-uid', provider: 'my-oauth-provider-domain.net', info: {email: 'eviltrout@made.up.email', name: 'Chatanooga'}}
|
||||
end
|
||||
|
||||
describe "#create_or_sign_on_user_using_oauth2" do
|
||||
context "User already exists" do
|
||||
before do
|
||||
User.stubs(:find_by_email).returns(Fabricate(:user))
|
||||
end
|
||||
|
||||
it "should create an OauthUserInfo" do
|
||||
expect {
|
||||
post :complete, provider: 'my_oauth2_provider'
|
||||
}.to change { Oauth2UserInfo.count }.by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user