Skip to content

Commit

Permalink
tests: use proper 0o600 file permissions in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
slyon committed Apr 19, 2024
1 parent cf65bcd commit 3ab206a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/cli/test_get_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def test_set_origin_hint_override_no_leak_renderer(self):
f.write('''network:
renderer: networkd
bridges: {br54: {dhcp4: true}}''')
os.chmod(defaults, mode=0o600)
self._set(['bridges.br54.dhcp4=false', '--origin-hint=90-snapd-config'])
self.assertTrue(os.path.isfile(defaults))
with open(defaults, 'r') as f:
Expand Down Expand Up @@ -730,6 +731,7 @@ def test_get_all(self):
def test_get_network(self):
with open(self.path, 'w') as f:
f.write('network:\n version: 2\n renderer: NetworkManager')
os.chmod(self.path, mode=0o600)
out = yaml.safe_load(self._get(['network']))
self.assertDictEqual({'renderer': 'NetworkManager', 'version': 2}, out)

Expand Down
1 change: 1 addition & 0 deletions tests/generator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ def generate(self, yaml, expect_fail=False, extra_args=[], confs=None, skip_gene
path = os.path.join(self.confdir, f + '.yaml')
with open(path, 'w') as f:
f.write(contents)
os.chmod(path, mode=0o600)
yaml_input.append(path)

argv = [exe_generate, '--root-dir', self.workdir.name] + extra_args
Expand Down
2 changes: 2 additions & 0 deletions tests/generator/test_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def test_help(self):
ethernets:
eth0:
dhcp4: true''')
os.chmod(conf, mode=0o600)

p = subprocess.Popen([exe_generate, '--root-dir', self.workdir.name, '--help'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
Expand Down Expand Up @@ -125,6 +126,7 @@ def test_systemd_generator(self):
ethernets:
eth0:
dhcp4: true''')
os.chmod(conf, mode=0o600)
outdir = os.path.join(self.workdir.name, 'out')
os.mkdir(outdir)

Expand Down

0 comments on commit 3ab206a

Please sign in to comment.