예제 #1
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);
 }
 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 testGetLocationsWithFilters()
 {
     $token = $this->doLogin('*****@*****.**', '123456');
     $this->tester->haveHttpHeader('Content-type', 'application/json');
     $this->tester->haveHttpHeader('X-Api-token', $token);
     $filter = ['game' => 1];
     $this->tester->sendGET('/api/locations', $filter);
     $this->checkLocationList();
     $data = json_decode($this->tester->grabResponse(), true);
     foreach ($data['data'] as $item) {
         $this->assertEquals($filter['game'], $item['game']);
     }
 }
 public function deleteUser(ApiTester $I, \Codeception\Scenario $scenario)
 {
     //$scenario->skip('ownCloud master is broken');
     $I->wantTo('delete the user');
     $I->amHttpAuthenticated('admin', 'admin');
     $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
     $I->sendDELETE($this->apiUrl . '/users/' . $this->userId);
     $I->seeResponseCodeIs(200);
     $I->seeResponseIsXml();
     $I->seeXmlResponseIncludes(XmlUtils::toXml(['status' => 'ok']));
 }
 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);
 }
<?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"));
<?php

$I = new ApiTester($scenario);
$I->wantTo('create new asset with a missing parameter via POST');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
// no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '1ed208ed3103ce3e2d238cadca560a68be860773e7b8a4f5feab3ee0e30b4156');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
// no whitespaces in json
// Missing: SerialNumber field
$I->sendPOST('asset', '{"GenericAssetID":12636,"UMDNS":12636,"AssetFullName":"Dash","ManufacturerID":"4c44276c3c2c0","Model":"4000 ","InternalIventoryNumber":"01382928","LocationID":"4b6b4f5120321","ResponsiblePers":null,"AssetStatusID":"1","AssetUtilizationID":"1","PurchaseDate":null,"InstallationDate":null,"Lifetime":10,"PurchasePrice":131174,"CurrentValue":"104939","WarrantyContractID":"1","AgentID":"4c90677ca7db7","WarrantyContractExp":null,"WarrantyContractNotes":null,"EmployeeID":"4cb6b8bbb9df6","SupplierID":"4b595a7124c8b","DonorID":"4c9066fc81b53","ServiceManual":"","Notes":null,"Picture":"gen_images/12636.jpg","by_user":"******","URL_Manual":null,"MetrologyDocument":null,"MetrologyDate":null,"Metrology":"0"}');
$I->seeResponseCodeIs(400);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array("error" => true, "message" => "Required field SerialNumber missing, empty or null"));
<?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"));
<?php

$I = new ApiTester($scenario);
$I->wantTo('create new asset via POST');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
//no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '6fb6b38ce5277f1fdfce13e8aed07ccc5421c67c01d0580894c3f067503138ae');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
//no whitespaces in json
$I->sendPOST('asset', '{"GenericAssetID":12636,"UMDNS":12636,"AssetFullName":"Dash","ManufacturerID":"4c44276c3c2c0","Model":"4000 ","SerialNumber":"SD008484463GA","InternalIventoryNumber":"01382928","LocationID":"4b6b4f5120321","ResponsiblePers":null,"AssetStatusID":"1","AssetUtilizationID":"1","PurchaseDate":null,"InstallationDate":null,"Lifetime":10,"PurchasePrice":131174,"CurrentValue":"104939","WarrantyContractID":"1","AgentID":"4c90677ca7db7","WarrantyContractExp":null,"WarrantyContractNotes":null,"EmployeeID":"4cb6b8bbb9df6","SupplierID":"4b595a7124c8b","DonorID":"4c9066fc81b53","ServiceManual":"","Notes":null,"Picture":"gen_images/12636.jpg","by_user":"******","URL_Manual":null,"MetrologyDocument":null,"MetrologyDate":null,"Metrology":"0"}');
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array("error" => false, "message" => "Asset created"));
$I->seeInDatabase('assets', array('GenericAssetID' => '12636', "AssetFullName" => 'Dash'));
예제 #10
0
 public function _before(ApiTester $I)
 {
     $I->dropDatabase();
     $I->haveHttpHeader('Content-Type', 'application/json');
 }
