##// END OF EJS Templates
Code cleanup: unverified request no longer raises a InvalidAuthenticityToken exception....
Jean-Philippe Lang -
r12037:05690057590a
parent child
Show More
@@ -1,615 +1,611
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require 'uri'
19 19 require 'cgi'
20 20
21 21 class Unauthorized < Exception; end
22 22
23 23 class ApplicationController < ActionController::Base
24 24 include Redmine::I18n
25 25 include Redmine::Pagination
26 26 include RoutesHelper
27 27 helper :routes
28 28
29 29 class_attribute :accept_api_auth_actions
30 30 class_attribute :accept_rss_auth_actions
31 31 class_attribute :model_object
32 32
33 33 layout 'base'
34 34
35 35 protect_from_forgery
36 36 def handle_unverified_request
37 37 super
38 38 cookies.delete(autologin_cookie_name)
39 if api_request?
40 logger.error "API calls must include a proper Content-type header (application/xml or application/json)."
41 end
42 render_error :status => 422, :message => "Invalid form authenticity token."
39 43 end
40 44
41 45 before_filter :session_expiration, :user_setup, :check_if_login_required, :check_password_change, :set_localization
42 46
43 rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
44 47 rescue_from ::Unauthorized, :with => :deny_access
45 48 rescue_from ::ActionView::MissingTemplate, :with => :missing_template
46 49
47 50 include Redmine::Search::Controller
48 51 include Redmine::MenuManager::MenuController
49 52 helper Redmine::MenuManager::MenuHelper
50 53
51 54 def session_expiration
52 55 if session[:user_id]
53 56 if session_expired? && !try_to_autologin
54 57 reset_session
55 58 flash[:error] = l(:error_session_expired)
56 59 redirect_to signin_url
57 60 else
58 61 session[:atime] = Time.now.utc.to_i
59 62 end
60 63 end
61 64 end
62 65
63 66 def session_expired?
64 67 if Setting.session_lifetime?
65 68 unless session[:ctime] && (Time.now.utc.to_i - session[:ctime].to_i <= Setting.session_lifetime.to_i * 60)
66 69 return true
67 70 end
68 71 end
69 72 if Setting.session_timeout?
70 73 unless session[:atime] && (Time.now.utc.to_i - session[:atime].to_i <= Setting.session_timeout.to_i * 60)
71 74 return true
72 75 end
73 76 end
74 77 false
75 78 end
76 79
77 80 def start_user_session(user)
78 81 session[:user_id] = user.id
79 82 session[:ctime] = Time.now.utc.to_i
80 83 session[:atime] = Time.now.utc.to_i
81 84 if user.must_change_password?
82 85 session[:pwd] = '1'
83 86 end
84 87 end
85 88
86 89 def user_setup
87 90 # Check the settings cache for each request
88 91 Setting.check_cache
89 92 # Find the current user
90 93 User.current = find_current_user
91 94 logger.info(" Current user: " + (User.current.logged? ? "#{User.current.login} (id=#{User.current.id})" : "anonymous")) if logger
92 95 end
93 96
94 97 # Returns the current user or nil if no user is logged in
95 98 # and starts a session if needed
96 99 def find_current_user
97 100 user = nil
98 101 unless api_request?
99 102 if session[:user_id]
100 103 # existing session
101 104 user = (User.active.find(session[:user_id]) rescue nil)
102 105 elsif autologin_user = try_to_autologin
103 106 user = autologin_user
104 107 elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth?
105 108 # RSS key authentication does not start a session
106 109 user = User.find_by_rss_key(params[:key])
107 110 end
108 111 end
109 112 if user.nil? && Setting.rest_api_enabled? && accept_api_auth?
110 113 if (key = api_key_from_request)
111 114 # Use API key
112 115 user = User.find_by_api_key(key)
113 116 else
114 117 # HTTP Basic, either username/password or API key/random
115 118 authenticate_with_http_basic do |username, password|
116 119 user = User.try_to_login(username, password) || User.find_by_api_key(username)
117 120 end
118 121 if user && user.must_change_password?
119 122 render_error :message => 'You must change your password', :status => 403
120 123 return
121 124 end
122 125 end
123 126 # Switch user if requested by an admin user
124 127 if user && user.admin? && (username = api_switch_user_from_request)
125 128 su = User.find_by_login(username)
126 129 if su && su.active?
127 130 logger.info(" User switched by: #{user.login} (id=#{user.id})") if logger
128 131 user = su
129 132 else
130 133 render_error :message => 'Invalid X-Redmine-Switch-User header', :status => 412
131 134 end
132 135 end
133 136 end
134 137 user
135 138 end
136 139
137 140 def autologin_cookie_name
138 141 Redmine::Configuration['autologin_cookie_name'].presence || 'autologin'
139 142 end
140 143
141 144 def try_to_autologin
142 145 if cookies[autologin_cookie_name] && Setting.autologin?
143 146 # auto-login feature starts a new session
144 147 user = User.try_to_autologin(cookies[autologin_cookie_name])
145 148 if user
146 149 reset_session
147 150 start_user_session(user)
148 151 end
149 152 user
150 153 end
151 154 end
152 155
153 156 # Sets the logged in user
154 157 def logged_user=(user)
155 158 reset_session
156 159 if user && user.is_a?(User)
157 160 User.current = user
158 161 start_user_session(user)
159 162 else
160 163 User.current = User.anonymous
161 164 end
162 165 end
163 166
164 167 # Logs out current user
165 168 def logout_user
166 169 if User.current.logged?
167 170 cookies.delete(autologin_cookie_name)
168 171 Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin'])
169 172 self.logged_user = nil
170 173 end
171 174 end
172 175
173 176 # check if login is globally required to access the application
174 177 def check_if_login_required
175 178 # no check needed if user is already logged in
176 179 return true if User.current.logged?
177 180 require_login if Setting.login_required?
178 181 end
179 182
180 183 def check_password_change
181 184 if session[:pwd]
182 185 if User.current.must_change_password?
183 186 redirect_to my_password_path
184 187 else
185 188 session.delete(:pwd)
186 189 end
187 190 end
188 191 end
189 192
190 193 def set_localization
191 194 lang = nil
192 195 if User.current.logged?
193 196 lang = find_language(User.current.language)
194 197 end
195 198 if lang.nil? && request.env['HTTP_ACCEPT_LANGUAGE']
196 199 accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first
197 200 if !accept_lang.blank?
198 201 accept_lang = accept_lang.downcase
199 202 lang = find_language(accept_lang) || find_language(accept_lang.split('-').first)
200 203 end
201 204 end
202 205 lang ||= Setting.default_language
203 206 set_language_if_valid(lang)
204 207 end
205 208
206 209 def require_login
207 210 if !User.current.logged?
208 211 # Extract only the basic url parameters on non-GET requests
209 212 if request.get?
210 213 url = url_for(params)
211 214 else
212 215 url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id])
213 216 end
214 217 respond_to do |format|
215 218 format.html {
216 219 if request.xhr?
217 220 head :unauthorized
218 221 else
219 222 redirect_to :controller => "account", :action => "login", :back_url => url
220 223 end
221 224 }
222 225 format.atom { redirect_to :controller => "account", :action => "login", :back_url => url }
223 226 format.xml { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
224 227 format.js { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
225 228 format.json { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
226 229 end
227 230 return false
228 231 end
229 232 true
230 233 end
231 234
232 235 def require_admin
233 236 return unless require_login
234 237 if !User.current.admin?
235 238 render_403
236 239 return false
237 240 end
238 241 true
239 242 end
240 243
241 244 def deny_access
242 245 User.current.logged? ? render_403 : require_login
243 246 end
244 247
245 248 # Authorize the user for the requested action
246 249 def authorize(ctrl = params[:controller], action = params[:action], global = false)
247 250 allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
248 251 if allowed
249 252 true
250 253 else
251 254 if @project && @project.archived?
252 255 render_403 :message => :notice_not_authorized_archived_project
253 256 else
254 257 deny_access
255 258 end
256 259 end
257 260 end
258 261
259 262 # Authorize the user for the requested action outside a project
260 263 def authorize_global(ctrl = params[:controller], action = params[:action], global = true)
261 264 authorize(ctrl, action, global)
262 265 end
263 266
264 267 # Find project of id params[:id]
265 268 def find_project
266 269 @project = Project.find(params[:id])
267 270 rescue ActiveRecord::RecordNotFound
268 271 render_404
269 272 end
270 273
271 274 # Find project of id params[:project_id]
272 275 def find_project_by_project_id
273 276 @project = Project.find(params[:project_id])
274 277 rescue ActiveRecord::RecordNotFound
275 278 render_404
276 279 end
277 280
278 281 # Find a project based on params[:project_id]
279 282 # TODO: some subclasses override this, see about merging their logic
280 283 def find_optional_project
281 284 @project = Project.find(params[:project_id]) unless params[:project_id].blank?
282 285 allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
283 286 allowed ? true : deny_access
284 287 rescue ActiveRecord::RecordNotFound
285 288 render_404
286 289 end
287 290
288 291 # Finds and sets @project based on @object.project
289 292 def find_project_from_association
290 293 render_404 unless @object.present?
291 294
292 295 @project = @object.project
293 296 end
294 297
295 298 def find_model_object
296 299 model = self.class.model_object
297 300 if model
298 301 @object = model.find(params[:id])
299 302 self.instance_variable_set('@' + controller_name.singularize, @object) if @object
300 303 end
301 304 rescue ActiveRecord::RecordNotFound
302 305 render_404
303 306 end
304 307
305 308 def self.model_object(model)
306 309 self.model_object = model
307 310 end
308 311
309 312 # Find the issue whose id is the :id parameter
310 313 # Raises a Unauthorized exception if the issue is not visible
311 314 def find_issue
312 315 # Issue.visible.find(...) can not be used to redirect user to the login form
313 316 # if the issue actually exists but requires authentication
314 317 @issue = Issue.find(params[:id])
315 318 raise Unauthorized unless @issue.visible?
316 319 @project = @issue.project
317 320 rescue ActiveRecord::RecordNotFound
318 321 render_404
319 322 end
320 323
321 324 # Find issues with a single :id param or :ids array param
322 325 # Raises a Unauthorized exception if one of the issues is not visible
323 326 def find_issues
324 327 @issues = Issue.where(:id => (params[:id] || params[:ids])).preload(:project, :status, :tracker, :priority, :author, :assigned_to, :relations_to).to_a
325 328 raise ActiveRecord::RecordNotFound if @issues.empty?
326 329 raise Unauthorized unless @issues.all?(&:visible?)
327 330 @projects = @issues.collect(&:project).compact.uniq
328 331 @project = @projects.first if @projects.size == 1
329 332 rescue ActiveRecord::RecordNotFound
330 333 render_404
331 334 end
332 335
333 336 def find_attachments
334 337 if (attachments = params[:attachments]).present?
335 338 att = attachments.values.collect do |attachment|
336 339 Attachment.find_by_token( attachment[:token] ) if attachment[:token].present?
337 340 end
338 341 att.compact!
339 342 end
340 343 @attachments = att || []
341 344 end
342 345
343 346 # make sure that the user is a member of the project (or admin) if project is private
344 347 # used as a before_filter for actions that do not require any particular permission on the project
345 348 def check_project_privacy
346 349 if @project && !@project.archived?
347 350 if @project.visible?
348 351 true
349 352 else
350 353 deny_access
351 354 end
352 355 else
353 356 @project = nil
354 357 render_404
355 358 false
356 359 end
357 360 end
358 361
359 362 def back_url
360 363 url = params[:back_url]
361 364 if url.nil? && referer = request.env['HTTP_REFERER']
362 365 url = CGI.unescape(referer.to_s)
363 366 end
364 367 url
365 368 end
366 369
367 370 def redirect_back_or_default(default)
368 371 back_url = params[:back_url].to_s
369 372 if back_url.present?
370 373 begin
371 374 uri = URI.parse(back_url)
372 375 # do not redirect user to another host or to the login or register page
373 376 if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)})
374 377 redirect_to(back_url)
375 378 return
376 379 end
377 380 rescue URI::InvalidURIError
378 381 logger.warn("Could not redirect to invalid URL #{back_url}")
379 382 # redirect to default
380 383 end
381 384 end
382 385 redirect_to default
383 386 false
384 387 end
385 388
386 389 # Redirects to the request referer if present, redirects to args or call block otherwise.
387 390 def redirect_to_referer_or(*args, &block)
388 391 redirect_to :back
389 392 rescue ::ActionController::RedirectBackError
390 393 if args.any?
391 394 redirect_to *args
392 395 elsif block_given?
393 396 block.call
394 397 else
395 398 raise "#redirect_to_referer_or takes arguments or a block"
396 399 end
397 400 end
398 401
399 402 def render_403(options={})
400 403 @project = nil
401 404 render_error({:message => :notice_not_authorized, :status => 403}.merge(options))
402 405 return false
403 406 end
404 407
405 408 def render_404(options={})
406 409 render_error({:message => :notice_file_not_found, :status => 404}.merge(options))
407 410 return false
408 411 end
409 412
410 413 # Renders an error response
411 414 def render_error(arg)
412 415 arg = {:message => arg} unless arg.is_a?(Hash)
413 416
414 417 @message = arg[:message]
415 418 @message = l(@message) if @message.is_a?(Symbol)
416 419 @status = arg[:status] || 500
417 420
418 421 respond_to do |format|
419 422 format.html {
420 423 render :template => 'common/error', :layout => use_layout, :status => @status
421 424 }
422 425 format.any { head @status }
423 426 end
424 427 end
425 428
426 429 # Handler for ActionView::MissingTemplate exception
427 430 def missing_template
428 431 logger.warn "Missing template, responding with 404"
429 432 @project = nil
430 433 render_404
431 434 end
432 435
433 436 # Filter for actions that provide an API response
434 437 # but have no HTML representation for non admin users
435 438 def require_admin_or_api_request
436 439 return true if api_request?
437 440 if User.current.admin?
438 441 true
439 442 elsif User.current.logged?
440 443 render_error(:status => 406)
441 444 else
442 445 deny_access
443 446 end
444 447 end
445 448
446 449 # Picks which layout to use based on the request
447 450 #
448 451 # @return [boolean, string] name of the layout to use or false for no layout
449 452 def use_layout
450 453 request.xhr? ? false : 'base'
451 454 end
452 455
453 def invalid_authenticity_token
454 if api_request?
455 logger.error "Form authenticity token is missing or is invalid. API calls must include a proper Content-type header (text/xml or text/json)."
456 end
457 render_error "Invalid form authenticity token."
458 end
459
460 456 def render_feed(items, options={})
461 457 @items = items || []
462 458 @items.sort! {|x,y| y.event_datetime <=> x.event_datetime }
463 459 @items = @items.slice(0, Setting.feeds_limit.to_i)
464 460 @title = options[:title] || Setting.app_title
465 461 render :template => "common/feed", :formats => [:atom], :layout => false,
466 462 :content_type => 'application/atom+xml'
467 463 end
468 464
469 465 def self.accept_rss_auth(*actions)
470 466 if actions.any?
471 467 self.accept_rss_auth_actions = actions
472 468 else
473 469 self.accept_rss_auth_actions || []
474 470 end
475 471 end
476 472
477 473 def accept_rss_auth?(action=action_name)
478 474 self.class.accept_rss_auth.include?(action.to_sym)
479 475 end
480 476
481 477 def self.accept_api_auth(*actions)
482 478 if actions.any?
483 479 self.accept_api_auth_actions = actions
484 480 else
485 481 self.accept_api_auth_actions || []
486 482 end
487 483 end
488 484
489 485 def accept_api_auth?(action=action_name)
490 486 self.class.accept_api_auth.include?(action.to_sym)
491 487 end
492 488
493 489 # Returns the number of objects that should be displayed
494 490 # on the paginated list
495 491 def per_page_option
496 492 per_page = nil
497 493 if params[:per_page] && Setting.per_page_options_array.include?(params[:per_page].to_s.to_i)
498 494 per_page = params[:per_page].to_s.to_i
499 495 session[:per_page] = per_page
500 496 elsif session[:per_page]
501 497 per_page = session[:per_page]
502 498 else
503 499 per_page = Setting.per_page_options_array.first || 25
504 500 end
505 501 per_page
506 502 end
507 503
508 504 # Returns offset and limit used to retrieve objects
509 505 # for an API response based on offset, limit and page parameters
510 506 def api_offset_and_limit(options=params)
511 507 if options[:offset].present?
512 508 offset = options[:offset].to_i
513 509 if offset < 0
514 510 offset = 0
515 511 end
516 512 end
517 513 limit = options[:limit].to_i
518 514 if limit < 1
519 515 limit = 25
520 516 elsif limit > 100
521 517 limit = 100
522 518 end
523 519 if offset.nil? && options[:page].present?
524 520 offset = (options[:page].to_i - 1) * limit
525 521 offset = 0 if offset < 0
526 522 end
527 523 offset ||= 0
528 524
529 525 [offset, limit]
530 526 end
531 527
532 528 # qvalues http header parser
533 529 # code taken from webrick
534 530 def parse_qvalues(value)
535 531 tmp = []
536 532 if value
537 533 parts = value.split(/,\s*/)
538 534 parts.each {|part|
539 535 if m = %r{^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$}.match(part)
540 536 val = m[1]
541 537 q = (m[2] or 1).to_f
542 538 tmp.push([val, q])
543 539 end
544 540 }
545 541 tmp = tmp.sort_by{|val, q| -q}
546 542 tmp.collect!{|val, q| val}
547 543 end
548 544 return tmp
549 545 rescue
550 546 nil
551 547 end
552 548
553 549 # Returns a string that can be used as filename value in Content-Disposition header
554 550 def filename_for_content_disposition(name)
555 551 request.env['HTTP_USER_AGENT'] =~ %r{MSIE} ? ERB::Util.url_encode(name) : name
556 552 end
557 553
558 554 def api_request?
559 555 %w(xml json).include? params[:format]
560 556 end
561 557
562 558 # Returns the API key present in the request
563 559 def api_key_from_request
564 560 if params[:key].present?
565 561 params[:key].to_s
566 562 elsif request.headers["X-Redmine-API-Key"].present?
567 563 request.headers["X-Redmine-API-Key"].to_s
568 564 end
569 565 end
570 566
571 567 # Returns the API 'switch user' value if present
572 568 def api_switch_user_from_request
573 569 request.headers["X-Redmine-Switch-User"].to_s.presence
574 570 end
575 571
576 572 # Renders a warning flash if obj has unsaved attachments
577 573 def render_attachment_warning_if_needed(obj)
578 574 flash[:warning] = l(:warning_attachments_not_saved, obj.unsaved_attachments.size) if obj.unsaved_attachments.present?
579 575 end
580 576
581 577 # Rescues an invalid query statement. Just in case...
582 578 def query_statement_invalid(exception)
583 579 logger.error "Query::StatementInvalid: #{exception.message}" if logger
584 580 session.delete(:query)
585 581 sort_clear if respond_to?(:sort_clear)
586 582 render_error "An error occurred while executing the query and has been logged. Please report this error to your Redmine administrator."
587 583 end
588 584
589 585 # Renders a 200 response for successfull updates or deletions via the API
590 586 def render_api_ok
591 587 render_api_head :ok
592 588 end
593 589
594 590 # Renders a head API response
595 591 def render_api_head(status)
596 592 # #head would return a response body with one space
597 593 render :text => '', :status => status, :layout => nil
598 594 end
599 595
600 596 # Renders API response on validation failure
601 597 def render_validation_errors(objects)
602 598 if objects.is_a?(Array)
603 599 @error_messages = objects.map {|object| object.errors.full_messages}.flatten
604 600 else
605 601 @error_messages = objects.errors.full_messages
606 602 end
607 603 render :template => 'common/error_messages.api', :status => :unprocessable_entity, :layout => nil
608 604 end
609 605
610 606 # Overrides #_include_layout? so that #render with no arguments
611 607 # doesn't use the layout for api requests
612 608 def _include_layout?(*args)
613 609 api_request? ? false : super
614 610 end
615 611 end
@@ -1,70 +1,79
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class ApplicationTest < ActionController::IntegrationTest
21 21 include Redmine::I18n
22 22
23 23 fixtures :projects, :trackers, :issue_statuses, :issues,
24 24 :enumerations, :users, :issue_categories,
25 25 :projects_trackers,
26 26 :roles,
27 27 :member_roles,
28 28 :members,
29 29 :enabled_modules
30 30
31 31 def test_set_localization
32 32 Setting.default_language = 'en'
33 33
34 34 # a french user
35 35 get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
36 36 assert_response :success
37 37 assert_tag :tag => 'h2', :content => 'Projets'
38 38 assert_equal :fr, current_language
39 39 assert_select "html[lang=?]", "fr"
40 40
41 41 # then an italien user
42 42 get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'it;q=0.8,en-us;q=0.5,en;q=0.3'
43 43 assert_response :success
44 44 assert_tag :tag => 'h2', :content => 'Progetti'
45 45 assert_equal :it, current_language
46 46 assert_select "html[lang=?]", "it"
47 47
48 48 # not a supported language: default language should be used
49 49 get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'zz'
50 50 assert_response :success
51 51 assert_tag :tag => 'h2', :content => 'Projects'
52 52 assert_select "html[lang=?]", "en"
53 53 end
54 54
55 55 def test_token_based_access_should_not_start_session
56 56 # issue of a private project
57 57 get 'issues/4.atom'
58 58 assert_response 302
59 59
60 60 rss_key = User.find(2).rss_key
61 61 get "issues/4.atom?key=#{rss_key}"
62 62 assert_response 200
63 63 assert_nil session[:user_id]
64 64 end
65 65
66 66 def test_missing_template_should_respond_with_404
67 67 get '/login.png'
68 68 assert_response 404
69 69 end
70
71 def test_invalid_token_should_call_custom_handler
72 ActionController::Base.allow_forgery_protection = true
73 post '/issues'
74 assert_response 422
75 assert_include "Invalid form authenticity token.", response.body
76 ensure
77 ActionController::Base.allow_forgery_protection = false
78 end
70 79 end
General Comments 0
You need to be logged in to leave comments. Login now