CAPI-407: Better email format validation (#466)

This commit is contained in:
Alexey 2020-03-02 17:15:18 +03:00 committed by GitHub
parent 72cb6bcbe0
commit 94637e4959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 6 deletions

2
Jenkinsfile vendored
View File

@ -33,7 +33,7 @@ build('capi', 'docker-host', finalHook) {
sh 'make wc_xref'
}
runStage('pre-dialyze') {
withWsCache("_build/default/rebar3_21.3.8.7_plt") {
withWsCache("_build/default/rebar3_22.2.6_plt") {
sh 'make wc_update_plt'
}
}

View File

@ -19,7 +19,7 @@ SERVICE_IMAGE_PUSH_TAG ?= $(SERVICE_IMAGE_TAG)
BASE_IMAGE_NAME := service-erlang
BASE_IMAGE_TAG := da0ab769f01b650b389d18fc85e7418e727cbe96
BUILD_IMAGE_TAG := 4536c31941b9c27c134e8daf0fd18848809219c9
BUILD_IMAGE_TAG := 14519aa9b9c10f79081567d8add33cdf408dfbd2
CALL_ANYWHERE := \
submodules \

View File

@ -1155,7 +1155,7 @@ search_payments_ok_test(Config) ->
{from_time, {{2015, 08, 11}, {19, 42, 35}}},
{to_time, {{2020, 08, 11}, {19, 42, 35}}},
{payerEmail, <<"test@test.ru">>},
{payerIP, <<"192.168.0.0.1">>},
{payerIP, <<"192.168.0.1">>},
{paymentStatus, <<"processed">>},
{paymentFlow, <<"instant">>},
{paymentMethod, <<"bankCard">>},

View File

@ -3,6 +3,8 @@
-include_lib("common_test/include/ct.hrl").
-include_lib("damsel/include/dmsl_domain_config_thrift.hrl").
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
-include_lib("damsel/include/dmsl_merch_stat_thrift.hrl").
-include_lib("capi_dummy_data.hrl").
-include_lib("jose/include/jose_jwk.hrl").
@ -18,7 +20,9 @@
-export([init/1]).
-export([
oops_body_test/1
oops_body_test/1,
schema_param_validation/1,
query_param_validation/1
]).
-type test_case_name() :: atom().
@ -38,7 +42,8 @@ init([]) ->
[test_case_name()].
all() ->
[
{group, stream_handler_tests}
{group, stream_handler_tests},
{group, validation_tests}
].
-spec groups() ->
@ -49,6 +54,12 @@ groups() ->
[
oops_body_test
]
},
{validation_tests, [],
[
schema_param_validation,
query_param_validation
]
}
].
@ -71,7 +82,10 @@ end_per_suite(C) ->
-spec init_per_group(group_name(), config()) ->
config().
init_per_group(stream_handler_tests, Config) ->
init_per_group(GroupName, Config) when
stream_handler_tests =:= GroupName;
validation_tests =:= GroupName
->
BasePermissions = [
{[invoices], write},
{[invoices], read},
@ -127,3 +141,41 @@ oops_body_test(Config) ->
Opts
),
{ok, OopsBody} = file:read_file(?OOPS_BODY).
-spec schema_param_validation(config()) ->
_.
schema_param_validation(Config) ->
capi_ct_helper:mock_services([
{invoicing, fun('Create', _) -> {ok, ?PAYPROC_INVOICE} end},
{bender, fun('GenerateID', _) -> {ok, capi_ct_helper_bender:get_result(<<"key">>)} end}
], Config),
Req0 = #{
<<"shopID">> => ?STRING,
<<"amount">> => <<"vry much">>,
<<"currency">> => <<"green paper">>,
<<"metadata">> => #{<<"invoice_dummy_metadata">> => <<"test_value">>},
<<"dueDate">> => <<"asap">>,
<<"product">> => <<"test_product">>,
<<"description">> => <<"test_invoice_description">>
},
{error, {request_validation_failed, _}} =
capi_client_invoices:create_invoice(?config(context, Config), Req0).
-spec query_param_validation(config()) ->
_.
query_param_validation(Config) ->
capi_ct_helper:mock_services([
{merchant_stat, fun('GetInvoices', _) -> {ok, ?STAT_RESPONSE_INVOICES} end},
{geo_ip_service, fun('GetLocationName', _) -> {ok, #{123 => ?STRING}} end}
], Config),
Query0 = [
{payerEmail, <<"te%^st@test.ru">>}
],
{error, {request_validation_failed, _}} =
capi_client_searches:search_invoices(?config(context, Config), ?STRING, Query0),
Query1 = #{
<<"geoIDs">> => <<"no,also no">>,
<<"language">> => <<"ru">>
},
{error, {request_validation_failed, _}} =
capi_client_geo:get_location_names(?config(context, Config), Query1).

View File

@ -33,6 +33,10 @@
{git,"git@github.com:rbkmoney/dmt_core.git",
{ref,"8ac78cb1c94abdcdda6675dd7519893626567573"}},
1},
{<<"email_validator">>,
{git,"https://github.com/rbkmoney/email_validator.git",
{ref,"be90c6ebd34d29fa9390136469b99d8a68ad4996"}},
0},
{<<"erl_health">>,
{git,"https://github.com/rbkmoney/erlang-health.git",
{ref,"c190cb8de0359b933a27cd20ddc74180c0e5f5c4"}},