Пример #1
0
 private function seedUsersScopes()
 {
     $users = Api::where('name', '=', 'users')->first();
     ApiScope::create(array('name' => 'profile', 'short_description' => 'Allows access to your profile info.', 'description' => 'This scope value requests access to the End-Users default profile Claims, which are: name, family_name, given_name, middle_name, nickname, preferred_username, profile, picture, website, gender, birthdate, zoneinfo, locale, and updated_at.', 'api_id' => $users->id, 'system' => false));
     ApiScope::create(array('name' => 'email', 'short_description' => 'Allows access to your email info.', 'description' => 'This scope value requests access to the email and email_verified Claims.', 'api_id' => $users->id, 'system' => false));
     ApiScope::create(array('name' => 'address', 'short_description' => 'Allows access to your Address info.', 'description' => 'This scope value requests access to the address Claim.', 'api_id' => $users->id, 'system' => false));
 }
Пример #2
0
 /**
  * testCreate
  * @covers create a new api scope
  */
 public function testCreate()
 {
     $api = Api::where('name', '=', 'api-endpoint')->first();
     $this->assertTrue(!is_null($api));
     $data = array('name' => 'https://test-scope/read.only', 'description' => 'test scope.', 'short_description' => 'test scope.', 'active' => true, 'system' => true, 'default' => true, 'api_id' => $api->id);
     $response = $this->action("POST", "ApiScopeController@create", $data, array(), array(), array());
     $content = $response->getContent();
     $json_response = json_decode($content);
     $this->assertResponseStatus(201);
     $this->assertTrue(isset($json_response->scope_id) && !empty($json_response->scope_id));
 }
Пример #3
0
 private function seedUsersEndpoints()
 {
     $users = Api::where('name', '=', 'users')->first();
     // endpoints scopes
     ApiEndpoint::create(array('name' => 'get-user-info', 'active' => true, 'api_id' => $users->id, 'route' => '/api/v1/users/me', 'http_method' => 'GET'));
     $profile_scope = ApiScope::where('name', '=', 'profile')->first();
     $email_scope = ApiScope::where('name', '=', 'email')->first();
     $address_scope = ApiScope::where('name', '=', 'address')->first();
     $get_user_info_endpoint = ApiEndpoint::where('name', '=', 'get-user-info')->first();
     $get_user_info_endpoint->scopes()->attach($profile_scope->id);
     $get_user_info_endpoint->scopes()->attach($email_scope->id);
     $get_user_info_endpoint->scopes()->attach($address_scope->id);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $public_clouds = Api::where('name', '=', 'public-clouds')->first();
     if ($public_clouds) {
         $public_clouds->delete();
     }
     $private_clouds = Api::where('name', '=', 'private-clouds')->first();
     if ($private_clouds) {
         $private_clouds->delete();
     }
     $consultants = Api::where('name', '=', 'consultants')->first();
     if ($consultants) {
         $consultants->delete();
     }
 }
 private function seedConsultantsEndpoints()
 {
     $consultants = Api::where('name', '=', 'consultants')->first();
     $current_realm = Config::get('app.url');
     // endpoints scopes
     ApiEndpoint::create(array('name' => 'get-consultants', 'active' => true, 'api_id' => $consultants->id, 'route' => '/api/v1/marketplace/consultants', 'http_method' => 'GET'));
     ApiEndpoint::create(array('name' => 'get-consultant', 'active' => true, 'api_id' => $consultants->id, 'route' => '/api/v1/marketplace/consultants/{id}', 'http_method' => 'GET'));
     ApiEndpoint::create(array('name' => 'get-consultant-offices', 'active' => true, 'api_id' => $consultants->id, 'route' => '/api/v1/marketplace/consultants/{id}/offices', 'http_method' => 'GET'));
     $consultant_read_scope = ApiScope::where('name', '=', sprintf('%s/consultants/read', $current_realm))->first();
     $endpoint = ApiEndpoint::where('name', '=', 'get-consultants')->first();
     $endpoint->scopes()->attach($consultant_read_scope->id);
     $endpoint = ApiEndpoint::where('name', '=', 'get-consultant')->first();
     $endpoint->scopes()->attach($consultant_read_scope->id);
     $endpoint = ApiEndpoint::where('name', '=', 'get-consultant-offices')->first();
     $endpoint->scopes()->attach($consultant_read_scope->id);
 }
Пример #6
0
 public function testUpdateStatus()
 {
     $api = Api::where('name', '=', 'api-endpoint')->first();
     $this->assertTrue(!is_null($api));
     $data = array('name' => 'test-api-endpoint', 'description' => 'test api endpoint, allows test api endpoints.', 'active' => true, 'route' => '/api/v1/api-endpoint/test', 'http_method' => 'POST', 'api_id' => $api->id, 'allow_cors' => true, 'rate_limit' => 60);
     $response = $this->action("POST", "ApiEndpointController@create", $data);
     $this->assertResponseStatus(201);
     $content = $response->getContent();
     $json_response = json_decode($content);
     $this->assertTrue(isset($json_response->api_endpoint_id) && !empty($json_response->api_endpoint_id));
     $new_id = $json_response->api_endpoint_id;
     //update status
     $response = $this->action('DELETE', "ApiEndpointController@deactivate", array('id' => $new_id));
     $this->assertResponseStatus(200);
     $content = $response->getContent();
     $json_response = json_decode($content);
     $this->assertTrue($json_response === 'ok');
     $response = $this->action("GET", "ApiEndpointController@get", array('id' => $new_id));
     $this->assertResponseStatus(200);
     $content = $response->getContent();
     $updated_values = json_decode($content);
     $this->assertTrue($updated_values->active == false);
 }
Пример #7
0
 public function testDeleteExisting()
 {
     $resource_server_api = Api::where('name', '=', 'resource-server')->first();
     $id = $resource_server_api->id;
     $response = $this->action("DELETE", "ApiController@delete", $parameters = array('id' => $id), array(), array(), array());
     $this->assertResponseStatus(204);
     $response = $this->action("GET", "ApiController@get", $parameters = array('id' => $id), array(), array(), array());
     $this->assertResponseStatus(404);
 }