remove openid remains

pull/1121/head
Martin Linkhorst 11 years ago committed by Michael Frister
parent 07ecf4b038
commit 1ce4d30b1b
  1. 2
      app/assets/stylesheets/default/main.css.erb
  2. 4
      app/models/setting.rb
  3. 2
      app/views/settings/_authentication.html.erb
  4. 2
      config/locales/de.yml
  5. 2
      config/locales/en.yml
  6. 1
      config/routes.rb
  7. 2
      config/settings.yml
  8. 23
      db/migrate/20140414141459_remove_openid_entirely.rb
  9. 103
      test/functional/account_controller_test.rb
  10. 74
      test/mocks/open_id_authentication_mock.rb
  11. 1
      test/test_helper.rb
  12. 35
      test/unit/user_test.rb

@ -27,8 +27,6 @@ See doc/COPYRIGHT.rdoc for more details.
++*/
input#openid_url { background: url(<%= asset_path 'openid-bg.gif' %>) no-repeat; background-color: #fff; background-position: 0 50%; padding-left: 18px; }
.clear:after{ content: "."; display: block; height: 0; clear: both; visibility: hidden; }
/***** Tables *****/

@ -189,10 +189,6 @@ class Setting < ActiveRecord::Base
per_page_options.split(%r{[\s,]}).collect(&:to_i).select {|n| n > 0}.sort
end
def self.openid?
Object.const_defined?(:OpenID) && self[:openid].to_i > 0
end
# Deprecation Warning: This method is no longer available. There is no
# replacement.
def self.check_cache

@ -77,8 +77,6 @@ See doc/COPYRIGHT.rdoc for more details.
<fieldset>
<legend><%= I18n.t(:other, :scope => [:settings]) %></legend>
<p><%= setting_check_box :openid, :disabled => !Object.const_defined?(:OpenID) %></p>
<p><%= setting_check_box :log_requesting_user %></p>
<p><%= setting_check_box :rest_api_enabled %></p>
</fieldset>

@ -800,7 +800,6 @@ de:
label_loading: "Lade..."
label_logged_as: "Angemeldet als"
label_login: "Anmelden"
label_login_with_open_id_option: "oder mit OpenID anmelden"
label_logout: "Abmelden"
label_main_menu: "Nebenmenü"
label_max_size: "Maximale Größe"
@ -1295,7 +1294,6 @@ de:
setting_mail_handler_api_key: "API-Schlüssel"
setting_mail_handler_body_delimiters: "Schneide E-Mails nach einer dieser Zeilen ab"
setting_new_project_user_role_id: "Rolle, die einem Nicht-Administrator zugeordnet wird, der ein Projekt erstellt"
setting_openid: "Erlaube OpenID-Anmeldung und -Registrierung"
setting_password_active_rules: "Aktive Zeichenklassen"
setting_password_count_former_banned: "Anzahl zuletzt benutzter Passwörter, die nicht wiederverwendet werden dürfen"
setting_password_days_valid: "Anzahl von Tagen, nach denen ein Passwortwechsel erwzwungen wird (deaktivieren mit 0)"

@ -797,7 +797,6 @@ en:
label_loading: "Loading..."
label_logged_as: "Logged in as"
label_login: "Sign in"
label_login_with_open_id_option: "or login with OpenID"
label_logout: "Sign out"
label_main_menu: "Side Menu"
label_max_size: "Maximum size"
@ -1283,7 +1282,6 @@ en:
setting_mail_handler_api_key: "API key"
setting_mail_handler_body_delimiters: "Truncate emails after one of these lines"
setting_new_project_user_role_id: "Role given to a non-admin user who creates a project"
setting_openid: "Allow OpenID login and registration"
setting_password_active_rules: "Active character classes"
setting_password_count_former_banned: "Number of most recently used passwords banned for reuse"
setting_password_days_valid: "Number of days, after which to enforce a password change (disable with 0)"

@ -483,6 +483,5 @@ OpenProject::Application.routes.draw do
# Install the default route as the lowest priority.
match '/:controller(/:action(/:id))'
match '/robots' => 'welcome#robots', :defaults => { :format => :txt }
# Used for OpenID
root :to => 'account#login'
end

@ -235,8 +235,6 @@ emails_footer:
To change your notification preferences, please click here: http://hostname/my/account
gravatar_enabled:
default: 0
openid:
default: 0
gravatar_default:
default: ''
start_of_week:

@ -0,0 +1,23 @@
class RemoveOpenidEntirely < ActiveRecord::Migration
def up
drop_table 'open_id_authentication_nonces'
drop_table 'open_id_authentication_associations'
end
def down
create_table "open_id_authentication_associations", :force => true do |t|
t.integer "issued"
t.integer "lifetime"
t.string "handle"
t.string "assoc_type"
t.binary "server_url"
t.binary "secret"
end
create_table "open_id_authentication_nonces", :force => true do |t|
t.integer "timestamp", :null => false
t.string "server_url"
t.string "salt", :null => false
end
end
end

