mirror of
https://github.com/ansible/awx.git
synced 2026-01-10 15:32:07 -03:30
Merge pull request #9336 from mabashian/9310-cred-edit
Fix bug where credential inputs were not filled on edit Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
2a37430eab
@ -116,7 +116,7 @@ function CredentialEdit({ credential, me }) {
|
||||
},
|
||||
] = await Promise.all([
|
||||
CredentialTypesAPI.read({ page_size: 200 }),
|
||||
CredentialsAPI.readInputSources(credId, { page_size: 200 }),
|
||||
CredentialsAPI.readInputSources(credId),
|
||||
]);
|
||||
const credTypes = data.results;
|
||||
if (data.next && data.next.includes('page=2')) {
|
||||
|
||||
@ -197,6 +197,58 @@ CredentialTypesAPI.read.mockResolvedValue({
|
||||
},
|
||||
injectors: {},
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
type: 'credential_type',
|
||||
url: '/api/v2/credential_types/9/',
|
||||
related: {
|
||||
credentials: '/api/v2/credential_types/9/credentials/',
|
||||
activity_stream: '/api/v2/credential_types/9/activity_stream/',
|
||||
},
|
||||
summary_fields: {
|
||||
user_capabilities: {
|
||||
edit: true,
|
||||
delete: true,
|
||||
},
|
||||
},
|
||||
created: '2021-02-12T19:13:22.352791Z',
|
||||
modified: '2021-02-12T19:14:15.578773Z',
|
||||
name: 'Google Compute Engine',
|
||||
description: '',
|
||||
kind: 'cloud',
|
||||
namespace: 'gce',
|
||||
managed_by_tower: true,
|
||||
inputs: {
|
||||
fields: [
|
||||
{
|
||||
id: 'username',
|
||||
label: 'Service Account Email Address',
|
||||
type: 'string',
|
||||
help_text:
|
||||
'The email address assigned to the Google Compute Engine service account.',
|
||||
},
|
||||
{
|
||||
id: 'project',
|
||||
label: 'Project',
|
||||
type: 'string',
|
||||
help_text:
|
||||
'The Project ID is the GCE assigned identification. It is often constructed as three words or two words followed by a three-digit number. Examples: project-id-000 and another-project-id',
|
||||
},
|
||||
{
|
||||
id: 'ssh_key_data',
|
||||
label: 'RSA Private Key',
|
||||
type: 'string',
|
||||
format: 'ssh_private_key',
|
||||
secret: true,
|
||||
multiline: true,
|
||||
help_text:
|
||||
'Paste the contents of the PEM file associated with the service account email.',
|
||||
},
|
||||
],
|
||||
required: ['username', 'ssh_key_data'],
|
||||
},
|
||||
injectors: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
@ -354,6 +406,38 @@ describe('<CredentialEdit />', () => {
|
||||
expect(CredentialInputSourcesAPI.destroy).toHaveBeenCalledWith(34);
|
||||
expect(history.location.pathname).toBe('/credentials/3/details');
|
||||
});
|
||||
test('inputs are properly rendered', async () => {
|
||||
history = createMemoryHistory({ initialEntries: ['/credentials'] });
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
<CredentialEdit
|
||||
credential={{
|
||||
...mockCredential,
|
||||
inputs: {
|
||||
project: 'foo',
|
||||
username: 'foo@ansible.com',
|
||||
ssh_key_data: '$encrypted$',
|
||||
},
|
||||
kind: 'gce',
|
||||
credential_type: 9,
|
||||
}}
|
||||
/>,
|
||||
{
|
||||
context: { router: { history } },
|
||||
}
|
||||
);
|
||||
});
|
||||
wrapper.update();
|
||||
expect(wrapper.find('input#credential-username').prop('value')).toBe(
|
||||
'foo@ansible.com'
|
||||
);
|
||||
expect(wrapper.find('input#credential-project').prop('value')).toBe(
|
||||
'foo'
|
||||
);
|
||||
expect(
|
||||
wrapper.find('textarea#credential-ssh_key_data').prop('value')
|
||||
).toBe('$encrypted$');
|
||||
});
|
||||
});
|
||||
describe('Initial GET request fails', () => {
|
||||
test('shows error when initial GET request fails', async () => {
|
||||
|
||||
@ -197,7 +197,7 @@ function CredentialForm({
|
||||
description: credential.description || '',
|
||||
organization: credential?.summary_fields?.organization || null,
|
||||
credential_type: credential?.credential_type || '',
|
||||
inputs: {},
|
||||
inputs: credential?.inputs || {},
|
||||
passwordPrompts: {},
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user