Network fields schema validation
Signed-off-by: Dimitar Bonev <dimitar.bonev@gmail.com>
This commit is contained in:
parent
227fa5c0de
commit
5545c55ecc
3 changed files with 70 additions and 2 deletions
|
|
@ -88,11 +88,26 @@ class ConfigTest(unittest.TestCase):
|
|||
'driver': 'default',
|
||||
'driver_opts': {'beep': 'boop'}
|
||||
}
|
||||
},
|
||||
'networks': {
|
||||
'default': {
|
||||
'driver': 'bridge',
|
||||
'driver_opts': {'beep': 'boop'}
|
||||
},
|
||||
'with_ipam': {
|
||||
'ipam': {
|
||||
'driver': 'default',
|
||||
'config': [
|
||||
{'subnet': '172.28.0.0/16'}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 'working_dir', 'filename.yml')
|
||||
)
|
||||
service_dicts = config_data.services
|
||||
volume_dict = config_data.volumes
|
||||
networks_dict = config_data.networks
|
||||
self.assertEqual(
|
||||
service_sort(service_dicts),
|
||||
service_sort([
|
||||
|
|
@ -113,6 +128,20 @@ class ConfigTest(unittest.TestCase):
|
|||
'driver_opts': {'beep': 'boop'}
|
||||
}
|
||||
})
|
||||
self.assertEqual(networks_dict, {
|
||||
'default': {
|
||||
'driver': 'bridge',
|
||||
'driver_opts': {'beep': 'boop'}
|
||||
},
|
||||
'with_ipam': {
|
||||
'ipam': {
|
||||
'driver': 'default',
|
||||
'config': [
|
||||
{'subnet': '172.28.0.0/16'}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
def test_named_volume_config_empty(self):
|
||||
config_details = build_config_details({
|
||||
|
|
@ -191,6 +220,18 @@ class ConfigTest(unittest.TestCase):
|
|||
)
|
||||
)
|
||||
|
||||
def test_load_throws_error_with_invalid_network_fields(self):
|
||||
with self.assertRaises(ConfigurationError):
|
||||
config.load(
|
||||
build_config_details({
|
||||
'version': 2,
|
||||
'services': {'web': 'busybox:latest'},
|
||||
'networks': {
|
||||
'invalid': {'foo', 'bar'}
|
||||
}
|
||||
}, 'working_dir', 'filename.yml')
|
||||
)
|
||||
|
||||
def test_load_config_invalid_service_names(self):
|
||||
for invalid_name in ['?not?allowed', ' ', '', '!', '/', '\xe2']:
|
||||
with pytest.raises(ConfigurationError) as exc:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue