mirror of
https://github.com/valitydev/fraudbusters-compose.git
synced 2024-11-06 00:15:18 +00:00
refactoring + fix e2e tests
This commit is contained in:
parent
87bc49fdaf
commit
3fb245ae6c
@ -12,7 +12,12 @@ const TEMPLATE_ID = "test-templ-id";
|
||||
const TEMPLATE = "rule:amount_test:amount() >= 20 -> decline;";
|
||||
const PARTY_ID = "partyTest";
|
||||
const SHOP_ID = "shopTest";
|
||||
const EMAIL = "test@mail.ru";
|
||||
|
||||
|
||||
const IP = "123.123.123.123";
|
||||
const FINGERPRINT = "xxxxx";
|
||||
const CARD_TOKEN = "4J8vmnlYPwzYzia74fny81";
|
||||
describe('Test for simple rule inspection', function () {
|
||||
this.timeout(testTimeout);
|
||||
|
||||
@ -38,12 +43,14 @@ describe('Test for simple rule inspection', function () {
|
||||
res.should.have.status(200);
|
||||
res.should.be.json;
|
||||
res.body.should.be.a("object");
|
||||
res.body.should.have.property("result");
|
||||
res.body.result.length.should.be.eql(1);
|
||||
res.body.result.should.does.include(PARTY_ID + "_" + SHOP_ID);
|
||||
}, PARTY_ID, SHOP_ID, TEMPLATE_ID);
|
||||
});
|
||||
|
||||
it('it should inspect that payment have FATAL risk', function (done) {
|
||||
let exceedAmount = 100;
|
||||
inspectorService.inspectPayment(done,
|
||||
(res) => {
|
||||
res.should.have.status(200);
|
||||
@ -52,16 +59,17 @@ describe('Test for simple rule inspection', function () {
|
||||
res.body.should.have.property("result");
|
||||
res.body.result.should.equal('fatal');
|
||||
},
|
||||
"test@mail.ru",
|
||||
"123.123.123.123",
|
||||
"xxxxx",
|
||||
"4J8vmnlYPwzYzia74fny81",
|
||||
EMAIL,
|
||||
IP,
|
||||
FINGERPRINT,
|
||||
CARD_TOKEN,
|
||||
PARTY_ID,
|
||||
SHOP_ID,
|
||||
100);
|
||||
exceedAmount);
|
||||
});
|
||||
|
||||
it('it should inspect that payment have default HIGH risk', function (done) {
|
||||
let acceptableAmount = 10;
|
||||
inspectorService.inspectPayment(done,
|
||||
(res) => {
|
||||
res.should.have.status(200);
|
||||
@ -70,12 +78,12 @@ describe('Test for simple rule inspection', function () {
|
||||
res.body.should.have.property("result");
|
||||
res.body.result.should.equal('high');
|
||||
},
|
||||
"test@mail.ru",
|
||||
"123.123.123.123",
|
||||
"xxxxx",
|
||||
"4J8vmnlYPwzYzia74fny81",
|
||||
EMAIL,
|
||||
IP,
|
||||
FINGERPRINT,
|
||||
CARD_TOKEN,
|
||||
PARTY_ID,
|
||||
SHOP_ID,
|
||||
10);
|
||||
acceptableAmount);
|
||||
});
|
||||
});
|
@ -1,16 +1,13 @@
|
||||
const chai = require("chai");
|
||||
const chaiHttp = require("chai-http");
|
||||
const should = chai.should();
|
||||
chai.use(chaiHttp);
|
||||
const config = require("../config");
|
||||
const templateService = require("./service/template_service.js");
|
||||
const inspectorService = require("./service/inspector_service.js");
|
||||
const listsService = require("./service/wb_list_service.js");
|
||||
const paymentService = require("./service/payment_service.js");
|
||||
|
||||
const FB_MGMNT_URL = config.fbManagement.url;
|
||||
|
||||
const GROUP_PATH = config.fbManagement.groupPath;
|
||||
const listGroupService = require("./service/list_group_service.js");
|
||||
const referenceService = require('./service/reference_service.js');
|
||||
|
||||
const testTimeout = config.testTimeout;
|
||||
const IN_WHITE_lIST_TEMPLATE_ID = "white-list-template-id";
|
||||
@ -24,6 +21,8 @@ const IN_WHITE_LIST_TEMPLATE = "rule: inWhiteList(\"email\") -> accept;";
|
||||
const IN_GREY_LIST_TEMPLATE = "rule: inGreyList(\"card_token\") -> accept;";
|
||||
const IN_BLACK_LIST_TEMPLATE = "rule: inBlackList(\"card_token\") -> decline;"
|
||||
const CARD_TOKEN = "wb_test_token_";
|
||||
const IP = "123.123.123.123";
|
||||
const FINGERPRINT = "xxxxx";
|
||||
|
||||
function generateCardToken() {
|
||||
return CARD_TOKEN + Math.floor(Math.random() * 999);
|
||||
@ -93,63 +92,27 @@ describe('Test for check white, black and grey tokens', function () {
|
||||
});
|
||||
|
||||
it('it should create a new group for list templates', function (done) {
|
||||
let TEST_GROUP = {
|
||||
groupId: GROUP_ID,
|
||||
modifiedByUser: "test-user",
|
||||
priorityTemplates: [
|
||||
{
|
||||
id: IN_WHITE_lIST_TEMPLATE_ID,
|
||||
lastUpdateTime: "2019-08-24T14:15:22Z",
|
||||
priority: 0
|
||||
},
|
||||
{
|
||||
id: IN_GREY_LIST_TEMPLATE_ID,
|
||||
lastUpdateTime: "2019-08-24T14:15:22Z",
|
||||
priority: 2
|
||||
},
|
||||
{
|
||||
id: IN_BLACK_LIST_TEMPLATE_ID,
|
||||
lastUpdateTime: "2019-08-24T14:15:22Z",
|
||||
priority: 1
|
||||
}]
|
||||
};
|
||||
|
||||
chai.request(FB_MGMNT_URL)
|
||||
.post(GROUP_PATH)
|
||||
.send(TEST_GROUP)
|
||||
.end(function (err) {
|
||||
if (err) {
|
||||
console.log(err.text);
|
||||
done(err);
|
||||
}
|
||||
listGroupService.create(done,
|
||||
GROUP_ID,
|
||||
IN_WHITE_lIST_TEMPLATE_ID,
|
||||
IN_GREY_LIST_TEMPLATE_ID,
|
||||
IN_BLACK_LIST_TEMPLATE_ID);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('it should create a new reference for group', function (done) {
|
||||
let TEST_GROUP = [{
|
||||
groupId: GROUP_ID,
|
||||
id: GROUP_REFERENCE_ID,
|
||||
lastUpdateDate: "2022-04-15T10:30:30",
|
||||
modifiedByUser: "test-user",
|
||||
shopId: SHOP_ID,
|
||||
partyId: PARTY_ID
|
||||
}];
|
||||
|
||||
chai.request(FB_MGMNT_URL)
|
||||
.post(GROUP_PATH + '/' + GROUP_ID + '/references')
|
||||
.send(TEST_GROUP)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
console.log(err.text);
|
||||
done(err);
|
||||
}
|
||||
should.not.exist(err);
|
||||
referenceService.createGroup(done,
|
||||
(res) => {
|
||||
res.should.have.status(200);
|
||||
res.should.be.json;
|
||||
done()
|
||||
});
|
||||
},
|
||||
GROUP_ID,
|
||||
GROUP_REFERENCE_ID,
|
||||
SHOP_ID,
|
||||
PARTY_ID);
|
||||
|
||||
});
|
||||
|
||||
let cardToken = generateCardToken();
|
||||
@ -164,8 +127,8 @@ describe('Test for check white, black and grey tokens', function () {
|
||||
res.body.result.should.equal('high');
|
||||
},
|
||||
EMAIL,
|
||||
"123.123.123.123",
|
||||
"xxxxx",
|
||||
IP,
|
||||
FINGERPRINT,
|
||||
cardToken,
|
||||
PARTY_ID,
|
||||
SHOP_ID,
|
||||
@ -198,8 +161,8 @@ describe('Test for check white, black and grey tokens', function () {
|
||||
res.body.result.should.equal('low');
|
||||
},
|
||||
EMAIL,
|
||||
"123.123.123.123",
|
||||
"xxxxx",
|
||||
IP,
|
||||
FINGERPRINT,
|
||||
cardToken,
|
||||
PARTY_ID,
|
||||
SHOP_ID,
|
||||
@ -224,7 +187,7 @@ describe('Test for check white, black and grey tokens', function () {
|
||||
SHOP_ID,
|
||||
cardToken,
|
||||
{
|
||||
"count": 0,
|
||||
"count": 1,
|
||||
"endCountTime": getNowDatePlusOneDay().toJSON(),
|
||||
"startCountTime": (new Date()).toJSON()
|
||||
});
|
||||
@ -240,8 +203,8 @@ describe('Test for check white, black and grey tokens', function () {
|
||||
res.body.result.should.equal('low');
|
||||
},
|
||||
EMAIL + 'x',
|
||||
"123.123.123.123",
|
||||
"xxxxx",
|
||||
IP,
|
||||
FINGERPRINT,
|
||||
cardToken,
|
||||
PARTY_ID,
|
||||
SHOP_ID,
|
||||
@ -255,9 +218,9 @@ describe('Test for check white, black and grey tokens', function () {
|
||||
},
|
||||
"captured",
|
||||
EMAIL + 'x',
|
||||
"123.123.123.123",
|
||||
IP,
|
||||
cardToken,
|
||||
"xxxxx",
|
||||
FINGERPRINT,
|
||||
PARTY_ID,
|
||||
SHOP_ID,
|
||||
"invoice_id_1.1");
|
||||
@ -289,8 +252,8 @@ describe('Test for check white, black and grey tokens', function () {
|
||||
res.body.result.should.equal('fatal');
|
||||
},
|
||||
EMAIL + 'x',
|
||||
"123.123.123.123",
|
||||
"xxxxx",
|
||||
IP,
|
||||
FINGERPRINT,
|
||||
cardToken,
|
||||
PARTY_ID,
|
||||
SHOP_ID,
|
@ -1,12 +1,12 @@
|
||||
const CARD_TOKEN = "aggr_test_token";
|
||||
const IP = "192.1.1.1";
|
||||
const EMAIL = "test_unique@vality.dev";
|
||||
const PAYMENT_ID = "payment_id";
|
||||
const paymentId = Math.floor(Math.random() * 999);
|
||||
|
||||
module.exports.create =
|
||||
function (id, ip, email, fingerprint, cardToken, partyId, shopId, amount, currency) {
|
||||
return {
|
||||
id: id || PAYMENT_ID,
|
||||
id: id || paymentId,
|
||||
customer: {
|
||||
name: "Test Test",
|
||||
device: {
|
||||
|
@ -10,9 +10,10 @@ const INSPECT_PATH = config.fbApi.inspectPath;
|
||||
|
||||
module.exports.inspectPayment =
|
||||
function (done, checkResponse, email, ip, fingerprint, cardToken, partyId, shopId, amount, currency) {
|
||||
let id = Math.floor(Math.random() * 999);
|
||||
let TEST_INSPECTOR_PAYMENT_REQ_HIGH = {
|
||||
payment: paymentFactory.create(
|
||||
"payment_id",
|
||||
id,
|
||||
ip,
|
||||
email,
|
||||
fingerprint,
|
||||
|
43
e2e-test/test/service/list_group_service.js
Normal file
43
e2e-test/test/service/list_group_service.js
Normal file
@ -0,0 +1,43 @@
|
||||
const chai = require("chai");
|
||||
const config = require("../../config");
|
||||
const chaiHttp = require("chai-http");
|
||||
chai.use(chaiHttp);
|
||||
|
||||
const GROUP_PATH = config.fbManagement.groupPath;
|
||||
const FB_MGMNT_URL = config.fbManagement.url;
|
||||
|
||||
module.exports.create = function (done, groupId, whiteListTemplateId, greyListTemplateId, blackListTemplateId) {
|
||||
|
||||
let TEST_GROUP = {
|
||||
groupId: groupId,
|
||||
modifiedByUser: "test-user",
|
||||
priorityTemplates: [
|
||||
{
|
||||
id: whiteListTemplateId,
|
||||
lastUpdateTime: "2019-08-24T14:15:22Z",
|
||||
priority: 0
|
||||
},
|
||||
{
|
||||
id: greyListTemplateId,
|
||||
lastUpdateTime: "2019-08-24T14:15:22Z",
|
||||
priority: 2
|
||||
},
|
||||
{
|
||||
id: blackListTemplateId,
|
||||
lastUpdateTime: "2019-08-24T14:15:22Z",
|
||||
priority: 1
|
||||
}]
|
||||
};
|
||||
|
||||
chai.request(FB_MGMNT_URL)
|
||||
.post(GROUP_PATH)
|
||||
.send(TEST_GROUP)
|
||||
.end(function (err) {
|
||||
if (err) {
|
||||
console.log(err.text);
|
||||
done(err);
|
||||
}
|
||||
|
||||
done()
|
||||
});
|
||||
}
|
@ -5,6 +5,7 @@ const should = chai.should();
|
||||
chai.use(chaiHttp);
|
||||
|
||||
const REFERENCE_PATH = config.fbManagement.referencePath;
|
||||
const GROUP_PATH = config.fbManagement.groupPath;
|
||||
const FB_MGMNT_URL = config.fbManagement.url;
|
||||
|
||||
module.exports.create = function (done, checkResponse, partyId, shopId, templateId) {
|
||||
@ -31,4 +32,28 @@ module.exports.create = function (done, checkResponse, partyId, shopId, template
|
||||
checkResponse(res);
|
||||
done()
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.createGroup = function (done, checkResponse, groupId, groupReferenceId, shopId, partyId) {
|
||||
let TEST_GROUP = [{
|
||||
groupId: groupId,
|
||||
id: groupReferenceId,
|
||||
lastUpdateDate: "2022-04-15T10:30:30",
|
||||
modifiedByUser: "test-user",
|
||||
shopId: shopId,
|
||||
partyId: partyId
|
||||
}];
|
||||
|
||||
chai.request(FB_MGMNT_URL)
|
||||
.post(GROUP_PATH + '/' + groupId + '/references')
|
||||
.send(TEST_GROUP)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
console.log(err.text);
|
||||
done(err);
|
||||
}
|
||||
should.not.exist(err);
|
||||
checkResponse(res);
|
||||
done()
|
||||
});
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
<root level="warn">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
<logger name="dev.vality" level="INFO"/>
|
||||
<logger name="dev.vality" level="ALL"/>
|
||||
<logger name="dev.vality.woody" level="INFO"/>
|
||||
<logger name="org.springframework.jdbc.core" level="ALL"/>
|
||||
</configuration>
|
||||
|
Loading…
Reference in New Issue
Block a user