diff --git a/apps/dot_ext/forms.py b/apps/dot_ext/forms.py index 5d07b55ab..3cec99e82 100644 --- a/apps/dot_ext/forms.py +++ b/apps/dot_ext/forms.py @@ -88,6 +88,8 @@ class Meta: required_css_class = "required" def clean(self): + self.cleaned_data['client_type'] = "confidential" + self.cleaned_data['authorization_grant_type'] = "authorization-code" return self.cleaned_data def clean_name(self): @@ -155,8 +157,6 @@ def clean_require_demographic_scopes(self): return require_demographic_scopes def save(self, *args, **kwargs): - self.instance.client_type = "confidential" - self.instance.authorization_grant_type = "authorization-code" app = self.instance # Only log agreement from a Register form if app.agree and type(self) == CustomRegisterApplicationForm: diff --git a/apps/dot_ext/tests/test_form_application.py b/apps/dot_ext/tests/test_form_application.py index 2ff91eda3..28a9b7328 100644 --- a/apps/dot_ext/tests/test_form_application.py +++ b/apps/dot_ext/tests/test_form_application.py @@ -258,6 +258,31 @@ def test_update_form_edit(self): form = CustomRegisterApplicationForm(user, passing_app_fields) self.assertTrue(form.is_valid()) + # Test client_type = 'confidential' and authorization_grant_type = 'authorization-code' regardless of input + data = passing_app_fields + data['client_type'] = 'confidential' + data['authorization_grant_type'] = 'implicit' + form = CustomRegisterApplicationForm(user, data) + self.assertTrue(form.is_valid()) + self.assertEqual(form.cleaned_data.get('client_type'), 'confidential') + self.assertEqual(form.cleaned_data.get('authorization_grant_type'), 'authorization-code') + + data = passing_app_fields + data['client_type'] = 'public' + data['authorization_grant_type'] = 'authorization-code' + form = CustomRegisterApplicationForm(user, data) + self.assertTrue(form.is_valid()) + self.assertEqual(form.cleaned_data.get('client_type'), 'confidential') + self.assertEqual(form.cleaned_data.get('authorization_grant_type'), 'authorization-code') + + data = passing_app_fields + data['client_type'] = 'public' + data['authorization_grant_type'] = 'implicit' + form = CustomRegisterApplicationForm(user, data) + self.assertTrue(form.is_valid()) + self.assertEqual(form.cleaned_data.get('client_type'), 'confidential') + self.assertEqual(form.cleaned_data.get('authorization_grant_type'), 'authorization-code') + def test_create_applications_with_logo(self): """ regression test: BB2-66: Fix-logo-display-in-Published-Applications-API