cancel
Showing results for 
Search instead for 
Did you mean: 

Testing for login failure

SOLVED
skyhigh
Contributor

Testing for login failure

Hi,

 

I'm new to both SOAP testing and SmartBear test tools.  Right now I'm creating the failure test case for login.  The test case uses "Get" API that has parmaters username and password.  For the test case assertion, I use "JSONPath Expression" and the expression is $['IsSuccessful'].  If login is good then the expected result is "true".  However I would like to validate for the failure password so if  the login fails, it should return false as expected result.  so after I put "false" as the expected value and the password parameter I just use random text.  But after I execute the test suite, that test case results as fail instead of pass.  What did I do wrong?  thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
PaulMS
Super Contributor

Re: Testing for login failure

 

200 OK is a standard status code for successful HTTP requests. Content-Length: 0 indicates that no JSON data was in the response so likely to be a problem with the service not the test step or assertion.

View solution in original post

15 REPLIES 15
nmrao
Community Hero

Re: Testing for login failure

Can you please show the json?


Regards,
Rao.
skyhigh
Contributor

Re: Testing for login failure

Great! thank you for responding to my question.

 

Not sure if JSON below is what you're asking for.  But this is JSON data from the Response section.

{
"ErrorMessage": "",
"IsSuccessful": true,
"Data": null,
"IsRedirect": false,
"RedirectUrl": ""
}

 

Please note the JSON above, I took it from other login test case that passes the test run.  As for the test case that I'm asking for help to test the login failure, it does not have JSON data under Response section.

 

thanks 

nmrao
Community Hero

Re: Testing for login failure

@skyhigh, do you get the similar response with "IsSuccessful": false on login failure? And that is expected?


Regards,
Rao.
skyhigh
Contributor

Re: Testing for login failure

unfortunately when running the test for the login failure test case, there is no JSON data in Response section so I don't know whether "IsSuccessful" is "true" or "false".

 

Could this mean the login API of that service does not return back as "false" when login fails?

skyhigh
Contributor

Re: Testing for login failure

This is my assertion to check the login should fail and API login should return back as false:

   JSONPath Expression:

      $['IsSuccessful']

 

   Expected Result:

      false

 

Below is the error message appears after running the test case above with Ready! API SoapUI NG pro.

 

-> Assertion failed.  Path [$['IsSuccessful']]: AssertionException:Assertion failed.  Path[$['IsSuccessful']]: illegalArgumentException:Invalid JSON: null..

 

 

PaulMS
Super Contributor

Re: Testing for login failure

Yes it seems that the service does not return JSON data as expected when login fails.

Can you check if the Raw tab in the response shows an invalid status code?

skyhigh
Contributor

Re: Testing for login failure

Hi Paul,

Below is all the Raw data under Response section.  

Please notes I replace some characters with pound signs just for privacy reasons.

 

HTTP/1.1 200 OK
Set-Cookie: ######2PP=###########; path=/; expires=Tue, 01-Aug-2017 00:18:17 GMT
Cache-Control: public, no-cache="Set-Cookie", no-store, max-age=0
Content-Type: text/html
Expires: Mon, 31 Jul 2017 22:58:04 GMT
Last-Modified: Mon, 31 Jul 2017 22:58:04 GMT
Vary: *
Server: Microsoft-IIS/8.5
X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
Set-Cookie: culture=en-US; expires=Tue, 31-Jul-2018 22:58:04 GMT; path=/
X-Powered-By: ASP.NET
SiteCreator: {########-####-####-####-############}
Date: Mon, 31 Jul 2017 22:58:04 GMT
Content-Length: 0

 

When I look at the Raw data of other login test case that uses valid login(username and password), it has "Content-Length: 87" and extra line like the below.

{"ErrorMessage":"","IsSuccessful":true,"Data":null,"IsRedirect":false,"RedirectUrl":""}

 

PaulMS
Super Contributor

Re: Testing for login failure

 

200 OK is a standard status code for successful HTTP requests. Content-Length: 0 indicates that no JSON data was in the response so likely to be a problem with the service not the test step or assertion.

View solution in original post

skyhigh
Contributor

Re: Testing for login failure

That's great thanks!. I will check with the developers of the app.

 

Another quick question. How can I add Cookie in the Resquest section when sending the request?

For example like this:
Cookie: ######2PP=###########; culture=en-US

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors