ruby - How to test protect_from_forgery with: :exception rails -
i using protect_from_forgery with: :exception
in application. seems work fine want test it.
i have form. understand every form has authenticity token related while using protect_from_forgery
, want create situation when authenticity token not pass , throws exception. want see how browser respond exception.
how able that?
several ways this:
the authenticity token part of form data: edit page alter / remove these , form submission should result in exception. ajax submitted forms can csrf meta tags in
head
portion of page - may wish alter these to.create standalone html page (outside of app) contains form posting action want test
the authenticity token stored in session, after form has been displayed hit url in browser tab / session calls
reset_session
. submit form - should fail.
Comments
Post a Comment