diff --git a/src/authentic2/attribute_kinds.py b/src/authentic2/attribute_kinds.py index b3ac4f7e4..27ae00b40 100644 --- a/src/authentic2/attribute_kinds.py +++ b/src/authentic2/attribute_kinds.py @@ -118,6 +118,7 @@ DEFAULT_ATTRIBUTE_KINDS = [ 'field_class': forms.BooleanField, 'serialize': lambda x: str(int(bool(x))), 'deserialize': lambda x: bool(int(x)), + 'rest_framework_field_class': serializers.NullBooleanField, }, { 'label': _('date'), diff --git a/tests/test_api.py b/tests/test_api.py index b01639b82..240b0382f 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -141,6 +141,16 @@ def test_api_users_list(app, user): assert resp.json['next'] is None +def test_api_users_boolean_attribute(app, superuser): + from authentic2.models import Attribute, AttributeValue + at = Attribute.objects.create( + kind='boolean', name='boolean', label='boolean', required=True) + superuser.attributes.boolean = True + app.authorization = ('Basic', (superuser.username, superuser.username)) + resp = app.get('/api/users/%s/' % superuser.uuid) + assert resp.json['boolean'] is True + + def test_api_users_list_by_authorized_service(app, superuser): from authentic2.models import Service