Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_users.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2016 The Bitcoin Core developers | # Copyright (c) 2015-2016 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test multiple RPC users.""" | """Test multiple RPC users.""" | ||||
import configparser | |||||
import http.client | import http.client | ||||
import os | import os | ||||
import urllib.parse | |||||
import subprocess | |||||
from random import SystemRandom | from random import SystemRandom | ||||
import string | import string | ||||
import configparser | import subprocess | ||||
import sys | |||||
import urllib.parse | |||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import ( | ||||
assert_equal, | assert_equal, | ||||
get_datadir_path, | get_datadir_path, | ||||
str_to_b64str, | str_to_b64str, | ||||
) | ) | ||||
Show All 10 Lines | def setup_chain(self): | ||||
rpcuser = "rpcuser=rpcuser💻" | rpcuser = "rpcuser=rpcuser💻" | ||||
rpcpassword = "rpcpassword=rpcpassword🔑" | rpcpassword = "rpcpassword=rpcpassword🔑" | ||||
self.user = ''.join(SystemRandom().choice( | self.user = ''.join(SystemRandom().choice( | ||||
string.ascii_letters + string.digits) for _ in range(10)) | string.ascii_letters + string.digits) for _ in range(10)) | ||||
config = configparser.ConfigParser() | config = configparser.ConfigParser() | ||||
config.read_file(open(self.options.configfile, encoding='utf-8')) | config.read_file(open(self.options.configfile, encoding='utf-8')) | ||||
gen_rpcauth = config['environment']['RPCAUTH'] | gen_rpcauth = config['environment']['RPCAUTH'] | ||||
p = subprocess.Popen([gen_rpcauth, self.user], | p = subprocess.Popen([sys.executable, gen_rpcauth, self.user], | ||||
stdout=subprocess.PIPE, universal_newlines=True) | stdout=subprocess.PIPE, universal_newlines=True) | ||||
lines = p.stdout.read().splitlines() | lines = p.stdout.read().splitlines() | ||||
rpcauth3 = lines[1] | rpcauth3 = lines[1] | ||||
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") | ||||
▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines |