public function createFirst(ApiTester $I) { $I->createAndLoginUser(); $I->createProjectAndSetHeader(); $table_data = $I->createTable(); $table_id_no_decisions = $table_data->_id; $table_data = $I->createTable(); $table_id_with_decisions = $table_data->_id; $decision_table = $I->makeDecision($table_id_with_decisions); $I->assertEquals('Approve', $decision_table->final_decision); $I->sendGET('api/v1/admin/decisions?table_id=' . $table_id_no_decisions); $I->seeResponseCodeIs(404); # filter by table_id $I->sendGET('api/v1/admin/decisions?table_id=' . $table_id_with_decisions); $I->assertTableDecisionsForAdmin('decision', '$.data[*]'); foreach ($I->getResponseFields()->data as $item) { $I->sendGET('api/v1/admin/decisions/' . $item->_id); $I->assertTableDecisionsForAdmin(); } $I->sendGET('api/v1/admin/decisions/123'); $I->seeResponseCodeIs(404); $decision_data = $I->makeDecision($table_id_with_decisions, ['borrowers_phone_verification' => 'invalid', 'contact_person_phone_verification' => 'invalid', 'internal_credit_history' => 'invalid', 'employment' => false, 'property' => false]); $I->assertEquals($table_data->variants[0]->default_decision, $decision_data->final_decision); $I->sendGET('api/v1/admin/decisions'); $I->assertTableDecisionsForAdmin('decision', '$.data[*]'); $decisions = $I->getResponseFields()->data; $I->assertEquals('invalid', $decisions[0]->request->borrowers_phone_verification); $I->assertEquals('Positive', $decisions[1]->request->borrowers_phone_verification); foreach ($I->getResponseFields()->data as $item) { $I->sendGET('api/v1/admin/decisions/' . $item->_id); $I->assertTableDecisionsForAdmin(); } $I->loginConsumer($I->createConsumer()); $I->sendGET('api/v1/admin/decisions'); $I->seeResponseCodeIs(401); }
public function ruleIsset(ApiTester $I) { $user = $I->createAndLoginUser(); $I->createProjectAndSetHeader(); $table = $I->createTable(['title' => 'Test title', 'description' => 'Test description', 'matching_type' => 'decision', 'decision_type' => 'alpha_num', 'fields' => [["key" => ' IS SET ', "title" => 'Test', "source" => "request", "type" => 'numeric', "preset" => ['condition' => '$lte', 'value' => 10]], ["key" => 'Second ', "title" => 'Second', "source" => "request", "type" => 'string', 'preset' => null]], 'variants' => [['default_decision' => 'Decline', 'rules' => [['than' => 'Approve', 'title' => '', 'description' => '', 'conditions' => [['field_key' => ' IS SET ', 'condition' => '$is_set', 'value' => true], ['field_key' => 'Second ', 'condition' => '$is_set', 'value' => true]]]]]]]); $I->sendPOST("api/v1/tables/{$table->_id}/decisions", [' ISSET ' => 8]); $I->seeResponseCodeIs(422); # invalid request type $I->sendPOST("api/v1/tables/{$table->_id}/decisions", ['is_set' => 'invalid_type', 'second' => 'test']); $I->seeResponseCodeIs(422); # invalid request type $I->sendPOST("api/v1/tables/{$table->_id}/decisions", ['is_set' => 200, 'second' => false]); $I->seeResponseCodeIs(422); $I->loginConsumer($I->createConsumer()); $decision = $I->makeDecision($table->_id, ['is_set' => 1000, 'second' => 'test']); $I->sendGET('api/v1/admin/decisions/' . $decision->_id); $I->seeResponseCodeIs(401); $I->loginUser($user); $I->makeDecision($table->_id, ['is_set' => 1000, 'second' => 'test']); $I->sendGET('api/v1/admin/decisions/' . $decision->_id); $I->assertResponseDataFields(['final_decision' => 'Approve', 'rules' => [['conditions' => [['field_key' => 'is_set', 'matched' => true], ['field_key' => 'second', 'matched' => true]]]]]); }
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); }