Skip to content

Commit b097d19

Browse files
committed
docs and unit test for security_opt
1 parent 1845d3b commit b097d19

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

docs/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ from. Optionally a single string joining container id's with commas
700700
* extra_hosts (dict): custom host-to-IP mappings (host:ip)
701701
* pid_mode (str): if set to "host", use the host PID namespace inside the
702702
container
703+
* security_opt (list): A list of string values to customize labels for MLS systems, such as SELinux.
703704

704705
```python
705706
>>> from docker import Client

tests/test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,19 @@ def test_tar_with_directory_symlinks(self):
22702270
tar = tarfile.open(fileobj=archive)
22712271
self.assertEqual(sorted(tar.getnames()), ['bar', 'bar/foo', 'foo'])
22722272

2273+
#######################
2274+
# HOST CONFIG TESTS #
2275+
#######################
2276+
2277+
def test_create_host_config_secopt(self):
2278+
security_opt = ['apparmor:test_profile']
2279+
result = create_host_config(security_opt=security_opt)
2280+
self.assertIn('SecurityOpt', result)
2281+
self.assertEqual(result['SecurityOpt'], security_opt)
2282+
2283+
with self.assertRaises(docker.errors.DockerException):
2284+
create_host_config(security_opt='wrong')
2285+
22732286

22742287
class StreamTest(Cleanup, unittest.TestCase):
22752288

0 commit comments

Comments
 (0)