File tree Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -304,9 +304,10 @@ def get_result(self, obj):
304
304
group = self .context ["group" ],
305
305
group_check = obj ,
306
306
)
307
- return counter .consumed ()
308
- except MaxQuotaReached :
309
- return int (obj .value )
307
+ consumed = counter .consumed ()
308
+ if consumed > int (obj .value ):
309
+ consumed = int (obj .value )
310
+ return consumed
310
311
except (SkipCheck , ValueError , KeyError ):
311
312
return None
312
313
Original file line number Diff line number Diff line change @@ -1170,6 +1170,44 @@ def test_user_radius_usage_view(self):
1170
1170
},
1171
1171
)
1172
1172
1173
+ data3 = self .acct_post_data
1174
+ data3 .update (
1175
+ dict (
1176
+ session_id = "40111117" ,
1177
+ unique_id = "12234f70" ,
1178
+ input_octets = 1000000000 ,
1179
+ output_octets = 1000000000 ,
1180
+ username = "tester" ,
1181
+ )
1182
+ )
1183
+ self ._create_radius_accounting (** data3 )
1184
+
1185
+ with self .subTest ("User consumed more than allowed limit" ):
1186
+ response = self .client .get (usage_url , HTTP_AUTHORIZATION = authorization )
1187
+ self .assertEqual (response .status_code , 200 )
1188
+ self .assertIn ("checks" , response .data )
1189
+ checks = response .data ["checks" ]
1190
+ self .assertDictEqual (
1191
+ dict (checks [0 ]),
1192
+ {
1193
+ "attribute" : "Max-Daily-Session" ,
1194
+ "op" : ":=" ,
1195
+ "value" : "10800" ,
1196
+ "result" : 783 ,
1197
+ "type" : "seconds" ,
1198
+ },
1199
+ )
1200
+ self .assertDictEqual (
1201
+ dict (checks [1 ]),
1202
+ {
1203
+ "attribute" : "Max-Daily-Session-Traffic" ,
1204
+ "op" : ":=" ,
1205
+ "value" : "3000000000" ,
1206
+ "result" : 3000000000 ,
1207
+ "type" : "bytes" ,
1208
+ },
1209
+ )
1210
+
1173
1211
with self .subTest ("Test user does not have RadiusUserGroup" ):
1174
1212
RadiusUserGroup .objects .all ().delete ()
1175
1213
response = self .client .get (usage_url , HTTP_AUTHORIZATION = authorization )
You can’t perform that action at this time.
0 commit comments