コード例 #1
0
 public function run()
 {
     foreach ($this->grants as $grant) {
         $thisGrant = new OAuthGrant(['id' => $grant]);
         $thisGrant->save();
     }
     foreach ($this->scopes as $scopeName => $scopeDescription) {
         $thisScope = new OAuthScope(['id' => $scopeName, 'description' => $scopeDescription]);
         $thisScope->save();
     }
 }
コード例 #2
0
 function updateAUserAvatar(APITester $I)
 {
     $client = factory(App\Models\OAuthClient::class, 1)->create();
     $grant = \App\Models\OAuthGrant::find('password');
     $client->oauth_grants()->attach($grant);
     $scopes = \App\Models\OAuthScope::all()->lists('id')->toArray();
     $client->oauth_scopes()->attach($scopes);
     $I->wantTo('Update a user avatar');
 }
コード例 #3
0
 function createAUserWithInvalidEmail(APITester $I)
 {
     $client = factory(App\Models\OAuthClient::class, 1)->create();
     $grant = \App\Models\OAuthGrant::find('password');
     $client->oauth_grants()->attach($grant);
     $scopes = \App\Models\OAuthScope::all()->lists('id')->toArray();
     $client->oauth_scopes()->attach($scopes);
     $I->wantTo('See an error message when providing an incorrect email');
     $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
     $I->sendPOST('users', ['username' => 'username', 'email' => 'testnotcorrect', 'password' => 'password', 'password_conf' => 'password']);
     $I->seeResponseCodeIs(400);
     $I->seeResponseIsJson();
     $I->seeResponseContainsJson(['status' => 'fail']);
 }
コード例 #4
0
 function obtainAuthCodeGrantRedirectsToLogin(ApiTester $I)
 {
     $client = factory(App\Models\OAuthClient::class, 1)->create();
     $grant = \App\Models\OAuthGrant::find('authorization_code');
     $client->oauth_grants()->attach($grant);
     $scope = \App\Models\OAuthScope::find('user_read');
     $client->oauth_scopes()->attach($scope);
     $endpoint = factory(App\Models\OAuthClientEndpoint::class, 1)->make();
     $endpoint->oauth_client()->associate($client);
     $endpoint->save();
     $I->wantTo('Be redirected to login page when un authenticated user visits auth code page');
     $I->amOnPage('authorize?client_id=' . $client->id . '&redirect_uri=' . $endpoint->redirect_uri . '&response_type=code&scope=user_read');
     $I->seeInCurrentUrl('login');
 }