public function actionAuthenticate() { $model = new Authenticate(); $authenticate_json = http_get_request_body(); //$authenticate_json = json_encode(array("username"=>"kailesh","password"=>"1c3dd8b850b055bb7b6fb0fb59a7cd4","deviceID"=>"90:C1:15:BC:97:4F")); $model->verifyDetails($authenticate_json); $verification = $model->getAccess(); $responseMsg = $model->generateJsonResponse(); //var_dump($responseMsg); /*HttpResponse::status(200); HttpResponse::setContentType('text/HTML'); HttpResponse::setData("Orders Recieved"); HttpResponse::send();*/ //var_dump($responseMsg); if ($verification === true) { HttpResponse::status(200); HttpResponse::setContentType('application/json'); HttpResponse::setData($responseMsg); HttpResponse::send(); } else { HttpResponse::status(200); HttpResponse::setContentType('application/json'); HttpResponse::setData($responseMsg); HttpResponse::send(); } }
public function testUnknownUser() { $authenticate = new Authenticate(); $authenticate_json = json_encode(array("username" => "bob", "password" => "1c3dd8b823we055bb7b6fb0fb59a7cd04", "deviceID" => "85:D5:76:AA:97:4F")); $authenticate->verifyDetails($authenticate_json); $expected_response = json_encode(array("access" => false, "reason" => "RMB-01", "balance" => "0")); $returned_response = $authenticate->generateJsonResponse(); $this->assertEquals($expected_response, $returned_response); }