Skip to content

Commit

Permalink
Additional validation and increased test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Smith committed May 12, 2017
1 parent 2ef844e commit a017ca7
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
7 changes: 5 additions & 2 deletions applications/multisite/intersite.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,8 +881,11 @@ def validate(self):

def get_interfaces(self):
interfaces = []
for interface in self._policy['site']['interfaces']:
interfaces.append(L3OutPolicy(interface))
try:
for interface in self._policy['site']['interfaces']:
interfaces.append(L3OutPolicy(interface))
except KeyError:
logging.warning('No interfaces in JSON for Site %s', self._policy['site']['name'])
return interfaces

def has_interface_policy(self, interface_policy_name):
Expand Down
60 changes: 60 additions & 0 deletions applications/multisite/intersite_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,36 @@ def test_site_with_good_ipaddress_and_bad_userid(self):

self.assertRaises(ValueError, execute_tool, args, test_mode=True)

def test_site_with_bad_local_setting(self):
"""
Test with bad local setting in the site JSON. Verify that the correct exception is generated.
:return: None
"""
args = self.get_args()
config = self.create_empty_config_file()
config['config'][0]['site']['username'] = 'admin'
config['config'][0]['site']['ip_address'] = SITE1_IPADDR
config['config'][0]['site']['local'] = 'BAD'
config['config'][0]['site']['use_https'] = 'True'
self.create_config_file(args, config)

self.assertRaises(ValueError, execute_tool, args, test_mode=True)

def test_site_with_bad_use_https(self):
"""
Test with bad use_https setting in the site JSON. Verify that the correct exception is generated.
:return: None
"""
args = self.get_args()
config = self.create_empty_config_file()
config['config'][0]['site']['username'] = 'admin'
config['config'][0]['site']['ip_address'] = SITE1_IPADDR
config['config'][0]['site']['local'] = 'True'
config['config'][0]['site']['use_https'] = 'BAD'
self.create_config_file(args, config)

self.assertRaises(ValueError, execute_tool, args, test_mode=True)

def test_reload_bad_config_filename(self):
"""
Test reload_config with a non-existent filename
Expand Down Expand Up @@ -396,6 +426,36 @@ def test_oversized_intersite_tag(self):
self.create_config_file(args, config)
self.assertRaises(ValueError, execute_tool, args, test_mode=True)

def test_duplicate_export_policy(self):
"""
Test oversized string lengths for the entities that make up a Intersite tag
"""
# Create a configuration with long names
args = self.get_args()
config = self.create_empty_config_file()
export_policy = {
"export":
{
"tenant": "mytenant",
"app": "myapp",
"epg": "myepg",
"remote_epg": "intersite-testsuite-app-epg",
"remote_sites":
[
{
"site":
{
"name": "mysite",
}
}
]
}
}
config['config'].append(export_policy)
config['config'].append(export_policy)

self.create_config_file(args, config)
self.assertRaises(ValueError, execute_tool, args, test_mode=True)



Expand Down

0 comments on commit a017ca7

Please sign in to comment.