Author: Benjamin Georgeault (benjamin@wedgesama.fr)
Ejemplo n.º 1
0
 public function testAllowedUpload()
 {
     $app = $this->getApp();
     $fp = new FilePermissions($app);
     $hiddenFile = ".bashrc";
     $this->assertFalse($fp->allowedUpload($hiddenFile));
     $badExtension = "evil.exe";
     $this->assertFalse($fp->allowedUpload($badExtension));
     $okFile = "mycoolimage.jpg";
     $this->assertTrue($fp->allowedUpload($okFile));
 }
Ejemplo n.º 2
0
 public function testAllowedUpload()
 {
     $app = $this->getApp();
     $fp = new FilePermissions($app['config']);
     $hiddenFile = '.bashrc';
     $this->assertFalse($fp->allowedUpload($hiddenFile));
     $badExtension = 'evil.exe';
     $this->assertFalse($fp->allowedUpload($badExtension));
     $okFile = 'mycoolimage.jpg';
     $this->assertTrue($fp->allowedUpload($okFile));
 }
Ejemplo n.º 3
0
 public function testAllowedUpload()
 {
     $app = $this->getApp();
     $fp = new FilePermissions($app['config']);
     $hiddenFile = '.bashrc';
     $this->assertFalse($fp->allowedUpload($hiddenFile));
     $badExtension = 'evil.exe';
     $this->assertFalse($fp->allowedUpload($badExtension));
     $okFile = 'mycoolimage.jpg';
     if (ini_set('file_uploads', '0') !== false) {
         try {
             $fp->allowedUpload($okFile);
         } catch (IOException $e) {
             $this->assertEquals($e->getMessage(), 'File uploads are not allowed, check the file_uploads ini directive.');
         }
         ini_set('file_uploads', '1');
     }
     $this->assertTrue($fp->allowedUpload($okFile));
 }
Ejemplo n.º 4
0
 /**
  * Returns whether you are authorized to do something with a file or directory.
  *
  * @param string $path
  *
  * @return bool
  */
 public function handle($path)
 {
     $file = $this->filesystem->getFile($path);
     return $this->filePermissions->authorized($file->getMountPoint(), $file->getPath());
 }