public function stage()
 {
     parent::stage();
     if (!$this->serviceExists('files')) {
         \DreamFactory\Core\Models\Service::create(['name' => 'files', 'label' => 'Local file service', 'description' => 'Local file service for unit test', 'is_active' => true, 'type' => 'local_file', 'config' => ['container' => 'local']]);
     }
 }
 public function testPasswordResetUsingConfirmationCode()
 {
     if (!$this->serviceExists('mymail')) {
         $emailService = \DreamFactory\Core\Models\Service::create(["name" => "mymail", "label" => "Test mail service", "description" => "Test mail service", "is_active" => true, "type" => "local_email", "mutable" => true, "deletable" => true, "config" => ["driver" => "sendmail", "command" => "/usr/sbin/sendmail -bs"]]);
         $userConfig = \DreamFactory\Core\User\Models\UserConfig::find(4);
         $userConfig->password_email_service_id = $emailService->id;
         $userConfig->save();
     }
     if (!\DreamFactory\Core\Models\EmailTemplate::whereName('mytemplate')->exists()) {
         $template = \DreamFactory\Core\Models\EmailTemplate::create(['name' => 'mytemplate', 'description' => 'test', 'to' => $this->user2['email'], 'subject' => 'rest password test', 'body_text' => 'link {link}']);
         $userConfig = \DreamFactory\Core\User\Models\UserConfig::find(4);
         $userConfig->password_email_template_id = $template->id;
         $userConfig->save();
     }
     Arr::set($this->user2, 'email', '*****@*****.**');
     $user = $this->createUser(2);
     Config::set('mail.pretend', true);
     $rs = $this->makeRequest(Verbs::POST, static::RESOURCE, ['reset' => 'true'], ['email' => $user['email']]);
     $content = $rs->getContent();
     $this->assertTrue($content['success']);
     /** @var User $userModel */
     $userModel = User::find($user['id']);
     $code = $userModel->confirm_code;
     $rs = $this->makeRequest(Verbs::POST, static::RESOURCE, ['login' => 'true'], ['email' => $user['email'], 'code' => $code, 'new_password' => '778877']);
     $content = $rs->getContent();
     $this->assertTrue($content['success']);
     $this->assertTrue(Session::isAuthenticated());
     $userModel = User::find($user['id']);
     $this->assertEquals('y', $userModel->confirm_code);
     $this->service = ServiceHandler::getService($this->serviceId);
     $rs = $this->makeRequest(Verbs::POST, 'session', [], ['email' => $user['email'], 'password' => '778877']);
     $content = $rs->getContent();
     $this->assertTrue(!empty($content['session_id']));
 }
 public function stage()
 {
     parent::stage();
     Artisan::call('migrate', ['--path' => 'vendor/dreamfactory/df-azure/database/migrations/']);
     Artisan::call('db:seed', ['--class' => DreamFactory\Core\Azure\Database\Seeds\DatabaseSeeder::class]);
     if (!$this->serviceExists('azure')) {
         \DreamFactory\Core\Models\Service::create(["name" => "azure", "label" => "Azure Blob file service", "description" => "Azure Blob file service for unit test", "is_active" => true, "type" => "azure_blob", "config" => ['protocol' => 'https', 'account_name' => env('AB_ACCOUNT_NAME'), 'account_key' => env('AB_ACCOUNT_KEY'), 'container' => env('AB_CONTAINER')]]);
     }
 }
