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'); }