Completed
Push — master ( 2bc6ba...1ab902 )
by Francesco
09:17
created
Tests/KeyManagerWrapperTest.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     protected function setUp()
37 37
     {
38 38
         $this->keyManager = $this->getMockBuilder('\Mes\Security\CryptoBundle\KeyManagerInterface')
39
-                                 ->getMock();
39
+                                    ->getMock();
40 40
         $this->wrapper = new KeyManagerWrapper($this->keyManager);
41 41
     }
42 42
 
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
     public function testGenerateCreatesKey()
49 49
     {
50 50
         $this->keyManager->expects($this->once())
51
-                         ->method('generate')
52
-                         ->with(null)
53
-                         ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()));
51
+                            ->method('generate')
52
+                            ->with(null)
53
+                            ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()));
54 54
 
55 55
         $key = $this->wrapper->generate();
56 56
 
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
     {
65 65
         try {
66 66
             $this->keyManager->expects($this->once())
67
-                             ->method('generate')
68
-                             ->with(null)
69
-                             ->will($this->throwException(new EnvironmentIsBrokenException()));
67
+                                ->method('generate')
68
+                                ->with(null)
69
+                                ->will($this->throwException(new EnvironmentIsBrokenException()));
70 70
         } catch (EnvironmentIsBrokenException $ex) {
71 71
             $this->throwException(new CryptoException());
72 72
         }
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         $secret = 'ThisIsASecretPassword';
81 81
 
82 82
         $this->keyManager->expects($this->once())
83
-                         ->method('generateFromAscii')
84
-                         ->with($key_encoded, $secret)
85
-                         ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()));
83
+                            ->method('generateFromAscii')
84
+                            ->with($key_encoded, $secret)
85
+                            ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()));
86 86
 
87 87
         $key = $this->wrapper->generateFromAscii($key_encoded, $secret);
88 88
 
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 
100 100
         try {
101 101
             $this->keyManager->expects($this->once())
102
-                             ->method('generateFromAscii')
103
-                             ->with($key_encoded, $secret)
104
-                             ->will($this->throwException(new BaseCryptoException()));
102
+                                ->method('generateFromAscii')
103
+                                ->with($key_encoded, $secret)
104
+                                ->will($this->throwException(new BaseCryptoException()));
105 105
         } catch (CryptoException $ex) {
106 106
             $this->throwException(new CryptoException());
107 107
         }
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
     public function testGetKeyReadsKey()
113 113
     {
114 114
         $this->keyManager->expects($this->once())
115
-                         ->method('getKey')
116
-                         ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()));
115
+                            ->method('getKey')
116
+                            ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()));
117 117
 
118 118
         $key = $this->wrapper->getKey();
119 119
 
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
     public function testSetKeyStoresKey()
124 124
     {
125 125
         $this->keyManager->expects($this->once())
126
-                         ->method('setKey')
127
-                         ->with($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock());
126
+                            ->method('setKey')
127
+                            ->with($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock());
128 128
 
129 129
         $this->wrapper->setKey($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock());
130 130
     }
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
     public function testSetSecretStoresSecret()
133 133
     {
134 134
         $this->keyManager->expects($this->once())
135
-                         ->method('setSecret')
136
-                         ->with('ThisIsASecret');
135
+                            ->method('setSecret')
136
+                            ->with('ThisIsASecret');
137 137
 
138 138
         $this->wrapper->setSecret('ThisIsASecret');
139 139
     }
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
     public function testGetSecretReadsSecret()
