(self)
| 84 | assert_equal(401, call_with_auth(node, user + 'wrong', password + 'wrong').status) |
| 85 | |
| 86 | def test_rpccookieperms(self): |
| 87 | p = {"owner": 0o600, "group": 0o640, "all": 0o644} |
| 88 | |
| 89 | if platform.system() == 'Windows': |
| 90 | self.log.info(f"Skip cookie file permissions checks as OS detected as: {platform.system()=}") |
| 91 | return |
| 92 | |
| 93 | self.log.info('Check cookie file permissions can be set using -rpccookieperms') |
| 94 | |
| 95 | cookie_file_path = self.nodes[1].chain_path / '.cookie' |
| 96 | PERM_BITS_UMASK = 0o777 |
| 97 | |
| 98 | def test_perm(perm: Optional[str]): |
| 99 | if not perm: |
| 100 | perm = 'owner' |
| 101 | self.restart_node(1) |
| 102 | else: |
| 103 | self.restart_node(1, extra_args=[f"-rpccookieperms={perm}"]) |
| 104 | |
| 105 | file_stat = os.stat(cookie_file_path) |
| 106 | actual_perms = file_stat.st_mode & PERM_BITS_UMASK |
| 107 | expected_perms = p[perm] |
| 108 | assert_equal(expected_perms, actual_perms) |
| 109 | |
| 110 | # Remove any leftover rpc{user|password} config options from previous tests |
| 111 | self.stop_node(1) |
| 112 | self.nodes[1].replace_in_config([("rpcuser", "#rpcuser"), ("rpcpassword", "#rpcpassword")]) |
| 113 | |
| 114 | self.log.info('Check default cookie permission') |
| 115 | test_perm(None) |
| 116 | |
| 117 | self.log.info('Check custom cookie permissions') |
| 118 | for perm in ["owner", "group", "all"]: |
| 119 | test_perm(perm) |
| 120 | |
| 121 | def test_norpccookiefile(self, node0_cookie_path): |
| 122 | assert self.nodes[0].is_node_stopped(), "We expect previous test to stopped the node" |
no test coverage detected