1212 assert_equal ,
1313 str_to_b64str
1414)
15+ import json
1516import http .client
17+ import re
1618import urllib .parse
1719
1820def rpccall (node , user , method ):
1921 url = urllib .parse .urlparse (node .url )
2022 headers = {"Authorization" : "Basic " + str_to_b64str ('{}:{}' .format (user [0 ], user [3 ]))}
2123 conn = http .client .HTTPConnection (url .hostname , url .port )
2224 conn .connect ()
23- conn .request ('POST' , '/' , '{"method": "' + method + '"}' , headers )
25+
26+ # composite commands are presented without space in whitelist
27+ # but space can't be ommitted when using CLI/http rpc
28+ # for sack of test, substitute missing space for quorum composite command
29+ params = []
30+ if re .match (r"^quorum[^ ]" , method ):
31+ params = [method [6 :]]
32+ method = "quorum"
33+ query = {"method" : method , "params" : params }
34+
35+ conn .request ('POST' , '/' , json .dumps (query ), headers )
2436 resp = conn .getresponse ()
2537 conn .close ()
2638 return resp
@@ -39,7 +51,8 @@ def setup_chain(self):
3951 # 3 => Password Plaintext
4052 self .users = [
4153 ["user1" , "50358aa884c841648e0700b073c32b2e$b73e95fff0748cc0b517859d2ca47d9bac1aa78231f3e48fa9222b612bd2083e" , "getbestblockhash,getblockcount," , "12345" ],
42- ["user2" , "8650ba41296f62092377a38547f361de$4620db7ba063ef4e2f7249853e9f3c5c3592a9619a759e3e6f1c63f2e22f1d21" , "getblockcount" , "54321" ]
54+ ["user2" , "8650ba41296f62092377a38547f361de$4620db7ba063ef4e2f7249853e9f3c5c3592a9619a759e3e6f1c63f2e22f1d21" , "getblockcount" , "54321" ],
55+ ["platform-user" , "8650ba41296f62092377a38547f361de$4620db7ba063ef4e2f7249853e9f3c5c3592a9619a759e3e6f1c63f2e22f1d21" , "getblockcount,quorumlist" , "54321" ],
4356 ]
4457 # For exceptions
4558 self .strange_users = [
@@ -55,7 +68,7 @@ def setup_chain(self):
5568 ["strangedude5" , "d12c6e962d47a454f962eb41225e6ec8$2dd39635b155536d3c1a2e95d05feff87d5ba55f2d5ff975e6e997a836b717c9" , ":getblockcount,getblockcount" , "s7R4nG3R7H1nGZ" ]
5669 ]
5770 # These commands shouldn't be allowed for any user to test failures
58- self .never_allowed = ["getnetworkinfo" ]
71+ self .never_allowed = ["getnetworkinfo" , "quorum sign" ]
5972 with open (os .path .join (get_datadir_path (self .options .tmpdir , 0 ), "dash.conf" ), 'a' , encoding = 'utf8' ) as f :
6073 f .write ("\n rpcwhitelistdefault=0\n " )
6174 for user in self .users :
0 commit comments