예제 #1
0
 def test_effectively_equal_different_time(self):
     good_entry = RadiusLogEntry(
         '00:de:ad:be:ef:00',
         'Access-Accept',
         ['traffic'],
         [['Egress-VLAN-Name', '"2hades-unauth"']],
         self.timestamp - 50,
     )
     self.assert_effective_equality_to_sample(good_entry)
예제 #2
0
 def test_not_effectively_equal_different_group_same_time(self):
     bad_entry = RadiusLogEntry(
         '00:de:ad:be:ef:00',
         'Access-Accept',
         ['violation'],
         [['Egress-VLAN-Name', '"2hades-unauth"']],
         self.timestamp,
     )
     self.assert_effective_equality_to_sample(bad_entry, equal=False)
예제 #3
0
 def assert_acceptance_from_reply(self, reply, should_accept=False):
     entry = RadiusLogEntry(mac=None, reply=reply, groups=None,
                            raw_attributes=None, timestamp=None)
     if should_accept:
         self.assertTrue(entry.accepted)
         self.assertTrue(entry)
     else:
         self.assertFalse(entry.accepted)
         self.assertFalse(entry)
예제 #4
0
 def setUp(self):
     super().setUp()
     self.timestamp = 1501623826.391414
     self.raw_entry = [
         '00:de:ad:be:ef:00',
         'Access-Accept',
         ['traffic'],
         [['Egress-VLAN-Name', '"2hades-unauth"']],
         self.timestamp,
     ]
     self.entry = RadiusLogEntry(*self.raw_entry)
예제 #5
0
 def test_radius_logs_work_as_well(self):
     timestamp = 1501623826.391414
     entries = [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),
     ]]
     reduced = list(self.func(entries, comparator=RadiusLogEntry.effectively_equal))
     self.assertEqual(len(reduced), 2)
     self.assertEqual(reduced[0], entries[0])
     self.assertEqual(reduced[-1], entries[-1])
예제 #6
0
 def assert_effective_equality_to_sample(self, other, equal=True):
     """Assert effective Equality of ``other`` to ``self.entry``"""
     do_assert = self.assertTrue if equal else self.assertFalse
     do_assert(RadiusLogEntry.effectively_equal(self.entry, other))
예제 #7
0
 def test_invalid_vlan_name_raises(self):
     invalid_entry = self.raw_entry.copy()
     invalid_entry[3][0][1] = '3Invalid'
     entry = RadiusLogEntry(*invalid_entry)
     with self.assertRaises(ParsingError):
         entry.vlans  # pylint: disable=pointless-statement