-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from Juniper/unit-tests
Unit tests up to 70% overall.
- Loading branch information
Showing
39 changed files
with
1,744 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[run] | ||
omit = | ||
lib/jnpr/junos/cfg/phyport/* | ||
lib/jnpr/junos/cfg/srx/* |
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
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,42 @@ | ||
__author__ = "Nitin Kumar, Rick Sherman" | ||
__credits__ = "Jeremy Schulman" | ||
|
||
import unittest | ||
from nose.plugins.attrib import attr | ||
from mock import patch | ||
|
||
from jnpr.junos.facts.domain import facts_domain | ||
from jnpr.junos import Device | ||
|
||
|
||
@attr('unit') | ||
class TestDomain(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.dev = Device(host='1.1.1.1', user='rick', password='password123', | ||
gather_facts=False) | ||
self.facts = {} | ||
|
||
@patch('jnpr.junos.facts.domain.FS.cat') | ||
def test_resolv_conf(self, mock_fs_cat): | ||
mock_fs_cat.return_value =\ | ||
"""# domain juniper.net | ||
search englab.juniper.net spglab.juniper.net juniper.net jnpr.net | ||
nameserver 10.11.12.13 | ||
""" | ||
self.facts['hostname'] = 'test' | ||
facts_domain(self.dev, self.facts) | ||
self.assertEqual(self.facts['domain'], 'juniper.net') | ||
self.assertEqual(self.facts['fqdn'], 'test.juniper.net') | ||
|
||
@patch('jnpr.junos.facts.domain.FS.cat') | ||
def test_resolv_conf_no_domain(self, mock_fs_cat): | ||
mock_fs_cat.return_value =\ | ||
""" | ||
search englab.juniper.net spglab.juniper.net juniper.net jnpr.net | ||
nameserver 10.11.12.13 | ||
""" | ||
self.facts['hostname'] = 'test' | ||
facts_domain(self.dev, self.facts) | ||
self.assertIsNone(self.facts['domain']) | ||
self.assertEqual(self.facts['fqdn'], 'test') |
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,154 @@ | ||
<configuration-information> | ||
<configuration-output> | ||
## Last commit: 2014-03-24 16:34:32 UTC by rick | ||
version 12.1X46-D15.3; | ||
system { | ||
host-name firefly; | ||
root-authentication { | ||
encrypted-password "$1$kmSqRIU6$9EogG7ow0DWiww9mev8.b."; ## SECRET-DATA | ||
} | ||
login { | ||
user rick { | ||
uid 2000; | ||
class super-user; | ||
authentication { | ||
encrypted-password "$1$wDDri7eJ$2Ot4pfE29PgVbeutIveov1"; ## SECRET-DATA | ||
} | ||
} | ||
} | ||
services { | ||
ssh; | ||
netconf { | ||
ssh; | ||
} | ||
web-management { | ||
http { | ||
interface ge-0/0/0.0; | ||
} | ||
} | ||
} | ||
syslog { | ||
user * { | ||
any emergency; | ||
} | ||
file messages { | ||
any any; | ||
authorization info; | ||
} | ||
file interactive-commands { | ||
interactive-commands any; | ||
} | ||
} | ||
license { | ||
autoupdate { | ||
url https://ae1.juniper.net/junos/key_retrieval; | ||
} | ||
} | ||
} | ||
interfaces { | ||
ge-0/0/0 { | ||
unit 0 { | ||
family inet { | ||
address 10.0.0.31/24; | ||
} | ||
} | ||
} | ||
ge-0/0/1 { | ||
unit 0 { | ||
family inet { | ||
address 192.168.2.1/24; | ||
} | ||
} | ||
} | ||
} | ||
routing-options { | ||
static { | ||
route 0.0.0.0/0 next-hop 10.0.0.1; | ||
} | ||
} | ||
security { | ||
screen { | ||
ids-option untrust-screen { | ||
icmp { | ||
ping-death; | ||
} | ||
ip { | ||
source-route-option; | ||
tear-drop; | ||
} | ||
tcp { | ||
syn-flood { | ||
alarm-threshold 1024; | ||
attack-threshold 200; | ||
source-threshold 1024; | ||
destination-threshold 2048; | ||
queue-size 2000; ## Warning: 'queue-size' is deprecated | ||
timeout 20; | ||
} | ||
land; | ||
} | ||
} | ||
} | ||
policies { | ||
from-zone trust to-zone trust { | ||
policy default-permit { | ||
match { | ||
source-address any; | ||
destination-address any; | ||
application any; | ||
} | ||
then { | ||
permit; | ||
} | ||
} | ||
} | ||
from-zone trust to-zone untrust { | ||
policy default-permit { | ||
match { | ||
source-address any; | ||
destination-address any; | ||
application any; | ||
} | ||
then { | ||
permit; | ||
} | ||
} | ||
} | ||
from-zone untrust to-zone trust { | ||
policy default-deny { | ||
match { | ||
source-address any; | ||
destination-address any; | ||
application any; | ||
} | ||
then { | ||
deny; | ||
} | ||
} | ||
} | ||
} | ||
zones { | ||
security-zone trust { | ||
tcp-rst; | ||
} | ||
security-zone untrust { | ||
screen untrust-screen; | ||
interfaces { | ||
ge-0/0/0.0 { | ||
host-inbound-traffic { | ||
system-services { | ||
http; | ||
https; | ||
ssh; | ||
telnet; | ||
dhcp; | ||
netconf; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
</configuration-output> | ||
</configuration-information> |
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,5 @@ | ||
<output> | ||
1 alarms currently active | ||
Alarm time Class Description | ||
2014-04-17 09:09:21 UTC Minor Rescue configuration is not set | ||
</output> |
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,9 @@ | ||
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/12.1X46/junos"> | ||
<rpc> | ||
<get-system-uptime-information> | ||
</get-system-uptime-information> | ||
</rpc> | ||
<cli> | ||
<banner></banner> | ||
</cli> | ||
</rpc-reply> |
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,4 @@ | ||
system { | ||
host-name {{ host_name }}; | ||
domain-name {{ domain_name }}; | ||
} |
Oops, something went wrong.