public function testCaptureFlag()
 {
     $token = $this->doLogin('*****@*****.**', '123456');
     $this->tester->haveHttpHeader('Content-type', 'application/json');
     $this->tester->haveHttpHeader('X-Api-token', $token);
     $region = rand(1, 4);
     $this->tester->sendPOST('/api/capture-flag', json_encode(['regionId' => $region]));
     $this->tester->seeResponseCodeIs(200);
     $this->tester->seeResponseIsJson();
     $this->tester->haveHttpHeader('Content-type', 'application/json');
     $this->tester->haveHttpHeader('X-Api-token', $token);
     $this->tester->sendGET('/api/player-status');
     $this->tester->seeResponseCodeIs(200);
     $this->tester->seeResponseIsJson();
     $data = json_decode($this->tester->grabResponse(), true);
     $myTeamId = $data['data']['id'];
     $this->tester->haveHttpHeader('Content-type', 'application/json');
     $this->tester->sendGET('/api/game-status/1');
     $this->tester->seeResponseCodeIs(200);
     $this->tester->seeResponseIsJson();
     $data = json_decode($this->tester->grabResponse(), true);
     $data = $data['data'];
     $this->assertArrayHasKey('ownerRegion1', $data);
     $this->assertArrayHasKey('ownerRegion2', $data);
     $this->assertArrayHasKey('ownerRegion3', $data);
     $this->assertArrayHasKey('ownerRegion4', $data);
     //        $this->assertEquals($data['ownerRegion' . $region]['id'], $myTeamId);
 }
 public function doCheckLogout($token)
 {
     // Do Logout
     $this->tester->haveHttpHeader('Content-type', 'application/json');
     $this->tester->haveHttpHeader('X-Api-Token', $token);
     $this->tester->sendPOST('/api/logout');
     $this->tester->seeResponseCodeIs(200);
     $this->tester->seeResponseIsJson();
     // Check is logged out
     $this->checkIsLogin($token, false);
 }
 public function testSubmitLocation()
 {
     $token = $this->doLogin('*****@*****.**', '123456');
     $latLng = AppBundle\Helper\LatLngHelper::getRandomLatLngNear(46.308245, 16.337884);
     $this->tester->haveHttpHeader('Content-type', 'application/json');
     $this->tester->haveHttpHeader('X-Api-token', $token);
     $this->tester->sendPOST('/api/locations', json_encode(['lat' => $latLng['lat'], 'lng' => $latLng['lng']]));
     $this->tester->seeResponseCodeIs(200);
     $this->tester->seeResponseIsJson();
     $this->tester->seeResponseJsonMatchesJsonPath('$.status');
     $this->tester->seeResponseJsonMatchesJsonPath('$.message');
 }
