Skip to content
This repository
Browse code

Adding tests for security salt generation.

  • Loading branch information...
commit 198511f6397d6712900bb09b1388eac1012f472f 1 parent 8c2a027
Mark Story authored June 30, 2009
2  cake/console/libs/tasks/project.php
@@ -61,7 +61,7 @@ function execute($project = null) {
61 61
 		if ($project) {
62 62
 			$response = false;
63 63
 			while ($response == false && is_dir($project) === true && file_exists($project . 'config' . 'core.php')) {
64  
-				$response = $this->in('A project already exists in this location: '.$project.' Overwrite?', array('y','n'), 'n');
  64
+				$response = $this->in('A project already exists in this location: ' . $project . ' Overwrite?', array('y','n'), 'n');
65 65
 				if (strtolower($response) === 'n') {
66 66
 					$response = $project = false;
67 67
 				}
25  cake/tests/cases/console/libs/tasks/project.test.php
@@ -76,6 +76,9 @@ function startTest() {
76 76
  */
77 77
 	function endTest() {
78 78
 		ClassRegistry::flush();
  79
+
  80
+		$Folder =& new Folder($this->Task->path . 'bake_test_app');
  81
+		$Folder->delete();
79 82
 	}
80 83
 
81 84
 /**
@@ -100,10 +103,26 @@ function testBake() {
100 103
 		$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s');
101 104
 		$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s');
102 105
 		$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');
103  
-
104  
-		$Folder =& new Folder($this->Task->path . 'bake_test_app');
105  
-		$Folder->delete();
106 106
 	}
107 107
 
  108
+/**
  109
+ * test generation of Security.salt
  110
+ *
  111
+ * @return void
  112
+ **/
  113
+	function testSecuritySaltGeneration() {
  114
+		$skel = CAKE_CORE_INCLUDE_PATH . DS . CONSOLE_LIBS . 'templates' . DS . 'skel';
  115
+		$this->Task->setReturnValueAt(0, 'in', 'y');
  116
+		$this->Task->setReturnValueAt(1, 'in', 'n');
  117
+		$this->Task->bake($this->Task->path . 'bake_test_app', $skel);
  118
+		
  119
+		$path = $this->Task->path . 'bake_test_app' . DS;
  120
+		$result = $this->Task->securitySalt($path);
  121
+		$this->assertTrue($result);
  122
+		
  123
+		$file =& new File($path . 'config' . DS . 'core.php');
  124
+		$contents = $file->read();
  125
+		$this->assertNoPattern('/DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi/', $contents, 'Default Salt left behind. %s');
  126
+	}
108 127
 }
109 128
 ?>

0 notes on commit 198511f

Please sign in to comment.
Something went wrong with that request. Please try again.