public function validDoorEntry(ApiTester $I) { $I->am('a valid device'); $I->wantTo('verify the endpoint returns a success door lookup response'); $user = $I->getActiveKeyholderMember(); $keyFob = $I->getMemberKeyFob($user->id); //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' => $keyFob->key_id, 'message' => 'lookup', 'service' => 'entry', 'time' => time()]); $I->canSeeResponseCodeIs(200); //Make sure a failure is returned $I->canSeeResponseContainsJson(['valid' => '1']); }
public function inactiveMemberLogin(ApiTester $I) { $I->am('an inactive member'); $I->wantTo('post to the main door endpoint and get an OK back'); $user = $I->getInactiveKeyholderMember(); $keyFob = $I->getMemberKeyFob($user->id); //Post the keyfob to the endpoint $I->sendPOST('/access-control/main-door', ['data' => $keyFob->key_id]); //The endpoint always returns 200 $I->seeResponseCodeIs(200); //Make sure a good response is returned $I->seeResponseIsJson(); //Response contains their name //$I->seeResponseContains($user->given_name); //Make sure the request was allowed $I->seeResponseContainsJson(['valid' => '0']); //Confirm an access log record was created $I->seeInDatabase('access_log', ['user_id' => $user->id, 'key_fob_id' => $keyFob->id, 'response' => 402, 'service' => 'main-door']); }
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]); }