Add testcase for wrong identifier with identmap

If a client connects with a secondary identifier first,
this one is used as the identifier for the Client-object instead of the
primary one.
This commit is contained in:
Thor77 2017-03-28 21:44:06 +01:00
parent 6e662e2555
commit 683f9b984a
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,7 @@
2017-03-28 01:00:00.000000|INFO |VirtualServer| 1| listening on 0.0.0.0:9987
2017-03-28 03:00:00.000000|INFO |VirtualServerBase| 2| client connected 'Client1'(id:2) from 1.2.3.4:1234
2017-03-28 04:00:00.000000|INFO |VirtualServerBase| 2| client disconnected 'Client1'(id:2) reason 'reasonmsg=ByeBye!'
2017-03-28 01:00:00.000000|INFO |VirtualServerBase| 2| client connected 'Client1'(id:1) from 1.2.3.4:1234
2017-03-28 02:00:00.000000|INFO |VirtualServerBase| 2| client disconnected 'Client1'(id:1) reason 'reasonmsg=ByeBye!'
2017-03-28 05:00:00.000000|INFO |VirtualServerBase| 2| client connected 'Client1'(id:3) from 1.2.3.4:1234
2017-03-28 06:00:00.000000|INFO |VirtualServerBase| 2| client disconnected 'Client1'(id:3) reason 'reasonmsg=ByeBye!'

View File

@ -1,6 +1,7 @@
import pytest
from tsstats.client import Client, Clients
from tsstats.log import _parse_details
from tsstats.utils import transform_pretty_identmap
@ -51,3 +52,17 @@ def test_transform_pretty_identmap(test_input, expected):
transformed_identmap = transform_pretty_identmap(test_input)
for alternate, primary in expected:
assert transformed_identmap[alternate] == primary
def test_ident_map_wrong_identifier():
clients = _parse_details(
'tsstats/tests/res/test.log.identmap_wrong_identifier', ident_map={
'2': '1',
'3': '1'
}
)
client = clients.get('1')
# assert client exists
assert client
# assert correct identifier
assert client.identifier == '1'