enable_sudo_mode_after_pwd_based_login_fixed.diff

fixed patch - Jens Krämer, 2015-10-01 07:33

Download (2.58 KB)

View differences:

app/controllers/account_controller.rb
201 201
      # Valid user
202 202
      if user.active?
203 203
        successful_authentication(user)
204
        update_sudo_timestamp! # activate Sudo Mode
204 205
      else
205 206
        handle_inactive_user(user)
206 207
      end
test/integration/sudo_mode_test.rb
7 7
    Redmine::SudoMode.stubs(:enabled?).returns(true)
8 8
  end
9 9

  
10
  def test_sudo_mode_should_be_active_after_login
11
    log_user("admin", "admin")
12
    get "/users/new"
13
    assert_response :success
14
    post "/users",
15
         :user => { :login => "psmith", :firstname => "Paul",
16
                    :lastname => "Smith", :mail => "psmith@somenet.foo",
17
                    :language => "en", :password => "psmith09",
18
                    :password_confirmation => "psmith09" }
19
    assert_response 302
20

  
21
    user = User.find_by_login("psmith")
22
    assert_kind_of User, user
23
  end
24

  
10 25
  def test_add_user
11 26
    log_user("admin", "admin")
27
    expire_sudo_mode!
12 28
    get "/users/new"
13 29
    assert_response :success
14 30
    post "/users",
......
36 52

  
37 53
  def test_create_member_xhr
38 54
    log_user 'admin', 'admin'
55
    expire_sudo_mode!
39 56
    get '/projects/ecookbook/settings/members'
40 57
    assert_response :success
41 58

  
......
59 76

  
60 77
  def test_create_member
61 78
    log_user 'admin', 'admin'
79
    expire_sudo_mode!
62 80
    get '/projects/ecookbook/settings/members'
63 81
    assert_response :success
64 82

  
......
84 102

  
85 103
  def test_create_role
86 104
    log_user 'admin', 'admin'
105
    expire_sudo_mode!
87 106
    get '/roles'
88 107
    assert_response :success
89 108

  
......
118 137

  
119 138
  def test_update_email_address
120 139
    log_user 'jsmith', 'jsmith'
140
    expire_sudo_mode!
121 141
    get '/my/account'
122 142
    assert_response :success
123 143
    post '/my/account', user: { mail: 'newmail@test.com' }
......
161 181
      end
162 182
    end
163 183
  end
184

  
185
  private
186

  
187
  # sudo mode is active after sign, let it expire by advancing the time
188
  def expire_sudo_mode!
189
    travel_to 20.minutes.from_now
190
  end
164 191
end