aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/test
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2017-07-10 18:17:49 +0200
committerAnders Svensson <[email protected]>2017-08-03 17:16:34 +0200
commit19c246a124d1962535b535682a106dc862cdcddd (patch)
tree9daecf8dd8ad85f2b775fe3106afb0d0ad6918dc /lib/diameter/test
parent246a5d8611e258119fc6bdc6c52772539c8b09ca (diff)
downloadotp-19c246a124d1962535b535682a106dc862cdcddd.tar.gz
otp-19c246a124d1962535b535682a106dc862cdcddd.tar.bz2
otp-19c246a124d1962535b535682a106dc862cdcddd.zip
Test Result-Code 5009 in traffic suite
Aka DIAMETER_AVP_OCCURS_TOO_MANY_TIMES. This reveals a fault. The RFC says this: A message was received that included an AVP that appeared more often than permitted in the message definition. The Failed-AVP AVP MUST be included and contain a copy of the first instance of the offending AVP that exceeded the maximum number of occurrences. The list of AVPs is reversed when diameter checks arities, so Failed-AVP contains the wrong AVP, causing the new testcase to fail.
Diffstat (limited to 'lib/diameter/test')
-rw-r--r--lib/diameter/test/diameter_traffic_SUITE.erl40
1 files changed, 39 insertions, 1 deletions
diff --git a/lib/diameter/test/diameter_traffic_SUITE.erl b/lib/diameter/test/diameter_traffic_SUITE.erl
index fb69cd831e..eb3ee777ce 100644
--- a/lib/diameter/test/diameter_traffic_SUITE.erl
+++ b/lib/diameter/test/diameter_traffic_SUITE.erl
@@ -64,6 +64,7 @@
send_invalid_reject/1,
send_unexpected_mandatory_decode/1,
send_unexpected_mandatory/1,
+ send_too_many/1,
send_long/1,
send_maxlen/1,
send_nopeer/1,
@@ -234,6 +235,8 @@
?'DIAMETER_BASE_RESULT-CODE_AVP_UNSUPPORTED').
-define(UNSUPPORTED_VERSION,
?'DIAMETER_BASE_RESULT-CODE_UNSUPPORTED_VERSION').
+-define(TOO_MANY,
+ ?'DIAMETER_BASE_RESULT-CODE_AVP_OCCURS_TOO_MANY_TIMES').
-define(REALM_NOT_SERVED,
?'DIAMETER_BASE_RESULT-CODE_REALM_NOT_SERVED').
-define(UNABLE_TO_DELIVER,
@@ -411,6 +414,7 @@ tc() ->
send_invalid_reject,
send_unexpected_mandatory_decode,
send_unexpected_mandatory,
+ send_too_many,
send_long,
send_maxlen,
send_nopeer,
@@ -549,7 +553,9 @@ rfc4005(Config) ->
%% Ensure that result codes have the expected values.
result_codes(_Config) ->
- {2001, 3001, 3002, 3003, 3004, 3007, 3008, 3009, 5001, 5011, 5014}
+ {2001,
+ 3001, 3002, 3003, 3004, 3007, 3008, 3009,
+ 5001, 5009, 5011, 5014}
= {?SUCCESS,
?COMMAND_UNSUPPORTED,
?UNABLE_TO_DELIVER,
@@ -559,6 +565,7 @@ result_codes(_Config) ->
?INVALID_HDR_BITS,
?INVALID_AVP_BITS,
?AVP_UNSUPPORTED,
+ ?TOO_MANY,
?UNSUPPORTED_VERSION,
?INVALID_AVP_LENGTH}.
@@ -691,6 +698,18 @@ send_unexpected_mandatory_decode(Config) ->
data = <<12:32>>}]]
= failed_avps(Avps, Config).
+%% Try to two Auth-Application-Id in ASR expect 5009.
+send_too_many(Config) ->
+ Req = ['ASR'],
+
+ ['ASA' | #{'Session-Id' := _,
+ 'Result-Code' := ?TOO_MANY,
+ 'Failed-AVP' := Avps}]
+ = call(Config, Req),
+ [[#diameter_avp{name = 'Auth-Application-Id',
+ value = 42}]]
+ = failed_avps(Avps, Config).
+
%% Send an containing a faulty Grouped AVP (empty Proxy-Host in
%% Proxy-Info) and expect that only the faulty AVP is sent in
%% Failed-AVP. The encoded values of Proxy-Host and Proxy-State are
@@ -1251,6 +1270,25 @@ prepare(Pkt, Caps, N, #group{client_dict = Dict0} = Group)
E#diameter_packet{bin = <<H/binary, (Len+9):24, T/binary>>};
prepare(Pkt, Caps, N, #group{client_dict = Dict0} = Group)
+ when N == send_too_many ->
+ Req = prepare(Pkt, Caps, Group),
+
+ #diameter_packet{header = #diameter_header{length = L},
+ bin = B}
+ = E
+ = diameter_codec:encode(Dict0,
+ Pkt#diameter_packet{msg = Req}),
+ M = L - 4 - 12,
+ <<1, L:24,
+ T:M/binary,
+ A:8/binary, D:4/binary>>
+ = B,
+ E#diameter_packet{bin = <<1, (L+12):24,
+ T/binary,
+ A/binary, D/binary,
+ A/binary, 42:32>>};
+
+prepare(Pkt, Caps, N, #group{client_dict = Dict0} = Group)
when N == send_long_avp_length;
N == send_short_avp_length;
N == send_zero_avp_length ->