Ejemplo n.º 1
0
    {
        try {
            if ($input == '' || empty($params['0'])) {
                return false;
            }
            $params = $params['0'];
            if (empty($params['s3_access_key']) || empty($params['s3_secret_key']) || empty($params['s3_bucket'])) {
                return false;
            }
            $local = new Remote(new Local(dirname($this->getTestFilePath())));
            $region = $params['s3_region'] ? $params['s3_region'] : '';
            $client = m62S3::getRemoteClient($params['s3_access_key'], $params['s3_secret_key'], $region);
            if ($client->doesBucketExist($params['s3_bucket'])) {
                $contents = $local->read($this->test_file);
                $filesystem = new Remote(new m62S3($client, $params['s3_bucket']));
                if ($filesystem->has($this->test_file)) {
                    $filesystem->delete($this->test_file);
                } else {
                    if ($filesystem->write($this->test_file, $contents)) {
                        $filesystem->delete($this->test_file);
                    }
                }
                return true;
            }
        } catch (\Exception $e) {
            return false;
        }
    }
}
$rule = new Writable();
\JaegerApp\Validate::addrule($rule->getName(), array($rule, 'validate'), $rule->getErrorMessage());
Ejemplo n.º 2
0
 /**
  * Tests the name of the rule
  */
 public function testName()
 {
     $dir = new Writable();
     $this->assertEquals($dir->getName(), 's3_bucket_writable');
 }