@@ -75,9 +75,7 class AdminController < ApplicationController | |||
|
75 | 75 | def info |
|
76 | 76 | @db_adapter_name = ActiveRecord::Base.connection.adapter_name |
|
77 | 77 | @checklist = [ |
|
78 | [:text_default_administrator_account_changed, | |
|
79 | User.find(:first, | |
|
80 | :conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?], | |
|
78 | [:text_default_administrator_account_changed, User.default_admin_account_changed?], | |
|
81 | 79 | [:text_file_repository_writable, File.writable?(Attachment.storage_path)], |
|
82 | 80 | [:text_plugin_assets_writable, File.writable?(Redmine::Plugin.public_directory)], |
|
83 | 81 | [:text_rmagick_available, Object.const_defined?(:Magick)] |
@@ -348,6 +348,11 class User < Principal | |||
|
348 | 348 | find(:first, :conditions => ["LOWER(mail) = ?", mail.to_s.downcase]) |
|
349 | 349 | end |
|
350 | 350 | |
|
351 | # Returns true if the default admin account can no longer be used | |
|
352 | def self.default_admin_account_changed? | |
|
353 | !User.active.find_by_login("admin").try(:check_password?, "admin") | |
|
354 | end | |
|
355 | ||
|
351 | 356 | def to_s |
|
352 | 357 | name |
|
353 | 358 | end |
@@ -630,6 +630,38 class UserTest < ActiveSupport::TestCase | |||
|
630 | 630 | end |
|
631 | 631 | end |
|
632 | 632 | |
|
633 | def test_default_admin_account_changed_should_return_false_if_account_was_not_changed | |
|
634 | user = User.find_by_login("admin") | |
|
635 | user.password = "admin" | |
|
636 | user.save! | |
|
637 | ||
|
638 | assert_equal false, User.default_admin_account_changed? | |
|
639 | end | |
|
640 | ||
|
641 | def test_default_admin_account_changed_should_return_true_if_password_was_changed | |
|
642 | user = User.find_by_login("admin") | |
|
643 | user.password = "newpassword" | |
|
644 | user.save! | |
|
645 | ||
|
646 | assert_equal true, User.default_admin_account_changed? | |
|
647 | end | |
|
648 | ||
|
649 | def test_default_admin_account_changed_should_return_true_if_account_is_disabled | |
|
650 | user = User.find_by_login("admin") | |
|
651 | user.password = "admin" | |
|
652 | user.status = User::STATUS_LOCKED | |
|
653 | user.save! | |
|
654 | ||
|
655 | assert_equal true, User.default_admin_account_changed? | |
|
656 | end | |
|
657 | ||
|
658 | def test_default_admin_account_changed_should_return_true_if_account_does_not_exist | |
|
659 | user = User.find_by_login("admin") | |
|
660 | user.destroy | |
|
661 | ||
|
662 | assert_equal true, User.default_admin_account_changed? | |
|
663 | end | |
|
664 | ||
|
633 | 665 | def test_roles_for_project |
|
634 | 666 | # user with a role |
|
635 | 667 | roles = @jsmith.roles_for_project(Project.find(1)) |
General Comments 0
You need to be logged in to leave comments.
Login now