Skip to content

Commit

Permalink
Merge pull request #1357 from anarkiwi/master
Browse files Browse the repository at this point in the history
Check dp_conf is a dict.
  • Loading branch information
anarkiwi committed Dec 4, 2017
2 parents 438b7a4 + b26a12f commit 1582fbf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions faucet/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def _dp_add_ports(dp, dp_conf, dp_id, vlans):
_dp_add_vlan(dp, vlan)

for identifier, dp_conf in list(dps_conf.items()):
assert isinstance(dp_conf, dict)
dp = DP(identifier, dp_conf.get('dp_id', None), dp_conf)
dp_id = dp.dp_id

Expand Down
15 changes: 15 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,21 @@ def test_missing_route_config(self):

self.check_config_failure(config, cp.dp_parser)

def test_invalid_dp_conf(self):
config = """
vlans:
office:
vid: 100
dps:
sw1:
dp_id: 0x1
interfaces:
1:
description: "host1 container"
0 native_vlan: office
"""
self.check_config_failure(config, cp.dp_parser)


if __name__ == "__main__":
unittest.main()

0 comments on commit 1582fbf

Please sign in to comment.