예제 #4
0
 public function invalidTime(ApiTester $I)
 {
     $I->am('an invalid device');
     $I->wantTo('verify the endpoint returns validation failures - invalid time');
     //Send a bad code to the endpoint
     $I->haveHttpHeader('Content-Type', 'application/json');
     $I->haveHttpHeader('Accept', 'application/json');
     $I->sendPOST('/acs', ['device' => 'main-door', 'tag' => 'ABCDEF123456', 'message' => 'boot', 'service' => 'entry', 'time' => 'abcdefgh']);
     $I->canSeeResponseCodeIs(422);
 }
 /**
  * @depends WebserviceIsAvailable
  */
 public function create(ApiTester $I)
 {
     $I->wantTo('POST a new Contact in com_contacts');
     $I->amHttpAuthenticated('admin', 'admin');
     $I->sendPOST('index.php' . '?option=contact' . '&api=Hal' . '&webserviceClient=administrator' . '&webserviceVersion=1.0.0' . "&name={$this->name}" . '&catid=4');
     $I->seeResponseCodeIs(201);
     $I->seeResponseIsJson();
     $contactIDs = $I->grabDataFromResponseByJsonPath('$.id');
     $this->id = $contactIDs[0];
     $I->comment("The id of the new created user is: {$this->id}");
 }
 public function createUser(ApiTester $I, \Codeception\Scenario $scenario)
 {
     //$scenario->skip('ownCloud master is broken');
     $I->wantTo('create a user via the provisioning API');
     $I->amHttpAuthenticated('admin', 'admin');
     $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
     $I->sendPOST($this->apiUrl . '/users', ['userid' => $this->userId, 'password' => 'test' . $this->userId]);
     $I->seeResponseCodeIs(200);
     $I->seeResponseIsXml();
     $I->seeXmlResponseIncludes(XmlUtils::toXml(['status' => 'ok']));
 }
 public function createPost(ApiTester $I)
 {
     $I->sendPOST($this->endpoint, ['title' => 'Game of Rings', 'body' => 'By George Tolkien']);
     $I->seeResponseCodeIs(200);
     $I->seeResponseIsJson();
     $I->seeResponseContainsJson(['title' => 'Game of Rings']);
     $id = $I->grabDataFromJsonResponse('id');
     $I->seeRecord('posts', ['id' => $id, 'title' => 'Game of Rings']);
     $I->sendGET($this->endpoint . "/{$id}");
     $I->seeResponseCodeIs(200);
     $I->seeResponseIsJson();
     $I->seeResponseContainsJson(['title' => 'Game of Rings']);
 }
 public function successfullEnd(ApiTester $I)
 {
     $I->am('a valid user');
     $I->wantTo('verify the endpoint returns a success response and creates the proper records');
     $user = $I->getActiveKeyholderMember();
     $keyFob = $I->getMemberKeyFob($user->id);
     //Send a bad code to the endpoint
     $I->sendPOST('/access-control/device', ['data' => $keyFob->key_id . '|welder|start']);
     //The device endpoint always returns 200
     $I->canSeeResponseCodeIs(200);
     //Make sure a success is returned and a session started
     $I->canSeeResponseContainsJson(['valid' => '1']);
     $I->seeInDatabase('equipment_log', ['user_id' => $user->id, 'device' => 'welder', 'active' => 1]);
     $I->sendPOST('/access-control/device', ['data' => $keyFob->key_id . '|welder|end']);
     $I->canSeeResponseCodeIs(200);
     $I->dontSeeHttpHeader('Set-Cookie');
     $I->dontSeeHttpHeader('Built-By');
     $I->canSeeResponseContainsJson(['valid' => '1']);
     //Make sure our database record is not active
     $I->seeInDatabase('equipment_log', ['user_id' => $user->id, 'device' => 'welder', 'active' => 0]);
     //And make sure there is no other active record
     $I->cantSeeInDatabase('equipment_log', ['user_id' => $user->id, 'device' => 'welder', 'active' => 1]);
 }
예제 #9
0
 public function createDiscussion(ApiTester $I)
 {
     $I->wantTo('create a discussion via API');
     $I->amAuthenticated();
     $I->sendPOST($this->endpoint, ['discussions' => ['title' => 'foo', 'content' => 'bar']]);
     $I->seeResponseCodeIs(200);
     $I->seeResponseIsJson();
     $I->expect('the discussion is included in the response');
     $I->seeResponseContainsJson(['title' => 'foo']);
     $I->expect('posts are included in the response');
     $I->seeResponseContainsJson(['type' => 'comment', 'contentHtml' => '<p>bar</p>']);
     $I->expect('the discussion was created in the database');
     $id = $I->grabDataFromJsonResponse('discussions.id');
     $I->seeRecord('discussions', ['id' => $id, 'title' => 'foo']);
 }
예제 #10
0
<?php

