aspose file tools*
The moose likes Testing and the fly likes Authentication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Authentication " Watch "Authentication " New topic
Author

Authentication

Pen Pentela
Greenhorn

Joined: May 15, 2008
Posts: 8
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
Marshal

Joined: Mar 22, 2005
Posts: 41524
    
  53
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.


Ping & DNS - my free Android networking tools app
Pen Pentela
Greenhorn

Joined: May 15, 2008
Posts: 8
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
Marshal

Joined: Mar 22, 2005
Posts: 41524
    
  53
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

Joined: Jul 11, 2001
Posts: 14112
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?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30309
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Pen Pentela
Greenhorn

Joined: May 15, 2008
Posts: 8
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 .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Authentication