Beispiel #4
0
 public function stage()
 {
     parent::stage();
     Artisan::call('migrate', ['--path' => 'vendor/dreamfactory/df-aws/database/migrations/']);
     Artisan::call('db:seed', ['--class' => DreamFactory\Core\Aws\Database\Seeds\DatabaseSeeder::class]);
     if (!$this->serviceExists('s3')) {
         \DreamFactory\Core\Models\Service::create(["name" => "s3", "label" => "S3 file service", "description" => "S3 file service for unit test", "is_active" => true, "type" => "aws_s3", "config" => ['key' => env('AWS_S3_KEY'), 'secret' => env('AWS_S3_SECRET'), 'region' => env('AWS_S3_REGION'), 'container' => env('AWS_S3_CONTAINER')]]);
     }
 }
 public function stage()
 {
     parent::stage();
     Artisan::call('migrate', ['--path' => 'vendor/dreamfactory/df-rackspace/database/migrations/']);
     Artisan::call('db:seed', ['--class' => DreamFactory\Core\Rackspace\Database\Seeds\DatabaseSeeder::class]);
     if (!$this->serviceExists('ros')) {
         \DreamFactory\Core\Models\Service::create(["name" => "ros", "label" => "Rackspace Cloud Files service", "description" => "Rackspace Cloud Files service for unit test", "is_active" => true, "type" => "rackspace_cloud_files", "config" => ['username' => env('ROS_USERNAME'), 'password' => env('ROS_PASSWORD'), 'tenant_name' => env('ROS_TENANT_NAME'), 'api_key' => env('ROS_API_KEY'), 'url' => env('ROS_URL'), 'region' => env('ROS_REGION'), 'storage_type' => env('ROS_STORAGE_TYPE'), 'container' => env('ROS_CONTAINER')]]);
     }
 }
 public function stage()
 {
     parent::stage();
     Artisan::call('migrate', ['--path' => 'vendor/dreamfactory/df-rws/database/migrations/']);
     Artisan::call('db:seed', ['--class' => DreamFactory\Core\Rws\Database\Seeds\DatabaseSeeder::class]);
     if (!$this->serviceExists('rave')) {
         \DreamFactory\Core\Models\Service::create(["name" => "rave", "type" => "rws", "label" => "Remote web service", "config" => ["base_url" => "http://df.local/rest", "cache_enabled" => false]]);
     }
 }
Beispiel #7
0
 public function stage()
 {
     parent::stage();
     Artisan::call('migrate', ['--path' => 'vendor/dreamfactory/df-rws/database/migrations/']);
     Artisan::call('db:seed', ['--class' => DreamFactory\Core\Rws\Database\Seeds\DatabaseSeeder::class]);
     if (!$this->serviceExists('gmap')) {
         \DreamFactory\Core\Models\Service::create(["name" => "gmap", "type" => "rws", "label" => "Remote web service", "config" => ["base_url" => "http://maps.googleapis.com/maps/api/directions/json", "cache_enabled" => false, "parameters" => [["name" => "origin", "value" => "5965 Willow Oak Pass, Cumming, GA 30040", "outbound" => true, "cache_key" => true, "action" => 31], ["name" => "destination", "value" => "3600 Mansell Rd. Alpharetta, GA", "outbound" => true, "cache_key" => true, "action" => 31]]]]);
     }
     if (!$this->serviceExists('dsp-tester')) {
         \DreamFactory\Core\Models\Service::create(["name" => "dsp-tester", "type" => "rws", "label" => "Remote web service", "config" => ["base_url" => "https://dsp-tester.cloud.dreamfactory.com/rest", "cache_enabled" => false, "headers" => [["name" => "Authorization", "value" => "Basic YXJpZmlzbGFtQGRyZWFtZmFjdG9yeS5jb206dGVzdCEyMzQ=", "pass_from_client" => false, "action" => 31], ["name" => "X-DreamFactory-Application-Name", "value" => "admin", "pass_from_client" => false, "action" => 31], ["name" => "X-HTTP-Method", "pass_from_client" => true, "action" => 31]]]]);
     }
 }
Beispiel #8
0
 /**
  * @return bool
  * @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
  */
 private function insertServices()
 {
     $data = $this->zip->getFromName('services.json');
     $this->zip->deleteName('services.json');
     if (false !== $data) {
         $data = DataFormatter::jsonToArray($data);
         try {
             foreach ($data as $service) {
                 Service::create($service);
             }
         } catch (\Exception $ex) {
             throw new InternalServerErrorException("Could not create the services.\n{$ex->getMessage()}");
         }
         return true;
     }
     return false;
 }
 protected function createDbService($num)
 {
     $serviceName = 'db' . $num;
     $service = \DreamFactory\Core\Models\Service::whereName($serviceName)->first();
     if (empty($service)) {
         $service = \DreamFactory\Core\Models\Service::create(["name" => $serviceName, "label" => "Database" . $num, "description" => "Local Database" . $num, "is_active" => true, "type" => "sql_db", 'config' => ['dsn' => 'foo', 'username' => 'user', 'password' => 'password', 'db' => 'mydb', 'options' => 'options', 'attributes' => 'attributes']]);
     }
     return $service->id;
 }