예제 #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 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]);
 }
예제 #3
0
 public function accessForCheck(ApiTester $I)
 {
     $first_user = $I->createUser(true, '', false);
     $second_user = $I->createUser(true);
     $I->loginUser($first_user);
     $I->createProjectAndSetHeader();
     $consumer = $I->createConsumer();
     $table = $I->createTable();
     $table_id = $table->_id;
     $data = ['borrowers_phone_verification' => 'Positive', 'contact_person_phone_verification' => 'Positive', 'internal_credit_history' => 'Positive', 'employment' => true, 'property' => true, 'matching_rules_type' => 'decision'];
     $I->sendPOST("api/v1/tables/{$table_id}/decisions", $data);
     $I->canSeeResponseCodeIs(403);
     $I->seeResponseContains("Project owner is not activated, try again later");
     $I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id, 'role' => 'manager', 'scope' => ['tables_view', 'decisions_make']]);
     $I->loginUser($second_user);
     $I->sendPOST("api/v1/tables/{$table_id}/decisions", $data);
     $I->canSeeResponseCodeIs(403);
     $I->seeResponseContains("Project owner is not activated, try again later");
     $I->loginConsumer($consumer);
     $I->sendPOST("api/v1/tables/{$table_id}/decisions", $data);
     $I->canSeeResponseCodeIs(403);
     $I->seeResponseContains("Project owner is not activated, try again later");
     $I->logout();
     $I->loginClient($I->getCurrentClient());
     $I->sendPOST('api/v1/users/verify/email', ['token' => $first_user->sandbox->token_email->token]);
     $I->seeResponseCodeIs(200);
     $I->loginUser($first_user);
     $I->makeDecision($table_id);
     $I->loginConsumer($consumer);
     $I->makeDecision($table_id);
     $I->loginUser($second_user);
     $I->makeDecision($table_id);
 }