142 142
     {
143 143
         $this->keyManager->expects($this->once())
144
-                         ->method('getSecret')
145
-                         ->will($this->returnValue('ThisIsYourSecret'));
144
+                            ->method('getSecret')
145
+                            ->will($this->returnValue('ThisIsYourSecret'));
146 146
 
147 147
         $secret = $this->wrapper->getSecret();
148 148
 
Please login to merge, or discard this patch.
DependencyInjection/MesCryptoExtension.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -86,21 +86,21 @@  discard block
 block discarded – undo
86 86
 
87 87
                 // Sets the loader resource.
88 88
                 $container->findDefinition($id)
89
-                          ->addMethodCall('setResource', array($attribute['resource']));
89
+                            ->addMethodCall('setResource', array($attribute['resource']));
90 90
 
91 91
                 // Load secret from loader.
92 92
                 $container->getDefinition('mes_crypto.key_manager_wrapper')
93
-                          ->setMethodCalls(array())
94
-                          ->addMethodCall('setSecret', array($this->loadSecret));
93
+                            ->setMethodCalls(array())
94
+                            ->addMethodCall('setSecret', array($this->loadSecret));
95 95
 
96 96
                 // Sets Defuse KeyProtectedByPassword.
97 97
                 $container->findDefinition('mes_crypto.raw_key')
98
-                          ->setClass('Defuse\Crypto\KeyProtectedByPassword')
99
-                          ->setArguments(array($this->loadKey))
100
-                          ->setFactory(array(
101
-                              'Defuse\Crypto\KeyProtectedByPassword',
102
-                              'loadFromAsciiSafeString',
103
-                          ));
98
+                            ->setClass('Defuse\Crypto\KeyProtectedByPassword')
99
+                            ->setArguments(array($this->loadKey))
100
+                            ->setFactory(array(
101
+                                'Defuse\Crypto\KeyProtectedByPassword',
102
+                                'loadFromAsciiSafeString',
103
+                            ));
104 104
 
105 105
                 // Sets the key
106 106
                 $this->createKeyDefinition($container, $this->loadSecret);
@@ -194,23 +194,23 @@  discard block
 block discarded – undo
194 194
 
195 195
             // Reads encoded key from configuration file if key is not external.
196 196
             $rawKeyDefinition->setClass($defuseKey)
197
-                             ->setFactory(array(
198
-                                 $defuseKey,
199
-                                 'loadFromAsciiSafeString',
200
-                             ));
197
+                                ->setFactory(array(
198
+                                    $defuseKey,
199
+                                    'loadFromAsciiSafeString',
200
+                                ));
201 201
             $rawKeyDefinition->setArguments(array(
202 202
                 $keyIsExternal ? $this->loadKey : $key,
203 203
             ));
204 204
         } else {
205 205
             $rawKeyDefinition->setClass($defuseKey)
206
-                             ->setArguments($secretExists ? array($secretIsExternal ? $this->loadSecret : $secret) : array())
207
-                             ->setFactory($secretExists ? array(
208
-                                 'Defuse\Crypto\KeyProtectedByPassword',
209
-                                 'createRandomPasswordProtectedKey',
210
-                             ) : array(
211
-                                 'Defuse\Crypto\Key',
212
-                                 'createNewRandomKey',
213
-                             ));
206
+                                ->setArguments($secretExists ? array($secretIsExternal ? $this->loadSecret : $secret) : array())
207
+                                ->setFactory($secretExists ? array(
208
+                                    'Defuse\Crypto\KeyProtectedByPassword',
209
+                                    'createRandomPasswordProtectedKey',
210
+                                ) : array(
211
+                                    'Defuse\Crypto\Key',
212
+                                    'createNewRandomKey',
213
+                                ));
214 214
         }
215 215
 
216 216
         if (($createRandomKey || (!$createRandomKey && !$keyIsExternal)) && !$this->loaderEnabled) {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
         }
219 219
 
220 220
         $container->setDefinition('mes_crypto.raw_key', $rawKeyDefinition)
221
-                  ->setPublic(false);
221
+                    ->setPublic(false);
222 222
 
223 223
         // Key
224 224
         $this->createKeyDefinition($container, $secretExists ? ($secretIsExternal ? $this->loadSecret : $secret) : null);
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
             'Mes\Security\CryptoBundle\Model\Key',
247 247
             'create',
248 248
         ))
249
-                      ->setPublic(false);
249
+                        ->setPublic(false);
250 250
 
251 251
         $container->setDefinition('mes_crypto.key', $keyDefinition);
252 252
     }
@@ -271,6 +271,6 @@  discard block
 block discarded – undo
271 271
     private function setCryptoLoaderResource(ContainerBuilder $container, $resource)
272 272
     {
273 273
         $container->findDefinition('mes_crypto.loader')
274
-                  ->addMethodCall('setResource', array($resource));
274
+                    ->addMethodCall('setResource', array($resource));
275 275
     }
276 276
 }
Please login to merge, or discard this patch.
Tests/DependencyInjection/MesCryptoExtensionTest.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
         $this->assertHasDefinition('mes_crypto.raw_key');
44 44
         $this->assertSame('Defuse\Crypto\Key', $this->configuration->findDefinition('mes_crypto.raw_key')
45
-                                                                   ->getClass(), 'Defuse\Crypto\Key class is correct');
45
+                                                                    ->getClass(), 'Defuse\Crypto\Key class is correct');
46 46
 
47 47
         $this->assertNotHasDefinition('mes_crypto.loader');
48 48
     }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
         $this->assertHasDefinition('mes_crypto.raw_key');
57 57
         $this->assertSame('Defuse\Crypto\KeyProtectedByPassword', $this->configuration->findDefinition('mes_crypto.raw_key')
58
-                                                                                      ->getClass(), 'KeyProtectedByPassword class is correct');
58
+                                                                                        ->getClass(), 'KeyProtectedByPassword class is correct');
59 59
 
60 60
         $this->assertNotHasDefinition('mes_crypto.loader');
