Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Fixed FreeRADIUS PostAuthView returning 500 error #513

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion openwisp_radius/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ class RadiusPostAuthSerializer(serializers.ModelSerializer):
allow_blank=True,
style={'input_type': 'password'},
)
called_station_id = serializers.CharField(required=False, allow_blank=True)
called_station_id = serializers.CharField(
required=False, allow_blank=True, max_length=50
)
calling_station_id = serializers.CharField(required=False, allow_blank=True)

def validate(self, data):
Expand Down
10 changes: 10 additions & 0 deletions openwisp_radius/tests/test_api/test_freeradius_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,16 @@ def test_postauth_400(self):
self.assertEqual(RadiusPostAuth.objects.all().count(), 0)
self.assertEqual(response.status_code, 400)

def test_postauth_called_station_id_validation(self):
payload = {
'called_station_id': 'C0-4A-00-EE-D1-0D:' + 'B' * 46
} # taking a >50 char value of called_station_id
response = self.client.post(
reverse('radius:postauth'), payload, HTTP_AUTHORIZATION=self.auth_header
)
self.assertEqual(RadiusPostAuth.objects.all().count(), 0)
self.assertEqual(response.status_code, 400)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you double checked that this test fails if the fix is removed?


@capture_any_output()
def test_postauth_no_token_403(self):
response = self.client.post(reverse('radius:postauth'), {'username': 'tester'})
Expand Down
Loading