From 198511f6397d6712900bb09b1388eac1012f472f Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 30 Jun 2009 18:30:39 -0400 Subject: [PATCH] Adding tests for security salt generation. --- cake/console/libs/tasks/project.php | 2 +- .../cases/console/libs/tasks/project.test.php | 25 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/cake/console/libs/tasks/project.php b/cake/console/libs/tasks/project.php index a0e63e8ea0b..40d9086d301 100644 --- a/cake/console/libs/tasks/project.php +++ b/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; } diff --git a/cake/tests/cases/console/libs/tasks/project.test.php b/cake/tests/cases/console/libs/tasks/project.test.php index 06886cf7846..be198856264 100644 --- a/cake/tests/cases/console/libs/tasks/project.test.php +++ b/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'); + } } ?> \ No newline at end of file