-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[airos] added tests and mock backends for defaulted converters
- Loading branch information
Showing
11 changed files
with
222 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from .mock import SnmpAirOs, ConverterTest | ||
|
||
|
||
class TestSnmpConverter(ConverterTest): | ||
""" | ||
tests for backends.airos.renderers.SystemRenderer | ||
""" | ||
backend = SnmpAirOs | ||
|
||
def test_defaults(self): | ||
|
||
o = self.backend({}) | ||
o.to_intermediate() | ||
expected = [ | ||
{ | ||
'community': 'public', | ||
'contact': '', | ||
'location': '', | ||
'status': 'enabled', | ||
} | ||
] | ||
|
||
self.assertEqualConfig(o.intermediate_data['snmp'], expected) | ||
|
||
def test_custom_info(self): | ||
|
||
o = self.backend({ | ||
'general': { | ||
'mantainer': '[email protected]', | ||
'location': 'somewhere in the woods', | ||
} | ||
}) | ||
o.to_intermediate() | ||
expected = [ | ||
{ | ||
'community': 'public', | ||
'contact': '[email protected]', | ||
'location': 'somewhere in the woods', | ||
'status': 'enabled', | ||
} | ||
] | ||
|
||
self.assertEqualConfig(o.intermediate_data['snmp'], expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from .mock import SyslogAirOs, ConverterTest | ||
|
||
|
||
class TestSyslogConverter(ConverterTest): | ||
backend = SyslogAirOs | ||
|
||
def test_active(self): | ||
o = self.backend({}) | ||
o.to_intermediate() | ||
expected = [ | ||
{ | ||
'remote.port': 514, | ||
'remote.status': 'disabled', | ||
'status': 'enabled', | ||
} | ||
] | ||
self.assertEqualConfig(o.intermediate_data['syslog'], expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from .mock import SystemAirOs, ConverterTest | ||
|
||
|
||
class TestSystemConverter(ConverterTest): | ||
backend = SystemAirOs | ||
|
||
def test_active(self): | ||
o = self.backend({}) | ||
o.to_intermediate() | ||
expected = [ | ||
{ | ||
'airosx.prov.status': 'enabled', | ||
'cfg.version': 0, | ||
'date.status': 'disabled', | ||
'external.reset': 'enabled', | ||
'timezone': 'GMT' | ||
} | ||
] | ||
self.assertEqualConfig(o.intermediate_data['system'], expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from .mock import TelnetdAirOs, ConverterTest | ||
|
||
|
||
class TestTelnetdConverter(ConverterTest): | ||
backend = TelnetdAirOs | ||
|
||
def test_active(self): | ||
o = self.backend({}) | ||
o.to_intermediate() | ||
expected = [ | ||
{ | ||
'port': 23, | ||
'status': 'disabled' | ||
} | ||
] | ||
self.assertEqualConfig(o.intermediate_data['telnetd'], expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from .mock import TshaperAirOs, ConverterTest | ||
|
||
|
||
class TestTshaperConverter(ConverterTest): | ||
backend = TshaperAirOs | ||
|
||
def test_active(self): | ||
o = self.backend({}) | ||
o.to_intermediate() | ||
expected = [{'status': 'disabled'}] | ||
self.assertEqualConfig(o.intermediate_data['tshaper'], expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from .mock import UnmsAirOs, ConverterTest | ||
|
||
|
||
class TestUnmsConverter(ConverterTest): | ||
backend = UnmsAirOs | ||
|
||
def test_active(self): | ||
o = self.backend({}) | ||
o.to_intermediate() | ||
expected = [{'status': 'disabled'}] | ||
self.assertEqualConfig(o.intermediate_data['unms'], expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from .mock import UpdateAirOs, ConverterTest | ||
|
||
|
||
class TestUpdateConverter(ConverterTest): | ||
backend = UpdateAirOs | ||
|
||
def test_status(self): | ||
o = self.backend({}) | ||
o.to_intermediate() | ||
expected = [ | ||
{'check.status': 'enabled'} | ||
] | ||
self.assertEqualConfig(o.intermediate_data['update'], expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from .mock import UpnpdAirOs, ConverterTest | ||
|
||
|
||
class TestUpnpdConverter(ConverterTest): | ||
""" | ||
tests for backends.airos.renderers.SystemRenderer | ||
""" | ||
backend = UpnpdAirOs | ||
|
||
def test_bridge(self): | ||
|
||
o = self.backend({ | ||
'netmode': 'bridge', | ||
}) | ||
o.to_intermediate() | ||
with self.assertRaises(KeyError): | ||
o.intermediate_data['upnpd'] | ||
|
||
def test_router(self): | ||
o = self.backend({ | ||
'netmode': 'router', | ||
}) | ||
o.to_intermediate() | ||
expected = [ | ||
{ | ||
'status': 'disabled', | ||
} | ||
] | ||
self.assertEqualConfig(o.intermediate_data['upnpd'], expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from .mock import UsersAirOs, ConverterTest | ||
|
||
|
||
class TestUsersConverter(ConverterTest): | ||
""" | ||
tests for backends.airos.renderers.SystemRenderer | ||
""" | ||
backend = UsersAirOs | ||
|
||
def test_user(self): | ||
|
||
o = self.backend({ | ||
'user': { | ||
'name': 'ubnt', | ||
'password': 'changeme', | ||
'salt': 'goodsalt', | ||
} | ||
}) | ||
o.to_intermediate() | ||
expected = [ | ||
{ | ||
'status': 'enabled', | ||
}, | ||
{ | ||
'1.name': 'ubnt', | ||
'1.password': '$1$goodsalt$changeme', | ||
'1.status': 'enabled', | ||
} | ||
] | ||
|
||
self.assertEqualConfig(o.intermediate_data['users'], expected) |