61 61
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
         $this->assertHasDefinition('mes_crypto.raw_key');
70 70
         $this->assertSame('Defuse\Crypto\KeyProtectedByPassword', $this->configuration->findDefinition('mes_crypto.raw_key')
71
-                                                                                      ->getClass(), 'Defuse\Crypto\KeyProtectedByPassword class is correct');
71
+                                                                                        ->getClass(), 'Defuse\Crypto\KeyProtectedByPassword class is correct');
72 72
         $this->assertNotHasDefinition('mes_crypto.loader');
73 73
     }
74 74
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
         $this->assertHasDefinition('mes_crypto.raw_key');
82 82
         $this->assertSame('Defuse\Crypto\KeyProtectedByPassword', $this->configuration->findDefinition('mes_crypto.raw_key')
83
-                                                                                      ->getClass(), 'Defuse\Crypto\KeyProtectedByPassword class is correct');
83
+                                                                                        ->getClass(), 'Defuse\Crypto\KeyProtectedByPassword class is correct');
84 84
         $this->assertHasDefinition('mes_crypto.loader');
85 85
     }
86 86
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
         $this->assertHasDefinition('mes_crypto.raw_key');
94 94
         $this->assertSame('Defuse\Crypto\KeyProtectedByPassword', $this->configuration->findDefinition('mes_crypto.raw_key')
95
-                                                                                      ->getClass(), 'Defuse\Crypto\KeyProtectedByPassword class is correct');
95
+                                                                                        ->getClass(), 'Defuse\Crypto\KeyProtectedByPassword class is correct');
96 96
         $this->assertHasDefinition('mes_crypto.loader');
97 97
 
98 98
         $this->assertSame('custom_key_storage_service', (string) $this->configuration->getAlias('mes_crypto.key_storage'), 'custom_key_storage_service is correct alias');
Please login to merge, or discard this patch.
Command/KeyGeneratorCommand.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         parent::initialize($input, $output);
64 64
 
65 65
         $this->helper = $this->getHelperSet()
66
-                             ->get('question');
66
+                                ->get('question');
67 67
 
68 68
         $this->symfonyStyle = $this->getStyle($input, $output);
69 69
     }
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
     protected function configure()
75 75
     {
76 76
         $this->setName('mes:crypto:generate-key')
77
-             ->setDefinition($this->createDefinition())
78
-             ->setDescription('Generates an encoded key with or without authentication secret')
79
-             ->setHelp(<<<'EOF'
77
+                ->setDefinition($this->createDefinition())
78
+                ->setDescription('Generates an encoded key with or without authentication secret')
79
+                ->setHelp(<<<'EOF'
80 80
 The <info>%command.name%</info> generates an encoded key with or without authentication secret and optionally it saves the printable key and the secret in a ini format .crypto file.
81 81
 
82 82
 <info>%command.full_name%</info>
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 <info>%command.full_name%</info> --dir /path/to/dir/key.crypto
87 87
 EOF
88
-             );
88
+                );
89 89
     }
90 90
 
91 91
     /**
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
         $this->writeSection($output, 'Generating key'.($secret ? ' with authentication secret' : '').($dir ? " in $dir" : ''));
166 166
 
167 167
         $encodedKey = $keyGenerator->generate($secret)
168
-                                   ->getEncoded();
168
+                                    ->getEncoded();
169 169
 
170 170
         $this->log($logger, "The encoded key has been generated with the following sequence:\n{$encodedKey}\n", LogLevel::INFO);
171 171
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
             /** @var DebugFormatterHelper */
227 227
             $dh = $this->getHelperSet()
228
-                       ->get('debug_formatter');
228
+                        ->get('debug_formatter');
229 229
 
230 230
             $process = new Process("ls -la {$options['dir']} | grep \".crypto\"");
231 231
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             $random = $this->generator->generateRandomSecret();
105 105
             $this->symfonyStyle->newLine();
106 106
             $question = new Question($this->getQuestion('Insert your authentication secret or use this one randomly generated', $random), $random);
107
-            $question->setValidator(function ($secret) {
107
+            $question->setValidator(function($secret) {
108 108
                 if (!ctype_print($secret)) {
109 109
                     throw new \RuntimeException(sprintf('The authentication secret is not printable', $secret));
110 110
                 }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
                 $dh->start(spl_object_hash($process), "Find {$options['dir']}", 'START'),
235 235
             ));
236 236
 
237
-            $process->run(function ($type, $buffer) use ($process, $output, $dh) {
237
+            $process->run(function($type, $buffer) use ($process, $output, $dh) {
238 238
                 $output->writeln($dh->progress(spl_object_hash($process), $buffer, Process::ERR === $type));
239 239
             });
240 240
 
Please login to merge, or discard this patch.