File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
tests/unit/legacy/api/xmlrpc
warehouse/legacy/api/xmlrpc Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -858,3 +858,14 @@ def test_missing_multicall_method(self):
858
858
assert exc .value .faultString == (
859
859
'ValueError: Method name not provided'
860
860
)
861
+
862
+ def test_too_many_multicalls_method (self ):
863
+ request = pretend .stub ()
864
+ args = [{'methodName' : 'nah' }] * 21
865
+
866
+ with pytest .raises (xmlrpc .XMLRPCWrappedError ) as exc :
867
+ xmlrpc .multicall (request , args )
868
+
869
+ assert exc .value .faultString == (
870
+ 'ValueError: Multicall limit is 20 calls'
871
+ )
Original file line number Diff line number Diff line change 33
33
)
34
34
35
35
36
+ _MAX_MULTICALLS = 20
37
+
38
+
36
39
def xmlrpc_method (** kwargs ):
37
40
"""
38
41
Support multiple endpoints serving the same views by chaining calls to
@@ -453,8 +456,11 @@ def multicall(request, args):
453
456
)
454
457
455
458
if not all (arg .get ('methodName' ) for arg in args ):
459
+ raise XMLRPCWrappedError (ValueError ('Method name not provided' ))
460
+
461
+ if len (args ) > _MAX_MULTICALLS :
456
462
raise XMLRPCWrappedError (
457
- ValueError ('Method name not provided ' )
463
+ ValueError (f'Multicall limit is { _MAX_MULTICALLS } calls ' )
458
464
)
459
465
460
466
responses = []
You can’t perform that action at this time.
0 commit comments