mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 04:31:21 -03:30
require that insights projects have insights cred
This commit is contained in:
parent
25632c03a4
commit
376170124e
@ -140,7 +140,9 @@ class ProjectOptions(models.Model):
|
||||
if not self.scm_type:
|
||||
return None
|
||||
cred = self.credential
|
||||
if cred:
|
||||
if not cred and self.scm_type == 'insights':
|
||||
raise ValidationError(_("Insights Credential is required for an Insights Project."))
|
||||
elif cred:
|
||||
if self.scm_type == 'insights':
|
||||
if cred.kind != 'insights':
|
||||
raise ValidationError(_("Credential kind must be 'insights'."))
|
||||
|
||||
15
awx/main/tests/unit/models/test_project.py
Normal file
15
awx/main/tests/unit/models/test_project.py
Normal file
@ -0,0 +1,15 @@
|
||||
import pytest
|
||||
import json
|
||||
from awx.main.models import (
|
||||
Project,
|
||||
)
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
|
||||
def test_clean_credential_insights():
|
||||
proj = Project(name="myproj", credential=None, scm_type='insights')
|
||||
with pytest.raises(ValidationError) as e:
|
||||
proj.clean_credential()
|
||||
|
||||
assert json.dumps(str(e.value)) == json.dumps(str([u'Insights Credential is required for an Insights Project.']))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user