Skip to content

Commit

Permalink
Fixed bug when changing passwords; Fixed template locations; Added ch…
Browse files Browse the repository at this point in the history
…ange password tests
  • Loading branch information
ginatrapani committed Apr 10, 2010
1 parent fb74d29 commit b672d88
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 345 deletions.
109 changes: 108 additions & 1 deletion tests/frontend_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,115 @@ function testSignInAndPrivateDashboard() {
$this->assertTitle('ThinkTank');
$this->assertText('Logged in as: me@example.com');

//TODO Test Export link here
/*
* $this->click("Export");
$this->assertTitle('');
$this->assertText('This is post');
*/
}

function testChangePasswordSuccess() {
global $TEST_SERVER_DOMAIN;

$this->get($TEST_SERVER_DOMAIN.'/session/login.php');
$this->setField('email', 'me@example.com');
$this->setField('pwd', 'secretpassword');

$this->click("Log In");
$this->assertTitle('ThinkTank');
$this->assertText('Logged in as: me@example.com');

$this->click("Configuration");
$this->assertText('Your ThinkTank Password');
$this->setField('oldpass', 'secretpassword');
$this->setField('pass1', 'secretpassword1');
$this->setField('pass2', 'secretpassword1');
$this->click('Change password');
$this->assertText('Your password has been updated.');

}

function testChangePasswordWrongExistingPassword() {
global $TEST_SERVER_DOMAIN;

$this->get($TEST_SERVER_DOMAIN.'/session/login.php');
$this->setField('email', 'me@example.com');
$this->setField('pwd', 'secretpassword');

$this->click("Log In");
$this->assertTitle('ThinkTank');
$this->assertText('Logged in as: me@example.com');

$this->click("Configuration");
$this->assertText('Your ThinkTank Password');
$this->setField('oldpass', 'secretpassworddd');
$this->setField('pass1', 'secretpassword1');
$this->setField('pass2', 'secretpassword1');
$this->click('Change password');
$this->assertText('Old password does not match or empty.');
}

function testChangePasswordEmptyExistingPassword() {
global $TEST_SERVER_DOMAIN;

$this->get($TEST_SERVER_DOMAIN.'/session/login.php');
$this->setField('email', 'me@example.com');
$this->setField('pwd', 'secretpassword');

$this->click("Log In");
$this->assertTitle('ThinkTank');
$this->assertText('Logged in as: me@example.com');

$this->click("Configuration");
$this->assertText('Your ThinkTank Password');
$this->setField('pass1', 'secretpassword1');
$this->setField('pass2', 'secretpassword1');
$this->click('Change password');
$this->assertText('Old password does not match or empty.');
}

function testChangePasswordNewPasswordsDontMatch() {
global $TEST_SERVER_DOMAIN;

$this->get($TEST_SERVER_DOMAIN.'/session/login.php');
$this->setField('email', 'me@example.com');
$this->setField('pwd', 'secretpassword');

$this->click("Log In");
$this->assertTitle('ThinkTank');
$this->assertText('Logged in as: me@example.com');

$this->click("Configuration");
$this->assertText('Your ThinkTank Password');
$this->setField('oldpass', 'secretpassword');
$this->setField('pass1', 'secretpassword1');
$this->setField('pass2', 'secretpassword2');
$this->click('Change password');
$this->assertText('New passwords did not match. Your password has not been changed.');
}

function testChangePasswordNewPasswordsNotLongEnough() {
global $TEST_SERVER_DOMAIN;

$this->get($TEST_SERVER_DOMAIN.'/session/login.php');
$this->setField('email', 'me@example.com');
$this->setField('pwd', 'secretpassword');

$this->click("Log In");
$this->assertTitle('ThinkTank');
$this->assertText('Logged in as: me@example.com');

$this->click("Configuration");
$this->assertText('Your ThinkTank Password');
$this->setField('oldpass', 'secretpassword');
$this->setField('pass1', 'dd');
$this->setField('pass2', 'dd');
$this->click('Change password');
$this->assertText('New password must be at least 5 characters. Your password has not been changed.');
}


function testUserPage() {
global $TEST_SERVER_DOMAIN;

Expand Down Expand Up @@ -270,6 +377,6 @@ function testNextAndPreviousLinksControls() {

}

//TODO Write account page and status page tests
//TODO Write post page tests
}
?>
6 changes: 3 additions & 3 deletions webapp/account/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

$od = new OwnerDAO($db);

if (isset($_POST['changepass']) && $_POST['changepass'] == 'Change Password') {
if (isset($_POST['changepass']) && $_POST['changepass'] == 'Change password') {
$originalpass = $od->getPass($_SESSION['user']);
$origpass = $originalpass['pwd'];
if (!$session->pwdCheck($_POST['oldpass'], $origpass)) {
Expand All @@ -27,7 +27,7 @@
$od->updatePassword($_SESSION['user'], $cryptpass);
$successmsg = "Your password has been updated.";
}
}
}

$s = new SmartyThinkTank();
$s->caching = 0;
Expand Down Expand Up @@ -90,5 +90,5 @@
$s->assign('successmsg', $successmsg);
}

$s->display('index.account.tpl');
$s->display('account.index.tpl');
?>
2 changes: 1 addition & 1 deletion webapp/post/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# clean up
$db->closeConnection($conn);

$s->display('index.post.tpl', $post_id);
$s->display('post.index.tpl', $post_id);
} else {
echo 'This update is not in the system.<br /><a href="'. $cfg->site_root_path .'">back home</a>';
}
Expand Down
Loading

0 comments on commit b672d88

Please sign in to comment.