예제 #1
0
 public function export(ApiTester $I)
 {
     $I->createAndLoginUser();
     $I->createProjectAndSetHeader();
     $I->createTable();
     $I->sendGET('api/v1/projects/export');
     $I->seeResponseCodeIs(200);
     $I->seeResponseMatchesJsonType(['url' => 'string'], '$.data');
     $I->assertTrue(false !== file_get_contents($I->getResponseFields()->data->url));
 }
 function obtainAuthCodeGrant(ApiTester $I)
 {
     $user = factory(App\Models\User::class, 1)->create();
     $user->password = '******';
     $user->save();
     $I->amLoggedAs($user);
     $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('Perform a full 3rd party authorisation flow and get an access token');
     $I->amOnPage('authorize?client_id=' . $client->id . '&redirect_uri=' . $endpoint->redirect_uri . '&response_type=code&scope=user_read');
     $I->click('approve');
     $I->seeInCurrentUrl('code=');
     $url = Request::fullUrl();
     $parts = parse_url($url);
     parse_str($parts['query'], $query);
     $code = $query['code'];
     $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
     $I->sendPOST('oauth/access_token', ['grant_type' => 'authorization_code', 'client_id' => $client->id, 'client_secret' => $client->secret, 'redirect_uri' => $endpoint->redirect_uri, 'code' => $code]);
     $I->seeResponseCodeIs(200);
     $I->seeResponseIsJson();
     $I->seeResponseMatchesJsonType(['access_token' => 'string']);
 }
예제 #3
0
 public function createInvalid(ApiTester $I)
 {
     $I->createAndLoginUser();
     $I->createProjectAndSetHeader();
     $table_id = $I->createTable()->_id;
     $I->sendPOST("api/v1/tables/{$table_id}/decisions", ['internal_credit_history' => 'okay']);
     $I->seeResponseCodeIs(422);
     $I->seeResponseMatchesJsonType(['borrowers_phone_verification' => 'array', 'contact_person_phone_verification' => 'array', 'property' => 'array', 'employment' => 'array'], '$.data');
     $I->sendPOST("api/v1/tables/{$table_id}/decisions", ['internal_credit_history' => 'okay', 'borrowers_phone_verification' => 'okay', 'contact_person_phone_verification' => 'okay', 'property' => 'okay', 'employment' => 'okay']);
     $I->seeResponseCodeIs(422);
     $I->seeResponseMatchesJsonType(['property' => 'array', 'employment' => 'array'], '$.data');
 }
<?php

/** @var AcceptanceTester $I */
$I = new ApiTester($scenario);
$I->wantTo('get list of frameworks');
$I->sendGET('/api/frameworks');
$I->seeResponseCodeIs(200);
$I->dontSeeResponseCodeIs(500);
$I->canSeeHttpHeader('Content-Type', 'application/json');
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['name' => 'Phalcon', 'version' => '2.0.8']);
$I->seeResponseMatchesJsonType(['name' => 'string', 'version' => 'string:regex(~\\d\\.\\d\\.\\d~)']);
예제 #5
0
<?php

Yii::$app->redis->executeCommand('FLUSHDB');
use Codeception\Util\Debug;
$model = new \app\models\Message();
$model->author_email = '*****@*****.**';
$model->author_name = 'test';
$model->message = str_repeat('A', 140);
$model->save();
$I = new ApiTester($scenario);
$I->wantTo('Ver uma mensagem');
$I->sendGET('messages/' . $model->id);
$I->seeResponseIsJson();
$I->seeResponseMatchesJsonType(['id' => 'string', 'author_name' => 'string', 'author_email' => 'string:email', 'creation_time' => 'string', 'message' => 'string']);