$request_body = ['interaction_id' => 'SD000000009', 'message' => 'Hey yo this is a test'];
$response_body = ['success' => 'Request for additional information successful!'];
$I = new ApiTester($scenario);
$I->wantTo('send request for additional information to user (through push notification and log update)');
//$I->haveHttpHeader('Content-Type', 'application/json');
//$I->sendGET('/request_info?id=SD000000008');
$I = new ApiTester($scenario);
$I->wantTo('ask for additional information');
$I->haveHttpHeader('Content-Type', 'application/json');
$I->sendPOST('/request_info/', $request_body);
//$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson($response_body);
예제 #11
0
 public function variantsProbabilityInvalid(ApiTester $I)
 {
     $I->createAndLoginUser();
     $I->createProjectAndSetHeader();
     # invalid variants_probability
     $data = $I->getTableShortData();
     $data['variants_probability'] = 'invalid';
     $I->sendPOST('api/v1/admin/tables', $data);
     $I->seeResponseCodeIs(422);
     $I->seeResponseContains('variants_probability');
     # more than 100
     $data['variants_probability'] = 'percent';
     $data['variants'][0]['probability'] = 30;
     $data['variants'][0]['title'] = 'Variant 1';
     $data['variants'][1] = ['title' => 'Variant 2', 'default_title' => 'Variant 2', 'default_description' => 'Description Variant 2', 'default_decision' => 'Decline', 'probability' => 71, 'rules' => $I->getVariantRules()];
     $I->sendPOST('api/v1/admin/tables', $data);
     $I->seeResponseCodeIs(422);
     $I->seeResponseContains('variants_probability');
     # less than 100
     $data['variants'][0]['probability'] = 28;
     $I->sendPOST('api/v1/admin/tables', $data);
     $I->seeResponseCodeIs(422);
     $I->seeResponseContains('variants_probability');
 }
 public function unknownDeviceSystemMessage(ApiTester $I)
 {
     $I->am('sending a valid system message');
     $I->wantTo('confirm it is received and handled correctly');
     //Post the keyfob to the endpoint
     $I->sendPOST('/access-control/main-door', ['data' => ':unknown|unknown']);
     //The endpoint always returns 200
     $I->seeResponseCodeIs(200);
     //Confirm an access log record was created
     //$I->seeInDatabase('access_log', ['user_id'=>$user->id, 'key_fob_id'=>$keyFob->id, 'response'=>200, 'service'=>'main-door']);
 }
예제 #13
0
<?php

$I = new ApiTester($scenario);
$I->wantTo('Get list of hotels');
$I->sendPOST('/hotels-api', []);
$I->seeResponseContains('{"id":"1","title":"Tonyresort","image":"http:\\/\\/andriuss.ktu.ongr.rocks\\/src\\/Frontend\\/Files\\/hotels\\/images\\/source\\/download(6).jpg","country":"Lithuania","city":"Vilnius"},{"id":"3","title":"Kaunas","image":"http:\\/\\/andriuss.ktu.ongr.rocks\\/src\\/Frontend\\/Files\\/hotels\\/images\\/source\\/36207618.jpg","country":"Lithuania","city":"Kaunas"},{"id":"4","title":"Gaia Village","image":"http:\\/\\/andriuss.ktu.ongr.rocks\\/src\\/Frontend\\/Files\\/hotels\\/images\\/source\\/211050_xl.jpg","country":null,"city":null},{"id":"5","title":"Europa Royale","image":"http:\\/\\/andriuss.ktu.ongr.rocks\\/src\\/Frontend\\/Files\\/hotels\\/images\\/source\\/big_4ac32e645761a.jpg","country":null,"city":null}');
예제 #14
0
 public function getCurrentUserScope(ApiTester $I)
 {
     $user = $I->createAndLoginUser();
     $I->createProjectAndSetHeader();
     $I->loginClient($I->getCurrentClient());
     $second_user = $I->createUser(true);
     $I->loginUser($user);
     $I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id, 'role' => 'manager', 'scope' => ['tables_view', 'tables_update']]);
     $I->loginUser($second_user);
     $I->sendGET('api/v1/projects/users');
     $I->assertProjectUser();
 }
예제 #15
0
<?php

