WebTestCase('Join CAcert'); } function testNewUser() { global $user; // Open website $this->get('http://' . BASE_URL); $this->assertText('Login'); $this->clickLink('Join'); $this->assertField("fname"); // Fill in half of the form $this->setField('fname', $user['2']['details']['fname']); $this->setField('mname', $user['2']['details']['mname']); $this->setField('lname', $user['2']['details']['lname']); $this->setField('suffix', $user['2']['details']['suffix']); $this->clickSubmit('Next'); $this->assertText('The Pass Phrase you submitted failed to contain enough differing', "Missing pass phrase not detected"); // add password $this->setField('pword1', $user['2']['password']); $this->setField('pword2', $user['2']['password']); $this->clickSubmit('Next'); $this->assertText('For your own security you must enter 5 lost password questions' , "Missing lost password questions not detected"); $this->assertText('Invalid date of birth', "Invalid date of birth not detected"); $this->assertText('Email Address was blank', "Blank email address not detected"); // everything but Q4/A4 Q5/A5, bad DOB $this->setField('email', $user['2']['username']); $this->setField('day', $user['2']['dob']['day']); $this->setField('month', $user['2']['dob']['month']); $this->setField('year', $user['2']['dob']['year']-500); $this->setField('Q1', $user['2']['lostpw']['questions']['1']); $this->setField('A1', $user['2']['lostpw']['answers']['1']); $this->setField('Q2', $user['2']['lostpw']['questions']['2']); $this->setField('A2', $user['2']['lostpw']['answers']['2']); $this->setField('Q3', $user['2']['lostpw']['questions']['3']); $this->setField('A3', $user['2']['lostpw']['answers']['3']); $this->setField('pword1', $user['2']['password']); $this->setField('pword2', $user['2']['password']); $this->clickSubmit('Next'); $this->assertText('For your own security you must enter 5 lost password questions', "Missing lost password questions not detected"); $this->assertText('Invalid date of birth', "Invalid date of birth not detected"); // bad password $this->setField('day', $user['2']['dob']['day']); $this->setField('month', $user['2']['dob']['month']); $this->setField('year', $user['2']['dob']['year']); $this->setField('pword1', "abcd"); $this->setField('pword2', "abcd"); $this->clickSubmit('Next'); $this->assertText('The Pass Phrase you submitted failed to contain enough differing', "Simple password abc accepted"); // mismatching password $this->setField('pword1', $user['2']['password']); $this->setField('pword2', strrev($user['2']['password'])); $this->clickSubmit('Next'); $this->assertText('Pass Phrases don', "Passwords do not match not detected"); // good passwords but still missing lost password questions 4 and 5 $this->setField('pword1', $user['2']['password']); $this->setField('pword2', $user['2']['password']); $this->clickSubmit('Next'); $this->assertText('must enter 5 lost password questions', "Missing lost password questions/answers 4 and 5 not detected"); // Use email that is already in the database $this->setField('email', $user['1']['username']); $this->setField('Q4', $user['2']['lostpw']['questions']['4']); $this->setField('A4', $user['2']['lostpw']['answers']['4']); $this->setField('Q5', $user['2']['lostpw']['questions']['5']); $this->setField('A5', $user['2']['lostpw']['answers']['5']); $this->setField('pword1', $user['2']['password']); $this->setField('pword2', $user['2']['password']); $this->clickSubmit('Next'); $this->assertText('This email address is currently valid in the system.', "Accepted email that should have been in the database already"); // now everything should be OK $this->setField('email', $user['2']['username']); $this->setField('pword1', $user['2']['password']); $this->setField('pword2', $user['2']['password']); $this->clickSubmit('Next'); $this->assertText('information has been submitted', "Subscription not accepted"); // sleep 5 seconds for the email to be processed sleep(5); // Try to login now $this->clickLink('Normal Login'); $this->setField('email', $user['2']['username']); $this->setField('pword', $user['2']['password']); $this->clickSubmit('Login'); $this->assertText('Logout', "Can't login. Did subscription fail?"); // logout again $this->clickLink('Logout'); // Logout again $this->assertText('Normal Login', "Can't logout. Did login fail?"); } } ?>