Skip to content

Commit

Permalink
fix(credential): ds-391 correct rendered fields
Browse files Browse the repository at this point in the history
When choosing auth type username and password, some extra fields
should only be generated to network source type.
Relates to JIRA: DISCOVERY-391
  • Loading branch information
nicolearagao committed Sep 11, 2024
1 parent 9a0211d commit 5c8c8b6
Show file tree
Hide file tree
Showing 3 changed files with 264 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,51 +155,149 @@ exports[`CredentialFormFields should render a basic component: basic 1`] = `
type="password"
/>
</FormGroup>
<React.Fragment>
<FormGroup
fieldId="become_method"
label="Become Method"
>
<SimpleDropdown
dropdownItems={
[
"Select option",
"sudo",
"su",
"pbrun",
"pfexec",
"doas",
"dzdo",
"ksu",
"runas",
]
}
isFullWidth={true}
label="Select option"
onSelect={[Function]}
variant="default"
/>
</FormGroup>
<FormGroup
fieldId="become_user"
label="Become User"
>
<TextInput
id="become_user"
name="become_user"
onChange={[Function]}
placeholder="Enter become user (optional)"
type="text"
/>
</FormGroup>
<FormGroup
fieldId="become_password"
label="Become Password"
>
<TextInput
id="become_password"
name="become_password"
onChange={[Function]}
placeholder="Enter become password (optional)"
type="password"
/>
</FormGroup>
</React.Fragment>
</React.Fragment>
</React.Fragment>
`;

exports[`CredentialFormFields should render ansible form appropriately: ansible, "Username and Password" 1`] = `
<React.Fragment>
<FormGroup
fieldId="name"
isRequired={true}
label="Name"
>
<TextInput
id="credential-name"
isRequired={true}
name="name"
onChange={[Function]}
placeholder="Enter a name for the credential"
type="text"
/>
</FormGroup>
<React.Fragment>
<FormGroup
fieldId="become_method"
label="Become Method"
fieldId="username"
isRequired={true}
label="Username"
>
<SimpleDropdown
dropdownItems={
[
"Select option",
"sudo",
"su",
"pbrun",
"pfexec",
"doas",
"dzdo",
"ksu",
"runas",
]
}
isFullWidth={true}
label="Select option"
onSelect={[Function]}
variant="default"
<TextInput
id="credential-username"
isRequired={true}
name="username"
onChange={[Function]}
placeholder="Enter username"
/>
</FormGroup>
<FormGroup
fieldId="become_user"
label="Become User"
fieldId="password"
isRequired={true}
label="Password"
>
<TextInput
id="become_user"
name="become_user"
id="credential-password"
isRequired={true}
name="password"
onChange={[Function]}
placeholder="Enter become user (optional)"
type="text"
placeholder="Enter password"
type="password"
/>
</FormGroup>
</React.Fragment>
</React.Fragment>
`;