$I = new ApiTester($scenario);
$I->wantTo('Get list of hotels');
$I->sendPOST('/hotels-api/detail/1', []);
$I->seeResponseContains('{"id":"2","title":"Vip","price":"180","image":"http:\\/\\/andriuss.ktu.ongr.rocks\\/src\\/Frontend\\/Files\\/rooms\\/images\\/source\\/vip_ton.jpg","count":"2","available_rooms":"2"},{"id":"3","title":"Standart","price":"100","image":"http:\\/\\/andriuss.ktu.ongr.rocks\\/src\\/Frontend\\/Files\\/rooms\\/images\\/source\\/standart_ton.jpg","count":"6","available_rooms":"6"},{"id":"4","title":"Family","price":"200","image":"http:\\/\\/andriuss.ktu.ongr.rocks\\/src\\/Frontend\\/Files\\/rooms\\/images\\/source\\/family_ton.jpg","count":"4","available_rooms":"4"}');
예제 #16
0
파일: GamesCept.php 프로젝트: AndriyK/team
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('games');
$games = $I->grabDataFromResponseByJsonPath('$.games')[0];
\PHPUnit_Framework_Assert::assertEquals(2, count($games));
$I->seeResponseContains('training');
$I->seeResponseContains('evening game');
// check for empty list for team with no games
$I->sendGET('/teams/27?expand=games');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('games');
$games = $I->grabDataFromResponseByJsonPath('$.games')[0];
\PHPUnit_Framework_Assert::assertEquals(0, count($games));
// create game
$I->sendPOST('/games', ['team_id' => 26, 'datetime' => date("Y-m-d H:i:s"), 'location' => "home", 'title' => "important game"]);
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContains('important game');
$I->seeResponseContains('home');
$gameId = $I->grabDataFromResponseByJsonPath('$.id')[0];
$I->sendGET('/teams/26?expand=games');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('games');
$games = $I->grabDataFromResponseByJsonPath('$.games')[0];
\PHPUnit_Framework_Assert::assertEquals(3, count($games));
// Join one player to the game
$I->sendPUT("/games/{$gameId}", ['join_player' => 33]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
예제 #17
0
<?php

$request_body = ['gm_id' => '1Z3967', 'token' => 'Works for me'];
$response_body = ['work_phone' => '517-555-4356'];
$I = new ApiTester($scenario);
$I->wantTo('update device token for a user');
$I->haveHttpHeader('Content-Type', 'application/json');
$I->sendPOST('/device_token.php', $request_body);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson($response_body);
예제 #18
0
<?php

$I = new ApiTester($scenario);
$I->wantTo('log in as an anonymous user');
$I->sendPOST('users/login');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseJsonMatchesJsonPath('$.skey');
$I->seeResponseJsonMatchesJsonPath('$.userid');
$I->seeResponseJsonMatchesJsonPath('$.email');
$guidResponse = $I->getRequestJSON();
$I->wantTo('log in as an anonymous user using a previous GUID');
$I->sendPOST('users/login', ['username' => $guidResponse['email']]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJSON(['email' => $guidResponse['email']]);
$I->seeResponseContainsJSON(['userid' => $guidResponse['userid']]);
$I->wantTo('fail to log in with an unregistered CCID');
$I->sendPOST('users/login', ['username' => '@12345678']);
$I->seeResponseCodeIs(401);
$I->wantTo('fail to log in with an incorrect CCID password');
$I->sendPOST('users/login', ['username' => '*****@*****.**', 'password' => 'obviouslybadpassword']);
$I->seeResponseCodeIs(401);
<?php

//has to be called first (thus 1LoginCept.php) because of the private keys after sql file import.
$I = new ApiTester($scenario);
$I->wantTo('login via POST');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
$I->haveHttpHeader('Accept', 'application/json;charset=utf-8');
$I->sendPOST('login', json_encode(array('username' => 'demo', 'password' => 'demo')));
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array("error" => false, "login_id" => 123, "username" => "demo", "group_id" => 3, "locale" => "en", "public_key" => "248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6", "access_level" => " AND (facilities.FacilityID = 11 OR facilities.FacilityID = 14 OR facilities.FacilityID = 13 OR facilities.FacilityID = 17 OR facilities.FacilityID = 16 OR facilities.FacilityID = 15 OR facilities.FacilityID = 12)"));
<?php

$I = new ApiTester($scenario);
$I->wantTo('create new intervention via POST');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
//no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '34756c567620857fac3539130db7c4e7d52162c7c349baeb82f635cf7003716a');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
//no whitespaces in json
$I->sendPOST('asset/4b6342489a963/532c5ad50d547/intervention', '{"Date":"2014-01-01","EmployeeID":"4d64045c4a525","AssetStatusID":1,"FaildPart":"Cable","FailurCategID":2,"FailureCauseID":1,"Interv_desc":"cables fixed","Comments":"repeat","RespEng":"4c8fcac9f06fa","TotalWork":1,"TotalCosts":2}');
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array("error" => false));
$I->seeResponseContainsJson(array("message" => "Intervention added"));
$I->seeInDatabase('intervention', array('AssetID_Visit' => '4b6342489a963', "Request_id" => '532c5ad50d547', "EmployeeID" => "4d64045c4a525"));
<?php

