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));
 }
Exemple #2
0
 /**
  * testDeleteExisting
  * @covers deletes an existing api scope
  */
 public function testDeleteExisting()
 {
     $scope = ApiScope::where('name', '=', sprintf('%s/api-scope/read', $this->current_realm))->first();
     $this->assertTrue(!is_null($scope));
     $id = $scope->id;
     $response = $this->action("DELETE", "ApiScopeController@delete", $parameters = array('id' => $id), array(), array(), array());
     $this->assertResponseStatus(204);
 }
 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);
 }
 public function testRemoveRequiredScope()
 {
     $api_endpoint = ApiEndpoint::where('name', '=', 'update-api-endpoint-status')->first();
     $this->assertTrue(!is_null($api_endpoint));
     $scope = ApiScope::where('name', '=', sprintf('%s/api-endpoint/update', $this->current_realm))->first();
     $this->assertTrue(!is_null($scope));
     $response = $this->action("DELETE", "ApiEndpointController@removeRequiredScope", array('id' => $api_endpoint->id, 'scope_id' => $scope->id), array(), array(), array());
     $this->assertResponseStatus(200);
     $content = $response->getContent();
     $response = json_decode($content);
     $this->assertTrue($response === 'ok');
     $response = $this->action("GET", "ApiEndpointController@get", $parameters = array('id' => $api_endpoint->id), array(), array(), array());
     $content = $response->getContent();
     $response_api_endpoint = json_decode($content);
     $this->assertTrue(is_array($response_api_endpoint->scopes) && count($response_api_endpoint->scopes) == 1);
     $this->assertResponseStatus(200);
 }
Exemple #5
0
 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);
 }