tests: check readability of cookie file

This commit is contained in:
Chun Kuan Lee 2018-11-24 02:32:38 +08:00
parent 2607c38fc5
commit d6b3790d1a

View file

@ -326,7 +326,7 @@ def get_auth_cookie(datadir):
if line.startswith("rpcpassword="): if line.startswith("rpcpassword="):
assert password is None # Ensure that there is only one rpcpassword line assert password is None # Ensure that there is only one rpcpassword line
password = line.split("=")[1].strip("\n") password = line.split("=")[1].strip("\n")
if os.path.isfile(os.path.join(datadir, "regtest", ".cookie")): if os.path.isfile(os.path.join(datadir, "regtest", ".cookie")) and os.access(os.path.join(datadir, "regtest", ".cookie"), os.R_OK):
with open(os.path.join(datadir, "regtest", ".cookie"), 'r', encoding="ascii") as f: with open(os.path.join(datadir, "regtest", ".cookie"), 'r', encoding="ascii") as f:
userpass = f.read() userpass = f.read()
split_userpass = userpass.split(':') split_userpass = userpass.split(':')