WebTestCase('Join with XSS attack'); } 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'].""); // Catched by looking at details $this->setField('mname', $user['2']['details']['mname'].""); // ... $this->setField('lname', $user['2']['details']['lname'].""); $this->setField('suffix', $user['2']['details']['suffix'].""); $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('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('day', $user['2']['dob']['day']); // filtered by intval() $this->setField('month', $user['2']['dob']['month']); // filtered by intval() $this->setField('year', $user['2']['dob']['year']); // filtered by intval() $this->setField('email', $user['2']['username'].""); // Catched by failing login $this->setField('pword1', $user['2']['password']); // untouched $this->setField('pword2', $user['2']['password']); // untouched $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. Subscription failed? XSS possible in email address?"); $this->get('https://'.BASE_URL.'/account.php?id=13'); $this->assertNoPattern('//', "XSS possible! Our test string wasn't removed from one of the user fields"); // logout again $this->clickLink('Logout'); // Logout again $this->assertText('Normal Login', "Can't logout. Did login fail?"); } } ?>