@ -68,109 +68,6 @@ class AccountControllerTest < ActionController::TestCase
assert_redirected_to home_url
end
if Object.const_defined?(:OpenID)
def test_login_with_openid_for_existing_user
Setting.self_registration = '3'
Setting.openid = '1'
existing_user = User.new(:firstname => 'Cool',
:lastname => 'User',
:mail => 'user@somedomain.com',
:identity_url => 'http://openid.example.com/good_user')
existing_user.login = 'cool_user'
assert existing_user.save!
post :login, :openid_url => existing_user.identity_url
assert_redirected_to '/my/first_login'
end
def test_login_with_invalid_openid_provider
Setting.self_registration = '0'
Setting.openid = '1'
post :login, :openid_url => 'http;//openid.example.com/good_user'
assert_redirected_to home_url
end
def test_login_with_openid_for_existing_non_active_user
Setting.self_registration = '2'
Setting.openid = '1'
existing_user = User.new(:firstname => 'Cool',
:lastname => 'User',
:mail => 'user@somedomain.com',
:identity_url => 'http://openid.example.com/good_user',
:status => User::STATUSES[:registered])
existing_user.login = 'cool_user'
assert existing_user.save!
post :login, :openid_url => existing_user.identity_url
assert_redirected_to '/login'
end
def test_login_with_openid_with_new_user_created
Setting.self_registration = '3'
Setting.openid = '1'
post :login, :openid_url => 'http://openid.example.com/good_user'
assert_redirected_to '/my/account'
user = User.find_by_login('cool_user')
assert user
assert_equal 'Cool', user.firstname
assert_equal 'User', user.lastname
end
def test_login_with_openid_with_new_user_and_self_registration_off
Setting.self_registration = '0'
Setting.openid = '1'
post :login, :openid_url => 'http://openid.example.com/good_user'
assert_redirected_to home_url
user = User.find_by_login('cool_user')
assert ! user
end
def test_login_with_openid_with_new_user_created_with_email_activation_should_have_a_token
Setting.self_registration = '1'
Setting.openid = '1'
post :login, :openid_url => 'http://openid.example.com/good_user'
assert_redirected_to '/login'
user = User.find_by_login('cool_user')
assert user
token = Token.find_by_user_id_and_action(user.id, 'register')
assert token
end
def test_login_with_openid_with_new_user_created_with_manual_activation
Setting.self_registration = '2'
Setting.openid = '1'
post :login, :openid_url => 'http://openid.example.com/good_user'
assert_redirected_to '/login'
user = User.find_by_login('cool_user')
assert user
assert_equal User::STATUSES[:registered], user.status
end
def test_login_with_openid_with_new_user_with_conflict_should_register
Setting.self_registration = '3'
Setting.openid = '1'
existing_user = User.new(:firstname => 'Cool', :lastname => 'User', :mail => 'user@somedomain.com')
existing_user.login = 'cool_user'
assert existing_user.save!
post :login, :openid_url => 'http://openid.example.com/good_user'
assert_response :success
assert_template 'register'
assert assigns(:user)
assert_equal 'http://openid.example.com/good_user', assigns(:user)[:identity_url]
end
def test_setting_openid_should_return_true_when_set_to_true
Setting.openid = '1'
assert_equal true, Setting.openid?
end
else
puts "Skipping openid tests."
end
def test_logout
@request.session[:user_id] = 2
get :logout

@ -1,74 +0,0 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
# Mocks out OpenID
#
# http://www.northpub.com/articles/2007/04/02/testing-openid-support
module OpenIdAuthentication
EXTENSION_FIELDS = {'email' => 'user@somedomain.com',
'nickname' => 'cool_user',
'country' => 'US',
'postcode' => '12345',
'fullname' => 'Cool User',
'dob' => '1970-04-01',
'language' => 'en',
'timezone' => 'America/New_York'}
protected
def authenticate_with_open_id(identity_url = params[:openid_url], options = {}) #:doc:
if User.find_by_identity_url(identity_url) || identity_url.include?('good')
# Don't process registration fields unless it is requested.
unless identity_url.include?('blank') || (options[:required].nil? && options[:optional].nil?)
extension_response_fields = {}
options[:required].each do |field|
extension_response_fields[field.to_s] = EXTENSION_FIELDS[field.to_s]
end unless options[:required].nil?
options[:optional].each do |field|
extension_response_fields[field.to_s] = EXTENSION_FIELDS[field.to_s]
end unless options[:optional].nil?
end
yield Result[:successful], identity_url , extension_response_fields
else
logger.info "OpenID authentication failed: #{identity_url}"
yield Result[:failed], identity_url, nil
end
end
private
def add_simple_registration_fields(open_id_response, fields)
open_id_response.add_extension_arg('sreg', 'required', [ fields[:required] ].flatten * ',') if fields[:required]
open_id_response.add_extension_arg('sreg', 'optional', [ fields[:optional] ].flatten * ',') if fields[:optional]
end
end

@ -41,7 +41,6 @@ require 'fileutils'
require 'rspec/mocks'
require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
require Rails.root.join('test/mocks/open_id_authentication_mock.rb')
require File.expand_path(File.dirname(__FILE__) + '/object_daddy_helpers')
include ObjectDaddyHelpers

@ -555,39 +555,4 @@ class UserTest < ActiveSupport::TestCase
end
end
if Object.const_defined?(:OpenID)
def test_setting_identity_url
normalized_open_id_url = 'http://example.com/'
u = User.new( :identity_url => 'http://example.com/' )
assert_equal normalized_open_id_url, u.identity_url
end
def test_setting_identity_url_without_trailing_slash
normalized_open_id_url = 'http://example.com/'
u = User.new( :identity_url => 'http://example.com' )
assert_equal normalized_open_id_url, u.identity_url
end
def test_setting_identity_url_without_protocol
normalized_open_id_url = 'http://example.com/'
u = User.new( :identity_url => 'example.com' )
assert_equal normalized_open_id_url, u.identity_url
end
def test_setting_blank_identity_url
u = User.new( :identity_url => 'example.com' )
u.identity_url = ''
assert u.identity_url.blank?
end
def test_setting_invalid_identity_url
u = User.new( :identity_url => 'this is not an openid url' )
assert u.identity_url.blank?
end
else
puts "Skipping openid tests."
end
end

Loading…
Cancel
Save