예제 #11
0
$I->sendPUT('/-/vaults/testvault');
$I->seeResponseCodeIs(201);
$data = '';
$archiveSize = 1024 * 1024 + 10;
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", []);
<?php

$I = new ApiTester($scenario);
$I->wantTo('Test the database/export endpoint via GET');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
$I->haveHttpHeader('X-Hash', 'e651e0f6450f89d82ab0a34c1d421097a635897f5e719179e49263ff145e6ed9');
$I->sendGET('database/export');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array('assets' => array(0 => array('AssetID' => '4b67517f4462a', 'GenericAssetID' => '12636', 'UMDNS' => '12636', 'AssetFullName' => 'Dash', 'ManufacturerID' => '4c44276c3c2c0', 'Model' => '4000 ', 'SerialNumber' => 'SD008484463GA', 'InternalIventoryNumber' => '01382928', 'LocationID' => '4b6b4f5120321', 'ResponsiblePers' => NULL, 'AssetStatusID' => '1', 'AssetUtilizationID' => '1', 'PurchaseDate' => NULL, 'InstallationDate' => NULL, 'Lifetime' => '10', 'PurchasePrice' => '131174', 'CurrentValue' => '104939', 'WarrantyContractID' => '1', 'AgentID' => '4c90677ca7db7', 'WarrantyContractExp' => NULL, 'WarrantyContractNotes' => NULL, 'EmployeeID' => '4cb6b8bbb9df6', 'SupplierID' => '4b595a7124c8b', 'DonorID' => '4c9066fc81b53', 'Notes' => NULL, 'Picture' => 'gen_images/12636.jpg', 'lastmodified' => '2010-02-05 01:47:18', 'by_user' => 'demo', 'URL_Manual' => NULL, 'MetrologyDocument' => NULL, 'MetrologyDate' => NULL, 'Metrology' => '0'))));
$I->seeResponseContainsJson(array('location' => array(0 => array('LocationID' => '4b6b4f5120321', 'FacilityID' => '11', 'DeptID' => '2', 'Roomnb' => '', 'Floor' => '', 'Building' => '', 'NotetoTech' => '-'))));
$I->seeResponseContainsJson(array('facilities' => array(0 => array('FacilityID' => '11', 'DistrictID' => '10001', 'FacilityName' => 'Central Hosptial'))));
$I->seeResponseContainsJson(array('facilities' => array(0 => array('FacilityID' => '11', 'DistrictID' => '10001', 'FacilityName' => 'Central Hosptial'))));
$I->seeResponseContainsJson(array('contacttype' => array(0 => array('ContactTypeID' => '1', 'ContactTypeName' => 'Manufacturer'))));
$I->seeResponseContainsJson(array('contact' => array(0 => array('ContactID' => '4ac3718e8d251', 'ContactTypeID' => '3', 'ContactName' => 'Nespecificat', 'ContactPersonName' => NULL, 'ContactTitle' => NULL, 'Address' => NULL, 'City' => NULL, 'PostalCode' => NULL, 'CountryID' => '99999', 'PhoneNumber' => NULL, 'FaxNumber' => NULL, 'Website' => '', 'Services' => NULL))));
$I->seeResponseContainsJson(array('donors' => array(0 => array('DonorID' => '0', 'ContactID' => '4ac3718e8d251'))));
$I->seeResponseContainsJson(array('agents' => array(0 => array('AgentID' => '0', 'ContactID' => '4ac3718e8d251'))));
$I->seeResponseContainsJson(array('suppliers' => array(0 => array('SupplierID' => '4b59581a8bb8f', 'ContactID' => '4b59581a8abf1'))));
$I->seeResponseContainsJson(array('manufactures' => array(0 => array('ManufacturerID' => '4b0be58d2806b', 'ContactID' => '4b0be58d2612c'))));
$I->seeResponseContainsJson(array('consumables' => array(0 => array('ConsumableID' => '1', 'Name' => 'Sensor debit', 'ManufacturerID' => '4c62506a58149', 'PartNumber' => '121', 'PackageQty' => '1', 'SupplierID' => '4c36d8223e3cf', 'UnitPrice' => '1', 'Notes' => '1', 'lastmodified' => '2012-01-17 14:15:11', 'by_user' => 'demo', 'TypeCons' => NULL))));
$I->seeResponseContainsJson(array('consumables_linked' => array(0 => array('Consumable_linkedID' => '1', 'ConsumableID' => '1', 'AssetID' => '4f154ff62df0e', 'AnnualConsumption' => '100', 'Notes' => 'Order 2 month before'))));
$I->seeResponseContainsJson(array('employees' => array(0 => array('EmployeeID' => '0', 'LoginID' => '3', 'FirstName' => 'admin', 'LastName' => 'admin', 'Position' => NULL, 'TechnicianYN' => '1', 'LocationID' => '4b0be83d5d1d7', 'WorkPhone' => NULL, 'HandPhone' => NULL, 'Email' => NULL, 'Fax' => NULL, 'Accesslevel' => ' AND (facilities.FacilityID=12)'))));
$I->seeResponseContainsJson(array('department' => array(3 => array('DeptID' => '4', 'DepartmentDesc' => 'Allergology'))));
$I->seeResponseContainsJson(array('essential_equipment' => array(0 => array('EssentialEquipmentID' => '1', 'FacilityID' => '11', 'GenericAssetID' => '10134', 'MinimalQuantity' => '2', 'Notes' => NULL))));
$I->seeResponseContainsJson(array('assetgenericname' => array(0 => array('GenericAssetID' => '10134', 'GenericAssetCode' => '10134', 'GenericAssetName' => 'Anaesthesia Units', 'AssetCategoryID' => '5', 'GenericPicture' => 'gen_images/10134.jpg'))));
$I->seeResponseContainsJson(array('assetutilization' => array(0 => array('AssetUtilizationID' => '1', 'AssetUtilizationDesc' => 'Normal'))));
$I->seeResponseContainsJson(array('assetstatus' => array(0 => array('AssetStatusID' => '1', 'AssetStatusDesc' => 'Fully functional'))));
$I->seeResponseContainsJson(array('assetcategory' => array(0 => array('AssetCategoryID' => '1', 'AssetCategoryNr' => '1', 'AssetCategoryName' => 'Dental'))));
$I->seeResponseContainsJson(array('intervention' => array(0 => array('IntervID' => '532c5b53aab95', 'Date' => '2014-03-21', 'EmployeeID' => '4d64045c4a525', 'AssetStatusID' => '1', 'AssetID_Visit' => '4b67517f4462a', 'Request_id' => '52fddba460044', 'FaildPart' => 'Cable', 'FailurCategID' => '2', 'FailureCauseID' => '0', 'Interv_desc' => 'Description Intervention', 'Interv_desc_eg' => '', 'Comments' => 'Comments', 'RespEng' => '4c8fcac9f06fa', 'TotalWork' => '0', 'TotalCosts' => '0', 'lastmodified' => '2014-03-21 16:59:22', 'by_user' => 'demo'))));
$I->seeResponseContainsJson(array('request' => array(0 => array('Request_id' => '52fddba460044', 'Request_date' => '2014-02-14', 'Request_desc' => 'Repair', 'Request_desc_eg' => 'Repair', 'AssetID' => '4b67517f4462a', 'Request_st_id' => '1', 'Request_contact_name' => 'Agata Correia', 'Request_note' => 'Notes', 'lastmodified' => '2014-02-14 10:02:53', 'by_user' => 'demo', 'VisiTpID' => '1'))));
$I->seeResponseContainsJson(array('request_st' => array(0 => array('Request_st_id' => '1', 'Request_st_desc' => 'Open'))));
예제 #13
0
<?php

$I = new ApiTester($scenario);
$I->wantTo('Get all non-deleted notes');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendGET('/notes');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson([['id' => 8, 'user' => 'Howken', 'project' => 'KulGrej', 'content' => 'rtyrty', 'completed' => 1, 'created' => '2016-01-05 10:28:03', 'deadline' => '2016-01-08 10:28:03'], ['id' => 2, 'user' => 'BluePrint', 'project' => 'Fiskpinne', 'content' => 'qweqwea', 'completed' => 1, 'created' => '2016-01-05 10:28:42', 'deadline' => '2016-01-05 10:28:42'], ['id' => 3, 'user' => 'BluePrint', 'project' => 'KulGrej', 'content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'completed' => 1, 'created' => '2016-01-05 10:28:42', 'deadline' => '2016-01-05 10:28:42'], ['id' => 4, 'user' => 'BluePrint', 'project' => 'Fiskpinne', 'content' => '123123', 'completed' => 0, 'created' => '2016-01-05 10:28:42', 'deadline' => '2016-01-08 10:28:42'], ['id' => 5, 'user' => 'Howken', 'project' => 'Birdie', 'content' => 'jkljkl', 'completed' => 0, 'created' => '2016-01-05 10:28:42', 'deadline' => '2016-01-05 10:28:42'], ['id' => 6, 'user' => 'Howken', 'project' => 'Fiskpinne', 'content' => 'tyutyu', 'completed' => 1, 'created' => '2016-01-05 10:28:42', 'deadline' => '2016-01-07 10:28:42'], ['id' => 7, 'user' => 'Howken', 'project' => 'KulGrej', 'content' => 'bnmbnm', 'completed' => 0, 'created' => '2016-01-05 10:28:42', 'deadline' => '2016-01-05 10:28:42'], ['id' => 1, 'user' => 'BluePrint', 'project' => 'Birdie', 'content' => 'Martin', 'completed' => 0, 'created' => '2016-01-05 10:30:41', 'deadline' => '2016-01-14 10:29:38']]);
예제 #14
0
 public function testGetStats()
 {
     $this->tester->haveHttpHeader('Content-type', 'application/json');
     $this->tester->sendGET('/api/stats/1');
     $this->checkStatList();
 }
<?php

$I = new ApiTester($scenario);
$I->wantTo('update an existing asset via PUT');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
// no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '5bb14dac8d49806a4f10bc24aff299b33c1f229eed775e7784b3e7a2888b593f');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
// no whitespaces in json
$I->sendPUT('asset/4b0beb98ce160', '{"AgentID":"99999","AssetFullName":"TAPPETO T2100ee","AssetStatusID":"1","AssetUtilizationID":"1","CurrentValue":"null","DonorID":"4cf67d984d94f","EmployeeID":"4d64045c4a525","GenericAssetID":"18427","InstallationDate":"2014-7-19","InternalIventoryNumber":"1234567890","Lifetime":"14","LocationID":"4d1481c1a54c5","ManufacturerID":"4d6f38daa55e4","Metrology":"0","MetrologyDate":"2014-7-19","MetrologyDocument":"null","Model":"T2100","Notes":"null","Picture":"null","PurchaseDate":"2013-6-20","PurchasePrice":"10000","ResponsiblePers":"null","SerialNumber":"SAS2345678WA","ServiceManual":"null","SupplierID":"4ce525f47e550","UMDNS":"14141","URL_Manual":"null","WarrantyContractExp":"2014-6-30","WarrantyContractID":"1","WarrantyContractNotes":"null","by_user":"******","lastmodified":"null"}');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeInDatabase('assets', array('AgentID' => '99999', "AssetFullName" => 'TAPPETO T2100ee', "AssetID" => "4b0beb98ce160"));
예제 #16
0
 public function _before(ApiTester $I, \Codeception\Scenario $scenario)
 {
     $I->dropDatabase();
     $I->haveHttpHeader('Content-Type', 'application/json');
 }
<?php

$I = new ApiTester($scenario);
$I->wantTo('create new intervention material via POST');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
//no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '604f063497b262f82851998915b85ad16502c8f1a4aa85e7b2fac4f04038bc0f');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
//no whitespaces in json
$I->sendPOST('intervention/material', '{"Description":"test","Amount":10,"PartNumber":"abc","UnitPrice":5.0,"IntervID":"532c5b53aab95"}');
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array("error" => false));
$I->seeResponseContainsJson(array("message" => "Intervention material created"));
$I->seeInDatabase('intervention_material', array("IntervID" => "532c5b53aab95", "Description" => "test", "Amount" => 10));
예제 #18
0
<?php

$I = new ApiTester($scenario);
$I->am('Saman IT employee!');
$I->wantTo('test GetProductInfo method on this webservice');
$I->haveHttpHeader('Content-Type', 'text/xml');
$I->sendPOST('/webservice.php', '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <GetProductInfo xmlns="http://example.com/nikapps/samanussd/soap/samansoapserver">
            <productCode>123213</productCode>
            <languageCode>Fa</languageCode>
        </GetProductInfo>
    </Body>
</Envelope>');
$I->seeResponseIsXml();
$I->seeResponseContains('<Result>1;1000;Ok!</Result>');
<?php

$I = new ApiTester($scenario);
$I->wantTo('check any route with wrong authentication header values');
$I->haveHttpHeader('X-PublicKey', 'somewrongkey2234');
$I->haveHttpHeader('X-Hash', 'somewronghash3322');
$I->sendGET('database/export');
$I->seeResponseCodeIs(401);
예제 #20
0
<?php

$I = new ApiTester($scenario);
$I->wantTo('get new pid for a user');
$I->haveHttpHeader("Content-Type", "application/json");
$I->sendGET('http://localhost/api/v1/action/GetPid.php');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains("action");
<?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();
예제 #22
0
파일: GamesCept.php 프로젝트: AndriyK/team
<?php

$I = new ApiTester($scenario);
$I->wantTo('check games resource');
$I->sendGET('/teams/26?expand=games');
$I->seeResponseCodeIs(401);
$token = $I->login('q@q.q', 'q');
// show list of games for team
$I->haveHttpHeader('Authorization', "Bearer {$token}");
$I->sendGET('/teams/26?expand=games');
$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];
<?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"));
 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']);
 }
<?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)"));
예제 #26
0
<?php

