mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FEATURE: List, revoke and reconnect associated accounts. Phase 1 (#6099)
Listing connections is supported for all built-in auth providers. Revoke and reconnect is currently only implemented for Facebook.
This commit is contained in:
@ -125,7 +125,40 @@ describe Plugin::Instance do
|
||||
end
|
||||
end
|
||||
|
||||
it 'patches the enabled? function for auth_providers if not defined' do
|
||||
SiteSetting.stubs(:ubuntu_login_enabled).returns(false)
|
||||
|
||||
plugin = Plugin::Instance.new
|
||||
|
||||
# No enabled_site_setting
|
||||
authenticator = Auth::Authenticator.new
|
||||
plugin.auth_provider(authenticator: authenticator)
|
||||
plugin.notify_after_initialize
|
||||
expect(authenticator.enabled?).to eq(true)
|
||||
|
||||
# With enabled site setting
|
||||
authenticator = Auth::Authenticator.new
|
||||
plugin.auth_provider(enabled_setting: 'ubuntu_login_enabled', authenticator: authenticator)
|
||||
plugin.notify_after_initialize
|
||||
expect(authenticator.enabled?).to eq(false)
|
||||
|
||||
# Defines own method
|
||||
SiteSetting.stubs(:ubuntu_login_enabled).returns(true)
|
||||
authenticator = Class.new(Auth::Authenticator) do
|
||||
def enabled?
|
||||
false
|
||||
end
|
||||
end.new
|
||||
plugin.auth_provider(enabled_setting: 'ubuntu_login_enabled', authenticator: authenticator)
|
||||
plugin.notify_after_initialize
|
||||
expect(authenticator.enabled?).to eq(false)
|
||||
end
|
||||
|
||||
context "activate!" do
|
||||
before do
|
||||
SiteSetting.stubs(:ubuntu_login_enabled).returns(false)
|
||||
end
|
||||
|
||||
it "can activate plugins correctly" do
|
||||
plugin = Plugin::Instance.new
|
||||
plugin.path = "#{Rails.root}/spec/fixtures/plugins/my_plugin/plugin.rb"
|
||||
@ -135,10 +168,6 @@ describe Plugin::Instance do
|
||||
File.open("#{plugin.auto_generated_path}/junk", "w") { |f| f.write("junk") }
|
||||
plugin.activate!
|
||||
|
||||
expect(plugin.auth_providers.count).to eq(1)
|
||||
auth_provider = plugin.auth_providers[0]
|
||||
expect(auth_provider.authenticator.name).to eq('ubuntu')
|
||||
|
||||
# calls ensure_assets! make sure they are there
|
||||
expect(plugin.assets.count).to eq(1)
|
||||
plugin.assets.each do |a, opts|
|
||||
@ -149,6 +178,17 @@ describe Plugin::Instance do
|
||||
expect(File.exists?(junk_file)).to eq(false)
|
||||
end
|
||||
|
||||
it "registers auth providers correctly" do
|
||||
plugin = Plugin::Instance.new
|
||||
plugin.path = "#{Rails.root}/spec/fixtures/plugins/my_plugin/plugin.rb"
|
||||
plugin.activate!
|
||||
|
||||
expect(plugin.auth_providers.count).to eq(1)
|
||||
auth_provider = plugin.auth_providers[0]
|
||||
expect(auth_provider.authenticator.name).to eq('ubuntu')
|
||||
expect(DiscoursePluginRegistry.auth_providers.count).to eq(1)
|
||||
end
|
||||
|
||||
it "finds all the custom assets" do
|
||||
plugin = Plugin::Instance.new
|
||||
plugin.path = "#{Rails.root}/spec/fixtures/plugins/my_plugin/plugin.rb"
|
||||
|
Reference in New Issue
Block a user