Skip to content

Commit

Permalink
Adding tests and vagrantfile for JunOS
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarrosop committed Sep 22, 2015
1 parent 41461a7 commit 3bc372a
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 310 deletions.
6 changes: 3 additions & 3 deletions test/unit/TestJunOSDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class TestJunOSDriver(unittest.TestCase, TestNetworkDriver):

@classmethod
def setUpClass(cls):
hostname = '192.168.76.11'
username = 'dbarroso'
password = 'this_is_not_a_secure_password'
hostname = '192.168.56.203'
username = 'vagrant'
password = 'vagrant123'
cls.vendor = 'junos'

cls.device = JunOSDriver(hostname, username, password)
Expand Down
2 changes: 0 additions & 2 deletions test/unit/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def print_diff_strings(orig, new):
for line in difflib.context_diff(orig.splitlines(), new.splitlines()):
print line

'''
def test_replacing_and_committing_config(self):
self.device.load_replace_candidate(filename='%s/new_good.conf' % self.vendor)
self.device.commit_config()
Expand Down Expand Up @@ -117,7 +116,6 @@ def test_merge_configuration_typo_and_rollback(self):
self.device.discard_config()

self.assertTrue(result)
'''

@staticmethod
def _test_model(model, data):
Expand Down
115 changes: 22 additions & 93 deletions test/unit/junos/initial.conf
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
version 12.1X47-D20.7;
system {
host-name junos-unittest;
host-name vsrx;
root-authentication {
encrypted-password "$1$7DeoJKZ/$ahBWi9d.0oV4SJtcK7bst0"; ## SECRET-DATA
encrypted-password "$1$5MhDFyrI$NBBMndW1POqbN.0QEA4z0."; ## SECRET-DATA
ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGnRjHTifULSGZiJA53JQRYuUgqXFJUq74Ste+fY1VBjYPqrBPNWWCKxUZoiVktUxPw1htTQIqanGBAW4fuzum/s4ZbTwswTRkZYi96RKSx6RK8zlwoLKwKhCRrFJKijcKn0ygZWOrcS3LPSr64tjsJJmNdgmNX8QFP7IHVWFFSv2HRIYYc+ibtunwH30RzAsyPeLOTFgRihlnyarO6T6EJsihudMWbHyzQY6DeDvIqZ3QwpcFhrNkVq8hm1D3ozqOEk9IRetEc+DV0g5EGRXQZcQi8PraT8COR8qFijzUBXO2mjVW183JgtfPkkxiikzBtJD5rqj5ymSJHUXNdxzn vagrant"; ## SECRET-DATA
}
login {
user dbarroso {
user vagrant {
uid 2000;
class super-user;
authentication {
encrypted-password "$1$EHPQTCAm$j.O6idmx8GjL1CH5dNoSM/"; ## SECRET-DATA
ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZNdIq1KbGzaaKjQLwVmhYbZZ2lNsVbqJqruEF7DaKfL1+0iMMwR4bx8fyzjweSTWG2k9zx9u9O1q3QAA9lsWkzuBYOch4iZIZauwI8R+GNRM7eUPyzfQ6jOkcdTK+1pRFx5s5QWAQqmsG78c+myWwMTOGpRKe46/ltw19xDIebivHffeeGV31zfSywoEWGvWR6BzkEnW2rBx0xzGIYQR8URRQj6Jjr5Qgjfqk1veay57BDPQ0iiejMxGZ0bw10gkOvAczBNYaLc7aKdmjFTfdp53A1suGmu8ZNyFFRDaQdaGMdpmFm5FDSD7NHNm5Mt2yJG9KG8vUMgDUUBxruTN1 [email protected]"; ## SECRET-DATA
encrypted-password "$1$KMQ6fIje$STNZNzDwjAb46xNonInGq/"; ## SECRET-DATA
ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"; ## SECRET-DATA
}
}
}
services {
ssh;
ssh {
root-login allow;
}
netconf {
ssh;
}
web-management {
http {
interface ge-0/0/0.0;
}
}
}
syslog {
user * {
Expand All @@ -46,98 +44,29 @@ system {
interfaces {
ge-0/0/0 {
unit 0 {
family inet {
address 192.168.76.11/24;
}
family inet {
address 192.168.56.203/24;
}
}
}
ge-0/0/1 {
unit 0;
}
}
protocols {
lldp {
interface all;
}
}
security {
screen {
ids-option untrust-screen {
icmp {
ping-death;
}
ip {
source-route-option;
tear-drop;
forwarding-options {
family {
inet6 {
mode packet-based;
}
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;
mpls {
mode packet-based;
}
}
}
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 {
permit;
}
}
}
}
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;
}
}
}
}
}
}
}
}
15 changes: 5 additions & 10 deletions test/unit/junos/merge_good.diff
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@

