public function checkLogin(APITester $I) { $I->amHttpAuthenticated('admin', 'testpassword'); $I->sendGET('/login'); $I->seeResponseCodeIs(201); $I->seeResponseIsJson(); $I->seeResponseContainsJson(['status' => 'ok']); }
public function boot(APITester $I) { $I->amHttpAuthenticated('admin', 'testpassword'); $I->sendGET('/login'); $I->seeResponseCodeIs(201); $json = $I->grabResponse(); $this->token = json_decode($json)->token; }
public function listFiles(APITester $I) { $I->amBearerAuthenticated($this->token); $I->sendGET('/files'); $I->seeResponseCodeIs(200); $I->seeResponseJsonMatchesJsonPath('$.[*]'); $I->dontSeeResponseJsonMatchesJsonPath('$.[*].*'); }
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']); }
public function showUser(APITester $I) { $I->amBearerAuthenticated($this->token); $I->sendGET('/users/admin'); $I->seeResponseCodeIs(200); $I->seeResponseJsonMatchesJsonPath('$.[*]'); $I->seeResponseJsonMatchesJsonPath('$.username'); $I->dontSeeResponseJsonMatchesJsonPath('$.password'); }
public function showConfig(APITester $I) { $I->amBearerAuthenticated($this->token); $I->sendGET('/config/site'); $I->seeResponseCodeIs(200); $I->seeResponseJsonMatchesJsonPath('$.[*]'); $I->seeResponseJsonMatchesJsonPath('$.title'); $I->seeResponseJsonMatchesJsonPath('$.theme'); }
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 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(); }
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');