$I = new ApiTester($scenario);
$I->wantTo('Get user with not exists id');
$I->sendGET('users/500000000');
$I->seeResponseCodeIs(404);
$I->seeResponseIsJson();
$I->haveHttpHeader('Content-Type', 'application/json');
<?php

$I = new ApiTester($scenario);
$I->wantTo('update an existing request via PUT');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
// no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '517c64ce66ec1129c94024f9cccab3762776e8c4eb9642543237abebc8c0ce98');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
// no whitespaces in json
$I->sendPUT('asset/4b674c6d9e9ff/532c5b331baf3', '{"Request_date":"2014-02-14","Request_desc":"blub","Request_contact_name":"democontact","Request_note":"somenotes","Request_st_id":"1","VisiTpID":"4"}');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeInDatabase('request', array("AssetID" => "4b674c6d9e9ff", "Request_id" => "532c5b331baf3", "Request_contact_name" => "democontact"));
<?php

$I = new ApiTester($scenario);
$I->wantTo('Get a 404 when I want to delete an asset that does not exist');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
$I->haveHttpHeader('X-Hash', 'e651e0f6450f89d82ab0a34c1d421097a635897f5e719179e49263ff145e6ed9');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
$I->sendDELETE('asset/xyz123456', '');
$I->seeResponseCodeIs(404);
<?php

$I = new ApiTester($scenario);
$I->wantTo('update an existing intervention via PUT');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
// no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '8fa6f078389516253c2ca6ebdf4b37209721bd64eab99242ef51a9368b957d9e');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
// no whitespaces in json
$I->sendPUT('asset/4b67517f4462a/52fddba460044/532c5b53aab95', '{"Date":"2014-01-01","EmployeeID":"4d64045c4a525","AssetID_Visit":"4b67517f4462a","AssetStatusID":1,"FaildPart":"Cable Red","FailurCategID":2,"FailureCauseID":1,"Interv_desc":"blub","Comments":"yes","RespEng":"4c8fcac9f06fa","TotalWork":1,"TotalCosts":2}');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array("error" => false));
$I->seeResponseContainsJson(array("message" => "Intervention updated"));
$I->seeInDatabase('intervention', array("IntervID" => "532c5b53aab95", "AssetID_Visit" => "4b67517f4462a", "Date" => "2014-01-01", "EmployeeID" => "4d64045c4a525", "RespEng" => "4c8fcac9f06fa"));