mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
test: Replace inline-comments with logs, pep8 formatting
This commit is contained in:
parent
fa83b39ff3
commit
fa12a37b27
1 changed files with 10 additions and 14 deletions
|
@ -20,6 +20,7 @@ import string
|
||||||
import configparser
|
import configparser
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def call_with_auth(node, user, password):
|
def call_with_auth(node, user, password):
|
||||||
url = urllib.parse.urlparse(node.url)
|
url = urllib.parse.urlparse(node.url)
|
||||||
headers = {"Authorization": "Basic " + str_to_b64str('{}:{}'.format(user, password))}
|
headers = {"Authorization": "Basic " + str_to_b64str('{}:{}'.format(user, password))}
|
||||||
|
@ -64,9 +65,9 @@ class HTTPBasicsTest(BitcoinTestFramework):
|
||||||
self.password = lines[3]
|
self.password = lines[3]
|
||||||
|
|
||||||
with open(os.path.join(get_datadir_path(self.options.tmpdir, 0), "bitcoin.conf"), 'a', encoding='utf8') as f:
|
with open(os.path.join(get_datadir_path(self.options.tmpdir, 0), "bitcoin.conf"), 'a', encoding='utf8') as f:
|
||||||
f.write(rpcauth+"\n")
|
f.write(rpcauth + "\n")
|
||||||
f.write(rpcauth2+"\n")
|
f.write(rpcauth2 + "\n")
|
||||||
f.write(rpcauth3+"\n")
|
f.write(rpcauth3 + "\n")
|
||||||
with open(os.path.join(get_datadir_path(self.options.tmpdir, 1), "bitcoin.conf"), 'a', encoding='utf8') as f:
|
with open(os.path.join(get_datadir_path(self.options.tmpdir, 1), "bitcoin.conf"), 'a', encoding='utf8') as f:
|
||||||
f.write("rpcuser={}\n".format(self.rpcuser))
|
f.write("rpcuser={}\n".format(self.rpcuser))
|
||||||
f.write("rpcpassword={}\n".format(self.rpcpassword))
|
f.write("rpcpassword={}\n".format(self.rpcpassword))
|
||||||
|
@ -76,19 +77,16 @@ class HTTPBasicsTest(BitcoinTestFramework):
|
||||||
assert_equal(200, call_with_auth(node, user, password).status)
|
assert_equal(200, call_with_auth(node, user, password).status)
|
||||||
|
|
||||||
self.log.info('Wrong...')
|
self.log.info('Wrong...')
|
||||||
assert_equal(401, call_with_auth(node, user, password+'wrong').status)
|
assert_equal(401, call_with_auth(node, user, password + 'wrong').status)
|
||||||
|
|
||||||
self.log.info('Wrong...')
|
self.log.info('Wrong...')
|
||||||
assert_equal(401, call_with_auth(node, user+'wrong', password).status)
|
assert_equal(401, call_with_auth(node, user + 'wrong', password).status)
|
||||||
|
|
||||||
self.log.info('Wrong...')
|
self.log.info('Wrong...')
|
||||||
assert_equal(401, call_with_auth(node, user+'wrong', password+'wrong').status)
|
assert_equal(401, call_with_auth(node, user + 'wrong', password + 'wrong').status)
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
|
self.log.info('Check correctness of the rpcauth config option')
|
||||||
##################################################
|
|
||||||
# Check correctness of the rpcauth config option #
|
|
||||||
##################################################
|
|
||||||
url = urllib.parse.urlparse(self.nodes[0].url)
|
url = urllib.parse.urlparse(self.nodes[0].url)
|
||||||
|
|
||||||
self.test_auth(self.nodes[0], url.username, url.password)
|
self.test_auth(self.nodes[0], url.username, url.password)
|
||||||
|
@ -96,12 +94,10 @@ class HTTPBasicsTest(BitcoinTestFramework):
|
||||||
self.test_auth(self.nodes[0], 'rt2', self.rt2password)
|
self.test_auth(self.nodes[0], 'rt2', self.rt2password)
|
||||||
self.test_auth(self.nodes[0], self.user, self.password)
|
self.test_auth(self.nodes[0], self.user, self.password)
|
||||||
|
|
||||||
###############################################################
|
self.log.info('Check correctness of the rpcuser/rpcpassword config options')
|
||||||
# Check correctness of the rpcuser/rpcpassword config options #
|
|
||||||
###############################################################
|
|
||||||
url = urllib.parse.urlparse(self.nodes[1].url)
|
url = urllib.parse.urlparse(self.nodes[1].url)
|
||||||
|
|
||||||
self.test_auth(self.nodes[1], self.rpcuser, self.rpcpassword)
|
self.test_auth(self.nodes[1], self.rpcuser, self.rpcpassword)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
HTTPBasicsTest ().main ()
|
HTTPBasicsTest().main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue