I am using devise gem for authentication and I need to test the log-in failure test when a user gives wrong password and I am using factories too. Can anyone help me in writing this?
Thanks in advance.
see this to get started with testing:
http://www.hiringthing.com/2012/08/17/rails-testing-factory-girl.html
and
http://railscasts.com/episodes/158-factories-not-fixtures
Related
I'm trying to build a SSO system where a bunch of Rails 4 apps under different subdomains share a common cookie. I've got 4 apps doing authentication via the sorcery gem and 2 apps using ActiveAdmin and Devise.
The 4 apps using Sorcery are working as expected, I can get a successfully signed on user to access all 4 different apps using the same session cookie.
I'm having trouble with the 2 Devise/ActiveAdmin apps. I added a custom Warden authentication strategy and configured Devise to use it. But I don't think the strategy is being used because I continue to get 401 unauthorized errors and any puts statements/logging in the authenticate! method below is never seen. Anyone with previous experience doing this? Or maybe some help tracing through where the authentication steps are happening so I can try to add some logging?
Warden::Strategies.add(:gc_auth) do
def valid?
true
end
def authenticate!
user = AdminUser.find_by_uuid(session[:user_uuid])
user ? success!(user) : fail!("Not signed in")
end
end
config.warden do |manager|
manager.default_strategies.unshift :gc_auth
end
Was able to get this to work by examining how this gem is structured:
https://github.com/AMekss/devise_custom_authenticatable
I'm trying to do functional test but I don't know how to deal with cookies.
I'm using Ruby and Minitest to do functional test of controllers.
But to run tests in controllers, first I need to authenticate.
The authentication uses cookies to see if the user is logged or not.
The problem is functional tests do not see what is in cookies, than I can't authenticate and then run tests. Does someone give me a tip to resolve this?
thanks
Heber
I'm looking at the same issue, myself. Being somewhat new at this, I'm not actually sure this will work, but I intend to try using the before do hook to run an authentication.
Something to this effect:
before do
get :login
# fill in and submit
end
it "must do stuff" do
#Test things and hopefully it'll be logged in
end
I have a webpage in a Liferay 5.2.3 site, in order to view this page the user shoulde be logged in.
i tried JMeter for stress testing but i stopped after i had this issue here ("invalid authentication token"). What other tool i could use to do stress test without facing the authentication issue (with example of script if its available).
I had the same problem. I managed to log in and then when sending POST requests to the server I only received 403. What I have done is that I set the auth.token.check.enabled to false in the portal-ext.properties.
auth.token.check.enabled=false
But be careful. The Portal Authentication Token was implemented to prevent Cross Site Request forgery, as explained here: https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF).
On a production environment set the property back to true.
More about that on the liferay site: http://www.liferay.com/community/wiki/-/wiki/Main/Authentication+Token
Well I'm not sure but you could try Grinder, it supports jython as scripting language, although i dont have a working script example at the moment.
You can use JMeter but you have to use its proxy to record your actions (login included).
Please see JMeter proxy step by step
I am creating request specs following the Railscast at http://railscasts.com/episodes/257-request-specs-and-capybara
In my application, users sign in using their Google OpenID accounts with OmniAuth (http://railscasts.com/episodes/241-simple-omniauth). How can I test this with RSpec and Capybara? When my application redirects to the Google sign in page, I get the following error:
ActionController::RoutingError:
No route matches "/accounts/o8/ud"
It seems that it doesn't allow redirecting away from the application, so how should I test this?
I have no experience with Capybara and can therefore not comment on your question, however, I have saved a bookmark for later usage that may be useful to you: http://blog.zerosum.org/2011/03/19/easy-rails-outh-integration-testing.html
I have a webservice -somewhere- to validate passwords and stuff, and a module using SAVON that makes the corresponding questions in order to verify someone. The thing is, I don't have the login to work with my module. I was trying to use DEVISE to work with it, but I can't figure out how to do it yet.
Does anybody know a good gem that can work and take advantage of SAVON in order to make login validations?
I don't know of any gem that works with SAVON but you can use find_for_database_authentication of Devise
def self.find_for_database_authentication(conditions)
where('users.rut = ?', conditions[:rut]).first
end
For more detail, see RoR Devise: Sign in with username OR email