Quick Users
I don't think I've said it publically yet, so a little heads up, I've gotten my first contract as "Three Planets Software". Rather (I hope) easy site in PHP/MySQL and some other goodness, but you'll hear more about that later when I put out a call for Beta testers. So I coded up all the login and registration pages two days ago, and now am working on some other fun stuff. Some fun stuff that required more than one user to test. Ideally, more than 10. I did *not* want to sit in phpmyadmin creating 20 dummy users that would only be used in testing, so I turned to perl.
Real simply, I used WWW::Mechanize to interface with my registration page (as I knew that worked already) and I wanted to prove it could handle a bunch of attention.
My registration page right now asks for first name, last name, an email, and a password. I needed data to through into those fields so a quick google search turned up this fine document. I decided I'd use the nickname as a first name, and the real name as a last name. The password would be the first name concatenated with "1". This'll provide some overlap, along with unique passwords, and a password scheme I could easily figure out looking at hashed passwords in my database.
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
open(NAMES, "$ARGV[0]");
while($_ =
if(/^#.*/) {
} else {
m/^(\S*)\s*(\S*)\s*/;
$firstname = $1;
$lastname = $2;
$password = "$firstname";
$email = $firstname."@".$lastname.".com";
$mech->get("http://192.168.1.3/o2h/www/register.php") or die "Can't load page!\n";
$mech->form(1);
print "Registering $firstname $lastname!\n";
print $mech->set_visible("$firstname", "$lastname", "$email", "$password", "$password");
$result = $mech->click_button(number=>1);
}
}
close(NAMES);
This is a whopping 17 lines, took 10ish minutes to write. Yes, it could get smaller, but I wanted it somewhat readable. In about 10s of running I had 537 new additions to my users to test with, yippee!
This can easily be adapted for any website (that doesn't use CAPTCHAS and asks for information of the same nature as mine), feel free to steal it.