Add test coverage for various action types

This commit is contained in:
Jonathan Claudius 2018-10-26 12:55:32 -04:00
Родитель 113be34933
Коммит b96e47592d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4BCDD990313DFA87
1 изменённых файлов: 109 добавлений и 1 удалений

Просмотреть файл

@ -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='