mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-26 03:28:17 +00:00
un-writable directory test
This commit is contained in:
parent
613a6f80aa
commit
30e3cd23da
@ -194,10 +194,16 @@ def sign(ctx, name, expiry_days):
|
||||
next_serial = 0
|
||||
f = None
|
||||
while f is None:
|
||||
fname = "{}.cert.{}".format(name, next_serial)
|
||||
try:
|
||||
f = fp.child("{}.cert.{}".format(name, next_serial)).create()
|
||||
except OSError:
|
||||
f = None
|
||||
f = fp.child(fname).create()
|
||||
except OSError as e:
|
||||
if e.errno == 17: # file exists
|
||||
f = None
|
||||
else:
|
||||
raise click.ClickException(
|
||||
"{}: {}".format(fname, e)
|
||||
)
|
||||
next_serial += 1
|
||||
with f:
|
||||
f.write(certificate_data)
|
||||
|
@ -164,6 +164,23 @@ class GridManagerCommandLine(SyncTestCase):
|
||||
result.output,
|
||||
)
|
||||
|
||||
def test_sign_bad_perms(self):
|
||||
"""
|
||||
Error reported if we can't create certificate file
|
||||
"""
|
||||
pubkey = "pub-v0-cbq6hcf3pxcz6ouoafrbktmkixkeuywpcpbcomzd3lqbkq4nmfga"
|
||||
with self.runner.isolated_filesystem():
|
||||
self.runner.invoke(grid_manager, ["--config", "foo", "create"])
|
||||
self.runner.invoke(grid_manager, ["--config", "foo", "add", "storage0", pubkey])
|
||||
# make the directory un-writable (so we can't create a new cert)
|
||||
os.chmod("foo", 0o550)
|
||||
result = self.runner.invoke(grid_manager, ["--config", "foo", "sign", "storage0", "42"])
|
||||
self.assertEquals(result.exit_code, 1)
|
||||
self.assertIn(
|
||||
"Permission denied",
|
||||
result.output,
|
||||
)
|
||||
|
||||
|
||||
class TahoeAddGridManagerCert(AsyncTestCase):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user