@@ -61,63 +61,40 @@ def setup_chain(self):
61
61
f .write (rpcuser + "\n " )
62
62
f .write (rpcpassword + "\n " )
63
63
64
- def run_test (self ):
65
-
66
- ##################################################
67
- # Check correctness of the rpcauth config option #
68
- ##################################################
69
- url = urllib .parse .urlparse (self .nodes [0 ].url )
70
-
71
- password = "cA773lm788buwYe4g4WT+05pKyNruVKjQ25x3n0DQcM="
72
- password2 = "8/F3uMDw4KSEbw96U3CA1C4X05dkHDN2BPFjTgZW4KI="
73
-
64
+ def test_auth (self , node , user , password ):
74
65
self .log .info ('Correct...' )
75
- assert_equal (200 , call_with_auth (self . nodes [ 0 ], url . username , url . password ).status )
66
+ assert_equal (200 , call_with_auth (node , user , password ).status )
76
67
77
- #Use new authpair to confirm both work
78
- self .log .info ('Correct...' )
79
- assert_equal (200 , call_with_auth (self .nodes [0 ], 'rt' , password ).status )
68
+ self .log .info ('Wrong...' )
69
+ assert_equal (401 , call_with_auth (node , user , password + 'wrong' ).status )
80
70
81
- #Wrong login name with rt's password
82
71
self .log .info ('Wrong...' )
83
- assert_equal (401 , call_with_auth (self . nodes [ 0 ], 'rtwrong ' , password ).status )
72
+ assert_equal (401 , call_with_auth (node , user + 'wrong ' , password ).status )
84
73
85
- #Wrong password for rt
86
74
self .log .info ('Wrong...' )
87
- assert_equal (401 , call_with_auth (self . nodes [ 0 ], 'rt ' , password + 'wrong' ).status )
75
+ assert_equal (401 , call_with_auth (node , user + 'wrong ' , password + 'wrong' ).status )
88
76
89
- #Correct for rt2
90
- self .log .info ('Correct...' )
91
- assert_equal (200 , call_with_auth (self .nodes [0 ], 'rt2' , password2 ).status )
77
+ def run_test (self ):
92
78
93
- #Wrong password for rt2
94
- self .log .info ('Wrong...' )
95
- assert_equal (401 , call_with_auth (self .nodes [0 ], 'rt2' , password2 + 'wrong' ).status )
79
+ ##################################################
80
+ # Check correctness of the rpcauth config option #
81
+ ##################################################
82
+ url = urllib .parse .urlparse (self .nodes [0 ].url )
96
83
97
- #Correct for randomly generated user
98
- self .log .info ('Correct...' )
99
- assert_equal (200 , call_with_auth (self .nodes [0 ], self .user , self .password ).status )
84
+ password = "cA773lm788buwYe4g4WT+05pKyNruVKjQ25x3n0DQcM="
85
+ password2 = "8/F3uMDw4KSEbw96U3CA1C4X05dkHDN2BPFjTgZW4KI="
100
86
101
- #Wrong password for randomly generated user
102
- self .log .info ('Wrong...' )
103
- assert_equal (401 , call_with_auth (self .nodes [0 ], self .user , self .password + 'Wrong' ).status )
87
+ self .test_auth (self .nodes [0 ], url .username , url .password )
88
+ self .test_auth (self .nodes [0 ], 'rt' , password )
89
+ self .test_auth (self .nodes [0 ], 'rt2' , password2 )
90
+ self .test_auth (self .nodes [0 ], self .user , self .password )
104
91
105
92
###############################################################
106
93
# Check correctness of the rpcuser/rpcpassword config options #
107
94
###############################################################
108
95
url = urllib .parse .urlparse (self .nodes [1 ].url )
109
96
110
- # rpcuser and rpcpassword authpair
111
- self .log .info ('Correct...' )
112
- assert_equal (200 , call_with_auth (self .nodes [1 ], "rpcuser💻" , "rpcpassword🔑" ).status )
113
-
114
- #Wrong login name with rpcuser's password
115
- self .log .info ('Wrong...' )
116
- assert_equal (401 , call_with_auth (self .nodes [1 ], 'rpcuserwrong' , 'rpcpassword' ).status )
117
-
118
- #Wrong password for rpcuser
119
- self .log .info ('Wrong...' )
120
- assert_equal (401 , call_with_auth (self .nodes [1 ], 'rpcuser' , 'rpcpasswordwrong' ).status )
97
+ self .test_auth (self .nodes [1 ], "rpcuser💻" , "rpcpassword🔑" )
121
98
122
99
if __name__ == '__main__' :
123
100
HTTPBasicsTest ().main ()
0 commit comments