Permalink
Browse files

Adding tests for security salt generation.

  • Loading branch information...
1 parent 8c2a027 commit 198511f6397d6712900bb09b1388eac1012f472f @markstory markstory committed Jun 30, 2009
Showing with 23 additions and 4 deletions.
  1. +1 −1 cake/console/libs/tasks/project.php
  2. +22 −3 cake/tests/cases/console/libs/tasks/project.test.php
View
2 cake/console/libs/tasks/project.php
@@ -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;
}
View
25 cake/tests/cases/console/libs/tasks/project.test.php
@@ -76,6 +76,9 @@ function startTest() {
*/
function endTest() {
ClassRegistry::flush();
+
+ $Folder =& new Folder($this->Task->path . 'bake_test_app');
+ $Folder->delete();
}
/**
@@ -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.