exports[`CredentialFormFields should render satellite form appropriately: satellite, "Username and Password" 1`] = `
<React.Fragment>
<FormGroup
fieldId="name"
isRequired={true}
label="Name"
>
<TextInput
id="credential-name"
isRequired={true}
name="name"
onChange={[Function]}
placeholder="Enter a name for the credential"
type="text"
/>
</FormGroup>
<React.Fragment>
<FormGroup
fieldId="become_password"
label="Become Password"
fieldId="username"
isRequired={true}
label="Username"
>
<TextInput
id="become_password"
name="become_password"
id="credential-username"
isRequired={true}
name="username"
onChange={[Function]}
placeholder="Enter become password (optional)"
placeholder="Enter username"
/>
</FormGroup>
<FormGroup
fieldId="password"
isRequired={true}
label="Password"
>
<TextInput
id="credential-password"
isRequired={true}
name="password"
onChange={[Function]}
placeholder="Enter password"
type="password"
/>
</FormGroup>
Expand Down Expand Up @@ -345,54 +443,56 @@ exports[`CredentialFormFields should render specific to authType for type networ
type="password"
/>
</FormGroup>
<FormGroup
fieldId="become_method"
label="Become Method"
>
<SimpleDropdown
dropdownItems={
[
"Select option",
"sudo",
"su",
"pbrun",
"pfexec",
"doas",
"dzdo",
"ksu",
"runas",
]
}
isFullWidth={true}
label="Select option"
onSelect={[Function]}
variant="default"
/>
</FormGroup>
<FormGroup
fieldId="become_user"
label="Become User"
>
<TextInput
id="become_user"
name="become_user"
onChange={[Function]}
placeholder="Enter become user (optional)"
type="text"
/>
</FormGroup>
<FormGroup
fieldId="become_password"
label="Become Password"
>
<TextInput
id="become_password"
name="become_password"
onChange={[Function]}
placeholder="Enter become password (optional)"
type="password"
/>
</FormGroup>
<React.Fragment>
<FormGroup
fieldId="become_method"
label="Become Method"
>
<SimpleDropdown
dropdownItems={
[
"Select option",
"sudo",
"su",
"pbrun",
"pfexec",
"doas",
"dzdo",
"ksu",
"runas",
]
}
isFullWidth={true}
label="Select option"
onSelect={[Function]}
variant="default"
/>
</FormGroup>
<FormGroup
fieldId="become_user"
label="Become User"
>
<TextInput
id="become_user"
name="become_user"
onChange={[Function]}
placeholder="Enter become user (optional)"
type="text"
/>
</FormGroup>
<FormGroup
fieldId="become_password"
label="Become Password"
>
<TextInput
id="become_password"
name="become_password"
onChange={[Function]}
placeholder="Enter become password (optional)"
type="password"
/>
</FormGroup>
</React.Fragment>
</React.Fragment>
</React.Fragment>
`;
Expand Down Expand Up @@ -508,51 +608,51 @@ exports[`CredentialFormFields should render specific to authType for type opensh
type="password"
/>
</FormGroup>
</React.Fragment>
</React.Fragment>
`;

exports[`CredentialFormFields should render vcenter form appropriately: vcenter, "Username and Password" 1`] = `
<React.Fragment>
<FormGroup
fieldId="name"
isRequired={true}
label="Name"
>
<TextInput
id="credential-name"
isRequired={true}
name="name"
onChange={[Function]}
placeholder="Enter a name for the credential"
type="text"
/>
</FormGroup>
<React.Fragment>
<FormGroup
fieldId="become_method"
label="Become Method"
>
<SimpleDropdown
dropdownItems={
[
"Select option",
"sudo",
"su",
"pbrun",
"pfexec",
"doas",
"dzdo",
"ksu",
"runas",
]
}
isFullWidth={true}
label="Select option"
onSelect={[Function]}
variant="default"
/>
</FormGroup>
<FormGroup
fieldId="become_user"
label="Become User"
fieldId="username"
isRequired={true}
label="Username"
>
<TextInput
id="become_user"
name="become_user"
id="credential-username"
isRequired={true}
name="username"
onChange={[Function]}
placeholder="Enter become user (optional)"
type="text"
placeholder="Enter username"
/>
</FormGroup>
<FormGroup
fieldId="become_password"
label="Become Password"
fieldId="password"
isRequired={true}
label="Password"
>
<TextInput
id="become_password"
name="become_password"
id="credential-password"
isRequired={true}
name="password"
onChange={[Function]}
placeholder="Enter become password (optional)"
placeholder="Enter password"
type="password"
/>
</FormGroup>
Expand Down
15 changes: 15 additions & 0 deletions src/views/credentials/__tests__/addCredentialModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ describe('CredentialFormFields', () => {
expect(openshiftToken).toMatchSnapshot('openshift, "Token"');
});

it('should render vcenter form appropriately', async () => {
const vcenter = await shallowComponent(<CredentialFormFields typeValue="vcenter" />);
expect(vcenter).toMatchSnapshot('vcenter, "Username and Password"');
});

it('should render satellite form appropriately', async () => {
const satellite = await shallowComponent(<CredentialFormFields typeValue="satellite" />);
expect(satellite).toMatchSnapshot('satellite, "Username and Password"');
});

it('should render ansible form appropriately', async () => {
const ansible = await shallowComponent(<CredentialFormFields typeValue="ansible" />);
expect(ansible).toMatchSnapshot('ansible, "Username and Password"');
});

it('should call handlers for setAuthType and handleInputChange', async () => {
const mockHandleInputChange = jest.fn();
const mockSetAuthType = jest.fn();
Expand Down
Loading

0 comments on commit 5c8c8b6

Please sign in to comment.