Tatva-Artha

meaning of "it"

Login as multiple users simultaneously for testing

without comments

Ever wondered how to login as two different users at the same time? The situation manifests in any project where you want to be able to test a workflow involving several actors with different roles. The problem is that browsers allow only one login for a given domain at any one time. So, you are required to logout as current_user before logging in as another. One of the solution people use is install multiple browsers.

Solution: Multiple Browsers

So, lets say your favorite browser is firefox. And you also have IE7 installed by default on your windows machine. And you have a google chrome installed just so you can try out the new and blazing contribution by google. Most developers, I assume, more than a single browser installed on their system. Given this, you can login as different user in each browser.

This works but here is another solution that, as you will quickly realize, is better.

Solution: Multiple names for your “localhost”

Just update your /etc/hosts file to add more names for your local machine. Lets take a concrete example:

So, on a project, realted to mortgage industry, I have several actors like borrower, realtor, loan officer, mortgage-broker. I updated my /etc/hosts file (on linux) from this line:

127.0.0.1 localhost

to this:

127.0.0.1 localhost r lo mb b

With this above line, I can access my local application using following URLs:

http://r:3000 (for realtor)
http://lo:3000 (for loan officer)
http://b:3000 (for borrower)
http://mb:3000 (for mortage broker)

Now, I can open 4 tabs in a browser each with different URL and login as different users. Coupled this with password saving feature of browser, I don’t even have to type username/password for each user as long as I am disciplined about not cross-logging in as realtor inside borrower url (b:3000). Go ahead, leave yourself logged in and never logout!

This simple trick is better than multiple browser solution since it doesn’t require as many browser and you can have as many unique URLs as you want. And you are not limited to using this trick for local testing. If you have a staging server at http://staging.project.com that resolves to an IP, say, 192.1.2.3, you can repeat the same process:

# my /etc/hosts file
127.0.0.1 localhost r lo mb b
192.1.2.3 staging.project.com sr slo smb sb
# Now I can
# http://sr (staging realtor)
# http://slo (staging loan officer)
# you get the drill ...

There you go. Happy testing!

http://www.tatvartha.com/wp-content/plugins/sociofluid/images/digg_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/reddit_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/stumbleupon_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/delicious_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/google_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/twitter_16.png

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Written by Sharad

May 26th, 2010 at 8:40 pm

Posted in Technology

Leave a Reply