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)); }
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)); }
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)); }
/** * 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()); }