idp_oidc: add slug edition field in edit form (#76223)
gitea/authentic/pipeline/head This commit looks good
Details
gitea/authentic/pipeline/head This commit looks good
Details
This commit is contained in:
parent
7c4462af0e
commit
37f389d20f
|
@ -33,6 +33,7 @@ class OIDCClientForm(SlugMixin, forms.ModelForm):
|
|||
model = OIDCClient
|
||||
fields = [
|
||||
'name',
|
||||
'slug',
|
||||
'redirect_uris',
|
||||
'post_logout_redirect_uris',
|
||||
'sector_identifier_uri',
|
||||
|
@ -97,6 +98,11 @@ class OIDCClientForm(SlugMixin, forms.ModelForm):
|
|||
return super().clean()
|
||||
|
||||
|
||||
class OIDCClientAddForm(OIDCClientForm):
|
||||
class Meta:
|
||||
exclude = ['slug']
|
||||
|
||||
|
||||
class OIDCClaimForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = OIDCClaim
|
||||
|
|
|
@ -25,7 +25,7 @@ from . import forms
|
|||
|
||||
|
||||
class OIDCServiceAddView(views.ActionMixin, views.BaseAddView):
|
||||
form_class = forms.OIDCClientForm
|
||||
form_class = forms.OIDCClientAddForm
|
||||
model = OIDCClient
|
||||
title = _('Add OIDC service')
|
||||
permissions = ['authentic2.add_service']
|
||||
|
|
|
@ -195,6 +195,25 @@ http://example2.com'''
|
|||
== resp.pyquery('.messages .warning').text()
|
||||
)
|
||||
|
||||
resp = app.get(f'/manage/services/{oidc_client.id}/settings/edit/')
|
||||
form = resp.form
|
||||
form['slug'] = 'anewslug'
|
||||
resp = form.submit().follow()
|
||||
assert not resp.pyquery('.errornotice p')
|
||||
assert not resp.pyquery('.error p')
|
||||
oidc_client.refresh_from_db()
|
||||
assert oidc_client.slug == 'anewslug'
|
||||
|
||||
resp = app.get(f'/manage/services/{oidc_client.id}/settings/edit/')
|
||||
form = resp.form
|
||||
form['slug'] = 'anew Invalid! slug'
|
||||
resp = form.submit()
|
||||
assert 'errors processing your form' in resp.pyquery('.errornotice p')[0].text
|
||||
assert (
|
||||
'Enter a valid “slug” consisting of letters, numbers, underscores or hyphens.'
|
||||
in resp.pyquery('.error p')[0].text
|
||||
)
|
||||
|
||||
def test_delete(self, app):
|
||||
resp = app.get('/manage/services/')
|
||||
resp = resp.click('Test')
|
||||
|
|
Loading…
Reference in New Issue