20
20
import configparser
21
21
import sys
22
22
23
+
23
24
def call_with_auth (node , user , password ):
24
25
url = urllib .parse .urlparse (node .url )
25
26
headers = {"Authorization" : "Basic " + str_to_b64str ('{}:{}' .format (user , password ))}
@@ -64,9 +65,9 @@ def setup_chain(self):
64
65
self .password = lines [3 ]
65
66
66
67
with open (os .path .join (get_datadir_path (self .options .tmpdir , 0 ), "bitcoin.conf" ), 'a' , encoding = 'utf8' ) as f :
67
- f .write (rpcauth + "\n " )
68
- f .write (rpcauth2 + "\n " )
69
- f .write (rpcauth3 + "\n " )
68
+ f .write (rpcauth + "\n " )
69
+ f .write (rpcauth2 + "\n " )
70
+ f .write (rpcauth3 + "\n " )
70
71
with open (os .path .join (get_datadir_path (self .options .tmpdir , 1 ), "bitcoin.conf" ), 'a' , encoding = 'utf8' ) as f :
71
72
f .write ("rpcuser={}\n " .format (self .rpcuser ))
72
73
f .write ("rpcpassword={}\n " .format (self .rpcpassword ))
@@ -76,32 +77,27 @@ def test_auth(self, node, user, password):
76
77
assert_equal (200 , call_with_auth (node , user , password ).status )
77
78
78
79
self .log .info ('Wrong...' )
79
- assert_equal (401 , call_with_auth (node , user , password + 'wrong' ).status )
80
+ assert_equal (401 , call_with_auth (node , user , password + 'wrong' ).status )
80
81
81
82
self .log .info ('Wrong...' )
82
- assert_equal (401 , call_with_auth (node , user + 'wrong' , password ).status )
83
+ assert_equal (401 , call_with_auth (node , user + 'wrong' , password ).status )
83
84
84
85
self .log .info ('Wrong...' )
85
- assert_equal (401 , call_with_auth (node , user + 'wrong' , password + 'wrong' ).status )
86
+ assert_equal (401 , call_with_auth (node , user + 'wrong' , password + 'wrong' ).status )
86
87
87
88
def run_test (self ):
88
-
89
- ##################################################
90
- # Check correctness of the rpcauth config option #
91
- ##################################################
89
+ self .log .info ('Check correctness of the rpcauth config option' )
92
90
url = urllib .parse .urlparse (self .nodes [0 ].url )
93
91
94
92
self .test_auth (self .nodes [0 ], url .username , url .password )
95
93
self .test_auth (self .nodes [0 ], 'rt' , self .rtpassword )
96
94
self .test_auth (self .nodes [0 ], 'rt2' , self .rt2password )
97
95
self .test_auth (self .nodes [0 ], self .user , self .password )
98
96
99
- ###############################################################
100
- # Check correctness of the rpcuser/rpcpassword config options #
101
- ###############################################################
97
+ self .log .info ('Check correctness of the rpcuser/rpcpassword config options' )
102
98
url = urllib .parse .urlparse (self .nodes [1 ].url )
103
99
104
100
self .test_auth (self .nodes [1 ], self .rpcuser , self .rpcpassword )
105
101
106
102
if __name__ == '__main__' :
107
- HTTPBasicsTest ().main ()
103
+ HTTPBasicsTest ().main ()
0 commit comments