Merge remote-tracking branch 'origin/master'

This commit is contained in:
Michal Čihař 2012-04-02 14:49:26 +02:00
commit 48c2f5906b
3 changed files with 67 additions and 50 deletions

View File

@ -30,8 +30,8 @@ class AllSeleniumTests
$suite = new PHPUnit_Framework_TestSuite('phpMyAdmin');
$suite->addTestSuite('PmaSeleniumLoginTest');
//$suite->addTestSuite('PmaSeleniumXssTest');
//$suite->addTestSuite('PmaSeleniumPrivilegesTest');
$suite->addTestSuite('PmaSeleniumXssTest');
$suite->addTestSuite('PmaSeleniumPrivilegesTest');
return $suite;
}
}

View File

@ -1,4 +1,5 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Selenium TestCase for privilege related tests
@ -6,43 +7,51 @@
* @package PhpMyAdmin-test
* @group Selenium
*/
require_once 'PmaSeleniumTestCase.php';
require_once 'Helper.php';
class PmaSeleniumPrivilegesTest extends PHPUnit_Extensions_SeleniumTestCase {
public function setUp() {
$helper = new Helper();
$this->setBrowser(Helper::getBrowserString());
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
}
public function testChangePassword() {
$log = new PmaSeleniumTestCase($this);
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
$this->selectFrame("frame_content");
$this->click("link=Change password");
$this->waitForPageToLoad("20000");
try {
$this->assertEquals("", $this->getValue("text_pma_pw"));
} catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
try {
$this->assertEquals("", $this->getValue("text_pma_pw2"));
} catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
try {
$this->assertEquals("", $this->getValue("generated_pw"));
} catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
$this->click("button_generate_password");
$this->assertNotEquals("", $this->getValue("text_pma_pw"));
$this->assertNotEquals("", $this->getValue("text_pma_pw2"));
$this->assertNotEquals("", $this->getValue("generated_pw"));
$this->type("text_pma_pw", TESTSUITE_PASSWORD);
$this->type("text_pma_pw2", TESTSUITE_PASSWORD);
$this->click("//button[@type='button']");
$this->waitForPageToLoad("20000");
$this->assertTrue($this->isTextPresent(""));
$this->assertTrue($this->isTextPresent(""));
}
class PmaSeleniumPrivilegesTest extends PmaSeleniumTestCase
{
public function testChangePassword()
{
$this->doLogin();
$this->selectFrame("frame_content");
$this->click("link=Change password");
$this->waitForPageToLoad("30000");
try {
$this->assertEquals("", $this->getValue("text_pma_pw"));
} catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
try {
$this->assertEquals("", $this->getValue("text_pma_pw2"));
} catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
try {
$this->assertEquals("", $this->getValue("generated_pw"));
} catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
$this->click("button_generate_password");
$this->assertNotEquals("", $this->getValue("text_pma_pw"));
$this->assertNotEquals("", $this->getValue("text_pma_pw2"));
$this->assertNotEquals("", $this->getValue("generated_pw"));
$this->type("text_pma_pw", $this->cfg['Test']['testuser']['password']);
$this->type("text_pma_pw2", $this->cfg['Test']['testuser']['password']);
$this->click("change_pw");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent(""));
$this->assertTrue($this->isTextPresent(""));
}
}
?>

View File

@ -1,4 +1,5 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Selenium TestCase for XSS related tests
@ -6,20 +7,27 @@
* @package PhpMyAdmin-test
* @group Selenium
*/
require_once 'PmaSeleniumTestCase.php';
require_once 'Helper.php';
class PmaSeleniumXSSTest extends PHPUnit_Extensions_SeleniumTestCase {
public function setUp() {
$helper = new Helper();
$this->setBrowser(Helper::getBrowserString());
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
}
public function testQueryTabWithNullValue() {
$log = new PmaSeleniumTestCase($this);
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
$this->selectFrame("frame_content");
$this->click("link=SQL");
$this->waitForPageToLoad("30000");
$this->click("button_submit_query");
$this->assertAlert("Missing value in the form!");
}
class PmaSeleniumXSSTest extends PmaSeleniumTestCase
{
public function testXssQueryTab()
{
$this->doLogin();
$this->selectFrame("frame_content");
$this->click("link=SQL");
$this->waitForPageToLoad("30000");
$this->type("sqlquery", "'\"><script>alert(123);</script>");
$this->click("SQL");
// If an alert pops up the test fails, since we don't handle an alert.
}
}
?>