[edit system]
- host-name junos-CHANGED;
+ host-name junos-unittest;
[edit interfaces]
- ge-0/0/1 {
- unit 0 {
- family inet {
- address 192.168.77.11/24;
- }
- }
- }
+ host-name vsrx;
[edit interfaces ge-0/0/1 unit 0]
- family inet {
- address 192.168.77.11/24;
- }
115 changes: 22 additions & 93 deletions test/unit/junos/new_good.conf
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
version 12.1X47-D20.7;
system {
host-name junos-CHANGED;
host-name vsrx;
root-authentication {
encrypted-password "$1$7DeoJKZ/$ahBWi9d.0oV4SJtcK7bst0"; ## SECRET-DATA
encrypted-password "$1$5MhDFyrI$NBBMndW1POqbN.0QEA4z0."; ## SECRET-DATA
ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGnRjHTifULSGZiJA53JQRYuUgqXFJUq74Ste+fY1VBjYPqrBPNWWCKxUZoiVktUxPw1htTQIqanGBAW4fuzum/s4ZbTwswTRkZYi96RKSx6RK8zlwoLKwKhCRrFJKijcKn0ygZWOrcS3LPSr64tjsJJmNdgmNX8QFP7IHVWFFSv2HRIYYc+ibtunwH30RzAsyPeLOTFgRihlnyarO6T6EJsihudMWbHyzQY6DeDvIqZ3QwpcFhrNkVq8hm1D3ozqOEk9IRetEc+DV0g5EGRXQZcQi8PraT8COR8qFijzUBXO2mjVW183JgtfPkkxiikzBtJD5rqj5ymSJHUXNdxzn vagrant"; ## SECRET-DATA
}
login {
user dbarroso {
user vagrant {
uid 2000;
class super-user;
authentication {
encrypted-password "$1$EHPQTCAm$j.O6idmx8GjL1CH5dNoSM/"; ## SECRET-DATA
ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZNdIq1KbGzaaKjQLwVmhYbZZ2lNsVbqJqruEF7DaKfL1+0iMMwR4bx8fyzjweSTWG2k9zx9u9O1q3QAA9lsWkzuBYOch4iZIZauwI8R+GNRM7eUPyzfQ6jOkcdTK+1pRFx5s5QWAQqmsG78c+myWwMTOGpRKe46/ltw19xDIebivHffeeGV31zfSywoEWGvWR6BzkEnW2rBx0xzGIYQR8URRQj6Jjr5Qgjfqk1veay57BDPQ0iiejMxGZ0bw10gkOvAczBNYaLc7aKdmjFTfdp53A1suGmu8ZNyFFRDaQdaGMdpmFm5FDSD7NHNm5Mt2yJG9KG8vUMgDUUBxruTN1 [email protected]"; ## SECRET-DATA
encrypted-password "$1$KMQ6fIje$STNZNzDwjAb46xNonInGq/"; ## SECRET-DATA
ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"; ## SECRET-DATA
}
}
}
services {
ssh;
ssh {
root-login allow;
}
netconf {
ssh;
}
web-management {
http {
interface ge-0/0/0.0;
}
}
}
syslog {
user * {
Expand All @@ -46,9 +44,9 @@ system {
interfaces {
ge-0/0/0 {
unit 0 {
family inet {
address 192.168.76.11/24;
}
family inet {
address 192.168.56.203/24;
}
}
}
ge-0/0/1 {
Expand All @@ -58,93 +56,24 @@ interfaces {
}
}
}
ge-0/0/1 {
unit 0;
}
}
protocols {
lldp {
interface all;
}
}
security {
screen {
ids-option untrust-screen {
icmp {
ping-death;
}
ip {
source-route-option;
tear-drop;
forwarding-options {
family {
inet6 {
mode packet-based;
}
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;
mpls {
mode packet-based;
}
}
}
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 {
permit;
}
}
}
}
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;
}
}
}
}
}
}
}
}
16 changes: 4 additions & 12 deletions test/unit/junos/new_good.diff
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@

[edit system]
- host-name junos-unittest;
+ host-name junos-CHANGED;
[edit interfaces]
+ ge-0/0/1 {
+ unit 0 {
+ family inet {
+ address 192.168.77.11/24;
+ }
+ }
+ }
[edit interfaces ge-0/0/1 unit 0]
+ family inet {
+ address 192.168.77.11/24;
+ }
Loading

0 comments on commit 3bc372a

Please sign in to comment.