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:
David Taylor
2018-07-23 16:51:57 +01:00
committed by GitHub
parent 32062864d3
commit eda1462b3b
40 changed files with 836 additions and 240 deletions

View File

@ -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"