$I = new ApiTester($scenario);
$I->wantTo('get new pid for a user');
$I->haveHttpHeader(' Content-Type', 'xxyyzz');
$I->sendPOST('http://localhost/api/v1/action/GetPid.php', json_encode(array('action' => 'GetPid')));
$I->seeResponseCodeIs(400);
$I->seeResponseIsJson();
<?php

$I = new ApiTester($scenario);
$I->wantTo('create new intervention work via POST');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
$I->haveHttpHeader('X-Hash', 'f6ddc80ba5123475c102ba654f5092e130df09bcec335e503db7757468cb7428');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
//no whitespaces in json
$I->sendPOST('intervention/work', '{"IntervID":"532c5b53aab95","Action":"yesitis","Date_action":"2014-01-01","Time":20}');
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array("error" => false));
$I->seeResponseContainsJson(array("message" => "Intervention work created"));
$I->seeInDatabase('intervention_work', array("IntervID" => "532c5b53aab95", "Action" => "yesitis"));
 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']);
 }
예제 #24
0
 public function canNotEditItself(ApiTester $I)
 {
     $user = $I->createAndLoginUser();
     $I->createProjectAndSetHeader();
     $I->sendPUT('api/v1/projects/users', ['user_id' => $user->_id, 'role' => 'manager', 'scope' => ['tables_view', 'tables_update', 'users_manage']]);
     $I->seeResponseCodeIs(403);
     $I->loginClient($I->getCurrentClient());
     $second_user = $I->createUser(true);
     $I->loginUser($user);
     $I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id, 'role' => 'manager', 'scope' => ['tables_view', 'tables_update', 'users_manage']]);
     $I->seeResponseCodeIs(201);
     $I->loginUser($second_user);
     $I->sendPUT('api/v1/projects/users', ['user_id' => $user->_id, 'role' => 'manager', 'scope' => ['tables_view', 'tables_update', 'users_manage']]);
     $I->seeResponseCodeIs(403);
     $I->loginUser($user);
     $I->sendPOST('api/v1/projects/users/admin', ['user_id' => $second_user->_id]);
     $I->seeResponseCodeIs(200);
     $I->loginUser($second_user);
     $I->sendPUT('api/v1/projects/users', ['user_id' => $user->_id, 'role' => 'manager', 'scope' => ['tables_view', 'tables_update', 'users_manage']]);
     $I->seeResponseCodeIs(200);
 }
예제 #25
0
파일: UpdateCept.php 프로젝트: GM-Team/web
<?php

$request_body = ['interaction_id' => 'SD000000099', 'category' => 'Laptop', 'issue' => 'Wont turn on!', 'status' => 'Submitted', 'description' => 'Yes, I have it plugged in!', 'affected_service' => 'Laptop', 'notify_type' => 'CALLME', 'phase' => 'WIP', 'last_update_date' => '7-7-17, 7:57:57 PM EDT'];
$response_body = ['status' => 'Successful update'];
$I = new ApiTester($scenario);
$I->wantTo('update a ticket');
$I->haveHttpHeader('Content-Type', 'application/json');
$I->sendPOST('/tickets/', $request_body);
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContainsJson($response_body);
예제 #26
0
<?php

$I = new ApiTester($scenario);
$I->wantTo('create a new device');
$user = $I->haveAnAccount();
$I->amHttpAuthenticated($user['email'], $user['password']);
$I->sendPOST('devices', ['mac' => '00:19:20:A1:B4:FC', 'name' => 'Manuel']);
$I->seeResponseCodeIs(422);
$I->seeResponseIsJson();
$I->sendPOST('devices', ['ip' => '192.168.1.123', 'mac' => '00:19:20:A1:B4:FC', 'name' => 'Manuel']);
$I->seeResponseCodeIs(201);
$I->seeHttpHeader('Location', 'http://localhost/api/v1/devices/1');
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['data' => ['ip' => '192.168.1.123', 'name' => 'Manuel', 'on_home_page' => 'auto', 'group' => null]]);
$I->seeResponseJsonMatchesXpath('//data//device_added');
$I->seeResponseJsonMatchesXpath('//data//last_contact');
$I->seeRecord('devices', ['ip' => '192.168.1.123', 'mac' => '00:19:20:A1:B4:FC', 'name' => 'Manuel', 'public' => 'auto', 'group' => null]);
<?php

