Beispiel #1
0
 public function boot(APITester $I)
 {
     $I->amHttpAuthenticated('admin', 'testpassword');
     $I->sendGET('/login');
     $I->seeResponseCodeIs(201);
     $json = $I->grabResponse();
     $this->token = json_decode($json)->token;
 }
 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');
 }
Beispiel #3
0
 public function showTheme(APITester $I)
 {
     $I->amBearerAuthenticated($this->token);
     $I->sendGET('/themes/galaxy');
     $I->seeResponseCodeIs(200);
     $I->seeResponseJsonMatchesJsonPath('$.[*]');
     $I->seeResponseJsonMatchesJsonPath('$.name');
     $I->seeResponseJsonMatchesJsonPath('$.layouts.[*]');
     $I->seeResponseJsonMatchesJsonPath('$.infos.[*]');
     $I->dontSeeResponseJsonMatchesJsonPath('$.layouts.[*].[*]');
 }
 function createAUserWithMissingEmail(APITester $I)
 {
     $I->wantTo('See an error message when missing an email');
     $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
     $I->sendPOST('users', ['username' => 'username', 'password' => 'password', 'password_conf' => 'password']);
     $I->seeResponseCodeIs(400);
     $I->seeResponseIsJson();
     $I->seeResponseContainsJson(['status' => 'fail']);
 }
Beispiel #5
0
 public function showUser(APITester $I)
 {
     $I->amBearerAuthenticated($this->token);
     $I->sendGET('/users/admin');
     $I->seeResponseCodeIs(200);
     $I->seeResponseJsonMatchesJsonPath('$.[*]');
     $I->seeResponseJsonMatchesJsonPath('$.username');
     $I->dontSeeResponseJsonMatchesJsonPath('$.password');
 }
Beispiel #6
0
 public function showConfig(APITester $I)
 {
     $I->amBearerAuthenticated($this->token);
     $I->sendGET('/config/site');
     $I->seeResponseCodeIs(200);
     $I->seeResponseJsonMatchesJsonPath('$.[*]');
     $I->seeResponseJsonMatchesJsonPath('$.title');
     $I->seeResponseJsonMatchesJsonPath('$.theme');
 }
Beispiel #7
0
 public function checkLogin(APITester $I)
 {
     $I->amHttpAuthenticated('admin', 'testpassword');
     $I->sendGET('/login');
     $I->seeResponseCodeIs(201);
     $I->seeResponseIsJson();
     $I->seeResponseContainsJson(['status' => 'ok']);
 }
Beispiel #8
0
 public function listFiles(APITester $I)
 {
     $I->amBearerAuthenticated($this->token);
     $I->sendGET('/files');
     $I->seeResponseCodeIs(200);
     $I->seeResponseJsonMatchesJsonPath('$.[*]');
     $I->dontSeeResponseJsonMatchesJsonPath('$.[*].*');
 }
 function cantObtainClientGrantWithInvalidCredentials(APITester $I)
 {
     $client = factory(App\Models\OAuthClient::class, 1)->create();
     $grant = \App\Models\OAuthGrant::find('client_credentials');
     $client->oauth_grants()->attach($grant);
     $scope = \App\Models\OAuthScope::find('user_read');
     $client->oauth_scopes()->attach($scope);
     $I->wantTo('Send bad client credentials and receive an error');
     $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
     $I->sendPOST('oauth/access_token', ['grant_type' => 'client_credentials', 'client_id' => $client->id, 'client_secret' => 'badsecret', 'scope' => 'user_read']);
     $I->seeResponseCodeIs(401);
     $I->seeResponseIsJson();
 }
Beispiel #10
0
 public function cannotDeleteAPage(APITester $I)
 {
     $I->amBearerAuthenticated($this->token);
     $I->sendDelete('/pages/' . $this->page1['slug']);
     $I->seeResponseCodeIs(404);
 }
<?php

$I = new APITester($scenario);
$I->wantTo('Test if SAP is online');
$I->sendGET('http://sap.prefeitura.unicamp.br/sap/pesquisa_achados_perdidos.jsf');
$I->seeResponseCodeIs(200);
$I->seeHttpHeader('Set-Cookie');
$cookie = $I->grabHttpHeader('Set-Cookie');
$I->assertContains("JSESSIONID", $cookie);
$I->seeResponseContains('javax.faces.ViewState');