From b96e47592d5f2c8f537817e73b08674068a446aa Mon Sep 17 00:00:00 2001 From: Jonathan Claudius Date: Fri, 26 Oct 2018 12:55:32 -0400 Subject: [PATCH] Add test coverage for various action types --- test_connection.py | 110 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) diff --git a/test_connection.py b/test_connection.py index 8dc52b7..7f303ae 100644 --- a/test_connection.py +++ b/test_connection.py @@ -22,7 +22,7 @@ class TestConnection(): assert connection.verb_details == "from IP=192.168.1.1:56822 (IP=0.0.0.0:389)" assert connection.client == "192.168.1.1" - def test_add_event(self): + def test_add_event_accept(self): event = {'time': 'Oct 26 12:46:58', 'server': 'ldap.example.com', 'process': 'slapd[11086]', @@ -40,3 +40,111 @@ class TestConnection(): assert connection.verb == "ACCEPT" assert connection.verb_details == "from IP=192.168.1.1:56822 (IP=0.0.0.0:389)" assert connection.client == "192.168.1.1" + + def test_add_event_ext(self): + event = {'time': 'Oct 26 12:46:58', + 'server': 'ldap.example.com', + 'process': 'slapd[11086]', + 'conn': '6862452', + 'rest': 'op=0 EXT oid=1.3.6.1.4.1.1466.20037'} + + connection = Connection(1245) + connection.add_event(event) + assert connection.time == event["time"] + assert connection.server == event["server"] + assert connection.process == event["process"] + assert connection.conn_id == 1245 + assert connection.fd == "" + assert connection.op == 0 + assert connection.verb == "EXT" + assert connection.verb_details == "oid=1.3.6.1.4.1.1466.20037" + + def test_add_event_starttls(self): + event = {'time': 'Oct 26 12:46:58', + 'server': 'ldap.example.com', + 'process': 'slapd[11086]', + 'conn': '6862452', + 'rest': 'op=0 STARTTLS'} + + connection = Connection(1245) + connection.add_event(event) + assert connection.time == event["time"] + assert connection.server == event["server"] + assert connection.process == event["process"] + assert connection.conn_id == 1245 + assert connection.fd == "" + assert connection.op == 0 + assert connection.verb == "STARTTLS" + assert connection.verb_details == "" + + def test_add_event_result(self): + event = {'time': 'Oct 26 12:46:58', + 'server': 'ldap.example.com', + 'process': 'slapd[11086]', + 'conn': '6862452', + 'rest': 'op=0 RESULT oid= err=0 text='} + + connection = Connection(1245) + connection.add_event(event) + assert connection.time == event["time"] + assert connection.server == event["server"] + assert connection.process == event["process"] + assert connection.conn_id == 1245 + assert connection.fd == "" + assert connection.op == 0 + assert connection.verb == "RESULT" + assert connection.verb_details == "oid= err=0 text=" + + def test_add_event_result(self): + event = {'time': 'Oct 26 12:46:58', + 'server': 'ldap.example.com', + 'process': 'slapd[11086]', + 'conn': '6862452', + 'rest': 'fd=34 TLS established tls_ssf=256 ssf=256'} + + connection = Connection(1245) + connection.add_event(event) + assert connection.time == event["time"] + assert connection.server == event["server"] + assert connection.process == event["process"] + assert connection.conn_id == 1245 + assert connection.fd == 34 + assert connection.op == "" + assert connection.verb == "TLS" + assert connection.verb_details == "established tls_ssf=256 ssf=256" + + def test_add_event_bind(self): + event = {'time': 'Oct 26 12:46:58', + 'server': 'ldap.example.com', + 'process': 'slapd[11086]', + 'conn': '6862452', + 'rest': 'op=1 BIND dn="mail=user@example.com,o=com,dc=example" method=128'} + + connection = Connection(1245) + connection.add_event(event) + assert connection.time == event["time"] + assert connection.server == event["server"] + assert connection.process == event["process"] + assert connection.conn_id == 1245 + assert connection.fd == "" + assert connection.op == 1 + assert connection.verb == "BIND" + assert connection.verb_details == 'dn="mail=user@example.com,o=com,dc=example" method=128' + + def test_add_event_result(self): + event = {'time': 'Oct 26 12:46:58', + 'server': 'ldap.example.com', + 'process': 'slapd[11086]', + 'conn': '6862452', + 'rest': 'op=1 RESULT tag=97 err=49 text='} + + connection = Connection(1245) + connection.add_event(event) + assert connection.time == event["time"] + assert connection.server == event["server"] + assert connection.process == event["process"] + assert connection.conn_id == 1245 + assert connection.fd == "" + assert connection.op == 1 + assert connection.verb == "RESULT" + assert connection.verb_details == 'tag=97 err=49 text='