Skip to content

Commit

Permalink
Adding tests for security salt generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jun 30, 2009
1 parent 8c2a027 commit 198511f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cake/console/libs/tasks/project.php
Expand Up @@ -61,7 +61,7 @@ function execute($project = null) {
if ($project) {
$response = false;
while ($response == false && is_dir($project) === true && file_exists($project . 'config' . 'core.php')) {
$response = $this->in('A project already exists in this location: '.$project.' Overwrite?', array('y','n'), 'n');
$response = $this->in('A project already exists in this location: ' . $project . ' Overwrite?', array('y','n'), 'n');
if (strtolower($response) === 'n') {
$response = $project = false;
}
Expand Down
25 changes: 22 additions & 3 deletions cake/tests/cases/console/libs/tasks/project.test.php
Expand Up @@ -76,6 +76,9 @@ function startTest() {
*/
function endTest() {
ClassRegistry::flush();

$Folder =& new Folder($this->Task->path . 'bake_test_app');
$Folder->delete();
}

/**
Expand All @@ -100,10 +103,26 @@ function testBake() {
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');

$Folder =& new Folder($this->Task->path . 'bake_test_app');
$Folder->delete();
}

/**
* test generation of Security.salt
*
* @return void
**/
function testSecuritySaltGeneration() {
$skel = CAKE_CORE_INCLUDE_PATH . DS . CONSOLE_LIBS . 'templates' . DS . 'skel';
$this->Task->setReturnValueAt(0, 'in', 'y');
$this->Task->setReturnValueAt(1, 'in', 'n');
$this->Task->bake($this->Task->path . 'bake_test_app', $skel);

$path = $this->Task->path . 'bake_test_app' . DS;
$result = $this->Task->securitySalt($path);
$this->assertTrue($result);

$file =& new File($path . 'config' . DS . 'core.php');
$contents = $file->read();
$this->assertNoPattern('/DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi/', $contents, 'Default Salt left behind. %s');
}
}
?>

0 comments on commit 198511f

Please sign in to comment.