예제 #1
0
 def test_effectively_equal_different_time(self, entry, timestamp):
     good_entry = RadiusLogEntry(
         '00:de:ad:be:ef:00',
         'Access-Accept',
         ['traffic'],
         [['Egress-VLAN-Name', '"2hades-unauth"']],
         timestamp - 50,
     )
     assert RadiusLogEntry.effectively_equal(entry, good_entry)
예제 #2
0
 def test_not_effectively_equal_different_group(self, entry, timestamp):
     bad_entry = RadiusLogEntry(
         '00:de:ad:be:ef:00',
         'Access-Accept',
         ['violation'],
         [['Egress-VLAN-Name', '"2hades-unauth"']],
         timestamp - 50,
     )
     assert not RadiusLogEntry.effectively_equal(entry, bad_entry)
예제 #3
0
 def entry(self, timestamp):
     return RadiusLogEntry(
         '00:de:ad:be:ef:00',
         'Access-Accept',
         ['traffic'],
         [['Egress-VLAN-Name', '"2hades-unauth"']],
         timestamp,
     )
예제 #4
0
def assert_acceptance_from_reply(reply, should_accept=False):
    entry = RadiusLogEntry(mac=None,
                           reply=reply,
                           groups=None,
                           raw_attributes=None,
                           timestamp=None)
    if should_accept:
        assert entry.accepted
        assert entry
    else:
        assert not entry.accepted
        assert not entry
예제 #5
0
 def entries(self):
     timestamp = 1501623826.391414
     return [
         RadiusLogEntry(*e) for e in [
             ('00:de:ad:be:ef:00', 'Access-Accept', ['traffic'],
              [['Egress-VLAN-Name', '"2hades-unauth"']], timestamp),
             ('00:de:ad:be:ef:00', 'Access-Accept', ['traffic'],
              [['Egress-VLAN-Name', '"2hades-unauth"']], timestamp - 50),
             ('00:de:ad:be:ef:00', 'Access-Accept', ['violation'],
              [['Egress-VLAN-Name', '"2hades-unauth"']], timestamp - 100),
         ]
     ]
예제 #6
0
 def test_reflexivity(self, entry):
     assert RadiusLogEntry.effectively_equal(entry, entry)
예제 #7
0
 def test_comparison_to_incomplete_type_gives_false(self, entry):
     assert not RadiusLogEntry.effectively_equal(entry, object())
예제 #8
0
def invalid_entry(raw_entry):
    invalid_entry = raw_entry.copy()
    invalid_entry[3][0][1] = '3Invalid'
    return RadiusLogEntry(*invalid_entry)
예제 #9
0
def entry(raw_entry):
    return RadiusLogEntry(*raw_entry)