Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Authentication

 
Pen Pentela
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We are maintaing list of usernames and passwords for my application, I need to write Http Unit testcases for login page.

how do i write , help me

Regards,
pp
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A login page is an HTML form like any other, so you'd write a test case for it like you'd do with any HTML form page. Or does the problem have to do wtih retrieving usernames/passwords? If so, tell us in more detail what you have so far, and where you're stuck making progress.
 
Pen Pentela
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
A login page is an HTML form like any other, so you'd write a test case for it like you'd do with any HTML form page. Or does the problem have to do wtih retrieving usernames/passwords? If so, tell us in more detail what you have so far, and where you're stuck making progress.



My code is below

WebConversation wc = new WebConversation();
WebResponse wr = wc.getResponse(URL);
WebForm[] form = wr.getForms();
form[0].setParameter("userName","administartor");
form[0].setParameter("pass","password");
WebResponse rs1 = form[0].submit();
assertEquals("Page Title","Menu",rs1.getTitle());

this is static working properly. Here I checked with only one username administrator, but we are having multiple usernames , to check multiple usenames with respective passwords how do i write , please suggest me ,

Best Regards,
PP
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be uncommon to test with more than one user. If one particular user can log in with a valid password, then so should all other ones.

One other test I'd add is to check the login with a non-admin user, and to make sure that he gets a different page (or one that's missing whatever additional options an admin sees).
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
It would be uncommon to test with more than one user. If one particular user can log in with a valid password, then so should all other ones.


To reformulate that into a question: why do you want to test with several user names? What problems might testing with several user names uncover that testing with just one name will not?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with the above posters that there is no point in testing multiple users unless something is different. Such as having different roles/levels of access.

To do that you would logout (or better yet, create a new test and web conversation) and test with the next user.
 
Pen Pentela
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
I agree with the above posters that there is no point in testing multiple users unless something is different. Such as having different roles/levels of access.

To do that you would logout (or better yet, create a new test and web conversation) and test with the next user.


We are having multiple users with different roles .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic