@@ -43,18 +43,12 @@ def run_test(self):
43
43
url = urllib .parse .urlparse (self .nodes [0 ].url )
44
44
45
45
def test_command (method , params , auth , expected_status , should_not_match = False ):
46
- test_command_helper (method , params , '/' , auth , expected_status , should_not_match )
47
-
48
- def test_external_command (method , params , auth , expected_status , should_not_match = False ):
49
- test_command_helper (method , params , '/external' , auth , expected_status , should_not_match )
50
-
51
- def test_command_helper (method , params , path , auth , expected_status , should_not_match ):
52
46
conn = http .client .HTTPConnection (url .hostname , url .port )
53
47
conn .connect ()
54
48
body = {"method" : method }
55
49
if len (params ):
56
50
body ["params" ] = params
57
- conn .request ('POST' , path , json .dumps (body ), {"Authorization" : "Basic " + str_to_b64str (auth )})
51
+ conn .request ('POST' , '/' , json .dumps (body ), {"Authorization" : "Basic " + str_to_b64str (auth )})
58
52
resp = conn .getresponse ()
59
53
if should_not_match :
60
54
assert resp .status != expected_status
@@ -120,15 +114,15 @@ def test_command_helper(method, params, path, auth, expected_status, should_not_
120
114
test_command ("debug" , ["1" ], rpcuser_authpair_operator , 200 )
121
115
122
116
123
- self .log .info ("Restart node with /external handler..." )
124
- test_external_command ("getbestblockhash" , [], rpcuser_authpair_platform , 200 )
125
- test_external_command ("getblockchaininfo" , [], rpcuser_authpair_platform , 403 )
126
-
117
+ self .log .info ("Restart node with -rpcexternaluser..." )
127
118
self .restart_node (0 , extra_args = ["-rpcexternaluser=platform-user" ])
128
- test_command ("getbestblockhash" , [], rpcuser_authpair_platform , 403 )
129
- test_external_command ("getbestblockhash" , [], rpcuser_authpair_platform , 200 )
130
- test_external_command ("getblockchaininfo" , [], rpcuser_authpair_platform , 403 )
131
- test_external_command ("getbestblockhash" , [], rpcuser_authpair_operator , 200 )
119
+
120
+ external_log_str = "HTTP: Calling handler for external user"
121
+ expected_log_str = "ThreadRPCServer method="
122
+ with self .nodes [0 ].assert_debug_log (expected_msgs = [expected_log_str , external_log_str ]):
123
+ test_command ("getbestblockhash" , [], rpcuser_authpair_platform , 200 )
124
+ with self .nodes [0 ].assert_debug_log (expected_msgs = [expected_log_str ], unexpected_msgs = [external_log_str ]):
125
+ test_command ("getbestblockhash" , [], rpcuser_authpair_operator , 200 )
132
126
133
127
134
128
0 commit comments