예제 #1
0
 public function testSystemLookupWithApiKey()
 {
     $app = App::find(1);
     $apiKey = $app->api_key;
     Lookup::create($this->systemLookup[0]);
     $this->call(Verbs::GET, '/api/v2/system/environment?api_key=' . $apiKey);
     $this->assertEquals(Arr::get($this->systemLookup, '0.value'), Session::get('lookup.host'));
 }
예제 #2
0
 public function testApiKeyUserRole()
 {
     $user = ['name' => 'John Doe', 'first_name' => 'John', 'last_name' => 'Doe', 'email' => '*****@*****.**', 'password' => 'test1234', 'security_question' => 'Make of your first car?', 'security_answer' => 'mazda', 'is_active' => true];
     $role = ['name' => 'test_role', 'is_active' => true, 'role_service_access_by_role_id' => [['service_id' => 1, 'component' => 'config', 'verb_mask' => 1, 'requestor_mask' => 1]]];
     $this->service = ServiceHandler::getService('system');
     $rs = $this->makeRequest(Verbs::POST, 'user', [], [$user]);
     $data = $rs->getContent();
     $userId = Arr::get($data, static::$wrapper . '.0.id');
     $this->service = ServiceHandler::getService('system');
     $rs = $this->makeRequest(Verbs::POST, 'role', [], [$role]);
     $data = $rs->getContent();
     $roleId = Arr::get($data, static::$wrapper . '.0.id');
     \DreamFactory\Core\Models\UserAppRole::create(['user_id' => $userId, 'app_id' => 1, 'role_id' => $roleId]);
     $app = App::find(1);
     $apiKey = $app->api_key;
     $myUser = User::find($userId);
     $token = JWTUtilities::makeJWTByUser($myUser->id, $myUser->email);
     $this->call(Verbs::GET, '/api/v2/system', [], [], [], ['HTTP_X_DREAMFACTORY_API_KEY' => $apiKey, 'HTTP_X_DREAMFACTORY_SESSION_TOKEN' => $token]);
     $this->assertFalse(Session::isSysAdmin());
     $this->assertEquals($roleId, Session::get('role.id'));
     $rsa = Session::get('role.services');
     $this->assertTrue(!empty($rsa));
 }
예제 #3
0
 /**
  * @param bool|true  $includeFiles
  * @param bool|false $includeData
  *
  * @return null
  * @throws \DreamFactory\Core\Exceptions\NotFoundException
  * @throws \Exception
  */
 public function exportAppAsPackage($includeFiles = true, $includeData = false)
 {
     /** @type App $app */
     $app = App::find($this->exportAppId);
     if (empty($app)) {
         throw new NotFoundException('App not found in database with app id - ' . $this->exportAppId);
     }
     $appName = $app->name;
     try {
         $this->initExportZipFile($appName);
         $this->packageAppDescription($app);
         $this->packageServices();
         $this->packageSchemas();
         if ($includeData) {
             $this->packageData();
         }
         if ($app->type === AppTypes::STORAGE_SERVICE && $includeFiles) {
             $this->packageAppFiles($app);
         }
         $this->zip->close();
         FileUtilities::sendFile($this->zipFilePath, true);
         return null;
     } catch (\Exception $e) {
         //Do necessary things here.
         throw $e;
     }
 }