$I = new ApiTester($scenario);
$I->wantTo('adicionar um novo pedido');
$I->amHttpAuthenticated('phptesting', '123');
$I->sendPOST('/pedido', ['produtoid' => 1, 'produtonome' => 'Firefox', 'produtoestoque' => 10, 'produtovalor' => 49.9]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['status' => 'sucesso', 'message' => 'Sucesso']);
예제 #28
0
<?php

Yii::$app->redis->executeCommand('FLUSHDB');
use Codeception\Util\Debug;
$I = new ApiTester($scenario);
$I->wantTo('Inserir uma mensagem');
$I->sendPOST('messages', ['author_name' => 'test', 'author_email' => '*****@*****.**', 'message' => 'a new message']);
$I->seeResponseIsJson();
$I->seeResponseJsonMatchesJsonPath('$[author_name');
$I->seeResponseJsonMatchesJsonPath('$.author_email');
$I->seeResponseJsonMatchesJsonPath('$.message');
$I->seeResponseJsonMatchesJsonPath('$.id');
$I->seeResponseJsonMatchesJsonPath('$.creation_time');
예제 #29
0
for ($i = 0; $i < $archiveSize; $i++) {
    $data .= chr(rand(0, 255));
}
$data[0] = 'A';
$data[1] = 'B';
$data[2] = 'C';
$data[3] = 'D';
$treeHash = new TreeHash();
$treeHash->update($data);
$treeHash = bin2hex($treeHash->complete());
$hash = hash('sha256', $data);
$I->haveHttpHeader('Content-Type', 'application/octet-stream');
$I->haveHttpHeader('x-amz-archive-description', 'test123');
$I->haveHttpHeader('x-amz-sha256-tree-hash', $treeHash);
$I->haveHttpHeader('x-amz-content-sha256', $hash);
$I->sendPOST('/-/vaults/testvault/archives', $data);
$I->seeResponseCodeIs(201);
$I->seeResponseEquals('');
$archiveID = $I->grabHttpHeader('x-amz-archive-id');
$I->haveHttpHeader('Content-Type', 'application/json');
$I->sendPOST('/-/vaults/testvault/jobs', ['Type' => 'archive-retrieval', 'ArchiveId' => $archiveID]);
$I->seeResponseCodeIs(202);
$jobID = $I->grabHttpHeader('x-amz-job-id');
$I->sendGET("/-/vaults/testvault/jobs/{$jobID}");
$I->seeResponseCodeIs(200);
$I->seeResponseContainsJson(['StatusCode' => 'InProgress']);
$I->sendPOST("/-/vaults/testvault/jobs/{$jobID}/force-complete", []);
$I->seeResponseCodeIs(200);
$I->sendGET("/-/vaults/testvault/jobs/{$jobID}");
$I->seeResponseCodeIs(200);
$I->seeResponseContainsJson(['StatusCode' => 'Succeeded']);
<?php

$I = new ApiTester($scenario);
$I->wantTo('create a request on a asset via POST');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
//no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '9fdcd3d292ce958b3d14c803aba077c965e54ebb1b991fee0d01038c9e8951c5');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
$I->sendPOST('asset/4b674c6d9e9ff/request', '{"Request_date":"2014-02-14","Request_desc":"blob","Request_contact_name":"Nicola Keller","Request_note":"somenotes","Request_st_id":"1","VisiTpID":"4"}');
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
//we don't test request_id response because its everytime different (PHP's uniqid())
$I->seeResponseContainsJson(array("error" => false));
$I->seeResponseContainsJson(array("message" => "Request added"));
$I->seeInDatabase('request', array("AssetID" => "4b674c6d9e9ff", "Request_contact_name" => "Nicola Keller"));