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
Related
Currently when creating a customer during an e2e testcase, my stripe-like payment gateway says "Customer already exists" which is true because this testcase has been run once already.
What is the high level solution? If it would be a unit test, I think mocking the payment-provider request would be the way to go. But in this case I can only intercept the requests that go from my frontend, right? I could mock away the whole request to my backend but that's not the point of e2e testing I think.
I also thought about some sort of flag or environment variable so that the backend knows if it's currently e2e tested (and in this case behave differently, eg not make this specific request). But I think that's not good practice.
Okay I figured out something. I think e2e should test the integrated services too, like the integration between my backend and the payment gateway.
When the test starts, I modify the email (which was the duplicate key for the payment provider) by doing the following little code snippet. Works for now and I think it's not that bad:
user.email = user.email.split("#").join(`${Date.now()}#`);
I'd like to run functional tests on a section of my website which requires authentication. I found a solution for Symfony 2.x here. However, this does not work for Symfony3 as this line is now deprecated:
self::$kernel->getContainer()->get('security.context')->setToken($token);
My question is, how do I go around this and make it work with Symfony3? Thank you.
In Symfony 3, the SecurityContext was split into the TokenStorage and the AuthorizationChecker. Thus, you need to use the security.token_storage service:
self::$kernel->getContainer()->get('security.token_storage')->setToken($token);
However, a simpler approach would be to switch to HTTP Basic auth in your tests and configure the logged in user as described in http://symfony.com/doc/current/cookbook/testing/http_authentication.html.
Just started using the Robot Framework to test our application and I really like it so far. The option to combine it with Selenium, Appium and Locust.io in the end sounds appealing. Anyhow, I have a basic question:
I'm trying to log the cookies from a browser session to the console. Selenium2Library provides the keyword:
Get Cookies
Then I try in my test case:
Log Cookies To Console
${cookies}= Get Cookies
Log To Console ${cookies}
This doesn't seem to give me anything in the console.
Are you 100% sure there is an cookie anyway?
What I would do it :
try with another URL on which you know there actually is a cookie (www.google.com?)
try to add a cookie (keyword: add cookie) just before you log, so that you can see, at least, that the one you add is displayed
That could help you find out the source of your problem.
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
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