mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 12:41:19 -03:30
Merge pull request #1219 from AlanCoding/dragon_vault_id
Prevent unicode errors in cred unique_hash
This commit is contained in:
commit
59c30af19f
@ -9,6 +9,7 @@ import os
|
||||
import re
|
||||
import stat
|
||||
import tempfile
|
||||
import six
|
||||
|
||||
# Jinja2
|
||||
from jinja2 import Template
|
||||
@ -415,9 +416,9 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique, ResourceMixin):
|
||||
type_alias = self.credential_type_id
|
||||
if self.kind == 'vault' and self.inputs.get('vault_id', None):
|
||||
if display:
|
||||
fmt_str = '{} (id={})'
|
||||
fmt_str = six.text_type('{} (id={})')
|
||||
else:
|
||||
fmt_str = '{}_{}'
|
||||
fmt_str = six.text_type('{}_{}')
|
||||
return fmt_str.format(type_alias, self.inputs.get('vault_id'))
|
||||
return str(type_alias)
|
||||
|
||||
|
||||
17
awx/main/tests/unit/models/test_credential.py
Normal file
17
awx/main/tests/unit/models/test_credential.py
Normal file
@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from awx.main.models import Credential, CredentialType
|
||||
|
||||
|
||||
def test_unique_hash_with_unicode():
|
||||
ct = CredentialType(name=u'Väult', kind='vault')
|
||||
cred = Credential(
|
||||
id=4,
|
||||
name=u'Iñtërnâtiônàlizætiøn',
|
||||
credential_type=ct,
|
||||
inputs={
|
||||
u'vault_id': u'🐉🐉🐉'
|
||||
},
|
||||
credential_type_id=42
|
||||
)
|
||||
assert cred.unique_hash(display=True) == u'Väult (id=🐉🐉🐉)'
|
||||
Loading…
x
Reference in New Issue
Block a user