We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cdf6957 commit 8cf6217Copy full SHA for 8cf6217
tests/container_hardening/test_container_hardening.py
@@ -13,6 +13,11 @@ def test_bgp_dev(duthost):
13
"""
14
Test bgp container has no access to /dev/vda* or /dev/sda*
15
16
- device = duthost.shell("docker exec bgp bash -c 'df -h | grep /etc/hosts' | awk '{print $1}'")['stdout']
+ cmd = duthost.shell("docker exec bgp bash -c 'df -h | grep /etc/hosts' | awk '{print $1}'")
17
+ rc, device = cmd['rc'], cmd['stdout']
18
+ if rc != 0:
19
+ pytest_assert(False, 'Failed to get the device name.')
20
+ if not device.startswith('/dev/'):
21
+ pytest_assert(False, 'Invalid device {}.'.format(device))
22
output = duthost.shell("docker exec bgp bash -c 'ls {}'".format(device), module_ignore_errors=True)['stdout']
23
pytest_assert(not output, 'The partition {} exists.'.format(device))
0 commit comments