Skip to content

Commit

Permalink
[change] Close all previous open RADIUS session #437
Browse files Browse the repository at this point in the history
Whenever a new session is started, all previous open session
from the same user and calling-station-id is closed.

In the previous implementation, only sessions with the same
called-station-id were closed.

Related to #437
  • Loading branch information
pandafy committed Oct 11, 2023
1 parent 690a0c2 commit 88bc9d8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
1 change: 0 additions & 1 deletion openwisp_radius/receivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def close_previous_radius_accounting_sessions(instance, created, **kwargs):
unique_id=instance.unique_id
).filter(
stop_time__isnull=True,
called_station_id=instance.called_station_id,
calling_station_id=instance.calling_station_id,
username=instance.username,
)
Expand Down
13 changes: 0 additions & 13 deletions openwisp_radius/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,6 @@ def test_multiple_accounting_sessions(self):
self.assertEqual(radiusaccounting1.stop_time, radiusaccounting1.update_time)
self.assertEqual(radiusaccounting2.stop_time, None)

with self.subTest('Test different called_session_id'):
self.assertEqual(
RadiusAccounting.objects.filter(stop_time__isnull=True).count(), 1
)
radiusaccounting_options['called_station_id'] = 'AA-AA-AA-AA-AA-0B'
self._create_radius_accounting(
unique_id='113', **radiusaccounting_options, update_time=timezone.now()
)
radiusaccounting2.refresh_from_db()
self.assertEqual(RadiusAccounting.objects.filter(stop_time=None).count(), 2)
self.assertEqual(radiusaccounting2.terminate_cause, None)
self.assertEqual(radiusaccounting2.stop_time, None)

@capture_any_output()
@mock.patch.object(app_settings, 'OPENVPN_DATETIME_FORMAT', u'%Y-%m-%d %H:%M:%S')
@mock.patch.object(app_settings, 'CONVERT_CALLED_STATION_ON_CREATE', True)
Expand Down

0 comments on commit 88bc9d8

Please sign in to comment.