15 import http.client
as httplib
19 import urllib.parse
as urlparse
28 print(
"Initializing test directory "+self.options.tmpdir)
31 rpcauth =
"rpcauth=rt:93648e835a54c573682c2eb19f882535$7681e9c5b74bdd85e78166031d2058e1069b3ed7ed967c93fc63abba06f31144" 32 rpcauth2 =
"rpcauth=rt2:f8607b1a88861fac29dfccf9b52ff9f$ff36a0c23c8c62b4846112e50fa888416e94c17bfd4c42f88fd8f55ec6a3137e" 33 with open(os.path.join(self.options.tmpdir+
"/node0",
"dash.conf"),
'a')
as f:
35 f.write(rpcauth2+
"\n")
42 url = urlparse.urlparse(self.
nodes[0].url)
45 authpair = url.username +
':' + url.password
48 rpcauth =
"rpcauth=rt:93648e835a54c573682c2eb19f882535$7681e9c5b74bdd85e78166031d2058e1069b3ed7ed967c93fc63abba06f31144" 49 password =
"cA773lm788buwYe4g4WT+05pKyNruVKjQ25x3n0DQcM=" 52 rpcauth2 =
"rpcauth=rt2:f8607b1a88861fac29dfccf9b52ff9f$ff36a0c23c8c62b4846112e50fa888416e94c17bfd4c42f88fd8f55ec6a3137e" 53 password2 =
"8/F3uMDw4KSEbw96U3CA1C4X05dkHDN2BPFjTgZW4KI=" 54 authpairnew =
"rt:"+password
56 headers = {
"Authorization":
"Basic " +
str_to_b64str(authpair)}
58 conn = httplib.HTTPConnection(url.hostname, url.port)
60 conn.request(
'POST',
'/',
'{"method": "getbestblockhash"}', headers)
61 resp = conn.getresponse()
66 headers = {
"Authorization":
"Basic " +
str_to_b64str(authpairnew)}
68 conn = httplib.HTTPConnection(url.hostname, url.port)
70 conn.request(
'POST',
'/',
'{"method": "getbestblockhash"}', headers)
71 resp = conn.getresponse()
76 authpairnew =
"rtwrong:"+password
77 headers = {
"Authorization":
"Basic " +
str_to_b64str(authpairnew)}
79 conn = httplib.HTTPConnection(url.hostname, url.port)
81 conn.request(
'POST',
'/',
'{"method": "getbestblockhash"}', headers)
82 resp = conn.getresponse()
87 authpairnew =
"rt:"+password+
"wrong" 88 headers = {
"Authorization":
"Basic " +
str_to_b64str(authpairnew)}
90 conn = httplib.HTTPConnection(url.hostname, url.port)
92 conn.request(
'POST',
'/',
'{"method": "getbestblockhash"}', headers)
93 resp = conn.getresponse()
98 authpairnew =
"rt2:"+password2
99 headers = {
"Authorization":
"Basic " +
str_to_b64str(authpairnew)}
101 conn = httplib.HTTPConnection(url.hostname, url.port)
103 conn.request(
'POST',
'/',
'{"method": "getbestblockhash"}', headers)
104 resp = conn.getresponse()
109 authpairnew =
"rt2:"+password2+
"wrong" 110 headers = {
"Authorization":
"Basic " +
str_to_b64str(authpairnew)}
112 conn = httplib.HTTPConnection(url.hostname, url.port)
114 conn.request(
'POST',
'/',
'{"method": "getbestblockhash"}', headers)
115 resp = conn.getresponse()
120 if __name__ ==
'__main__':
121 HTTPBasicsTest ().main ()
def initialize_chain(test_dir)
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None)
def str_to_b64str(string)
def assert_equal(thing1, thing2)