Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Fix save vCenter credentials functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
pcbailey committed Jun 7, 2019
1 parent 9db34ed commit eee5ed9
Show file tree
Hide file tree
Showing 14 changed files with 3,093 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import {
PROVIDER_VMWARE_REMEMBER_PASSWORD_KEY,
PROVIDER_VMWARE_VCENTER_KEY,
PROVIDER_VMWARE_VM_KEY,
PROVIDER_VMWARE_NEW_VCENTER_NAME_KEY,
PROVIDER_VMWARE_CHECK_CONNECTION_BTN_TEXT_KEY,
PROVIDER_VMWARE_CHECK_CONNECTION_BTN_SAVE,
} from '../../providers/VMwareImportProvider/constants';
import { getSimpleV2vVMwareStatus } from '../../../../../utils/status/v2vVMware/v2vVMwareStatus';

Expand All @@ -29,7 +32,7 @@ export const getVmWareInitialState = props => ({
[PROVIDER_VMWARE_CHECK_CONNECTION_KEY]: {
isDisabled: asDisabled(true, PROVIDER_VMWARE_VCENTER_KEY),
},
[PROVIDER_VMWARE_REMEMBER_PASSWORD_KEY]: {},
[PROVIDER_VMWARE_REMEMBER_PASSWORD_KEY]: { value: true },
[PROVIDER_VMWARE_VM_KEY]: {
isDisabled: asDisabled(true, PROVIDER_VMWARE_VM_KEY),
},
Expand All @@ -40,14 +43,16 @@ export const getVmWareInitialState = props => ({

// simple values
[PROVIDER_VMWARE_V2V_NAME_KEY]: null,
[PROVIDER_VMWARE_NEW_VCENTER_NAME_KEY]: null,
[PROVIDER_VMWARE_CHECK_CONNECTION_BTN_TEXT_KEY]: PROVIDER_VMWARE_CHECK_CONNECTION_BTN_SAVE,
});

const titleResolver = {
[PROVIDER_VMWARE_VCENTER_KEY]: 'vCenter Instance',
[PROVIDER_VMWARE_HOSTNAME_KEY]: 'vCenter Hostname',
[PROVIDER_VMWARE_USER_NAME_KEY]: 'vCenter User Name',
[PROVIDER_VMWARE_USER_PASSWORD_KEY]: 'vCenter Password',
[PROVIDER_VMWARE_REMEMBER_PASSWORD_KEY]: 'Remember vCenter credentials',
[PROVIDER_VMWARE_REMEMBER_PASSWORD_KEY]: 'Save as New vCenter Instance',
[PROVIDER_VMWARE_VM_KEY]: 'VM to Import',
};

Expand Down Expand Up @@ -75,7 +80,7 @@ const helpResolver = {
[PROVIDER_VMWARE_USER_NAME_KEY]: () => 'User name to be used for connection to a vCenter instance.',
[PROVIDER_VMWARE_USER_PASSWORD_KEY]: () => 'User password to be used for connection to a vCenter instance.',
[PROVIDER_VMWARE_REMEMBER_PASSWORD_KEY]: () =>
'If checked, new secret keeping connection details will be created for later use.',
'If checked, a new secret containing the connection details will be created for future use.',
[PROVIDER_VMWARE_VM_KEY]: () =>
'Select a vCenter virtual machine to import. Loading of their list might take some time. The list will be enabled for selection once data are loaded.',
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { FormRow } from '../../../../Form/FormRow';
import { CONNECT_TO_NEW_INSTANCE } from '../../strings';
import {
PROVIDER_VMWARE,
PROVIDER_VMWARE_CHECK_CONNECTION_BTN_TEXT_KEY,
PROVIDER_VMWARE_CHECK_CONNECTION_KEY,
PROVIDER_VMWARE_HOSTNAME_KEY,
PROVIDER_VMWARE_REMEMBER_PASSWORD_KEY,
Expand Down Expand Up @@ -180,7 +181,7 @@ export class VMWareImportProvider extends React.Component {
disabled={isFieldDisabled(this.getField(PROVIDER_VMWARE_CHECK_CONNECTION_KEY))}
onClick={() => this.onChange(PROVIDER_VMWARE_CHECK_CONNECTION_KEY, true)}
>
Check
{this.getField(PROVIDER_VMWARE_CHECK_CONNECTION_BTN_TEXT_KEY)}
</Button>
</FormRow>
<FormRow isHidden={isFieldHidden(this.getField(PROVIDER_VMWARE_STATUS_KEY))}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ export const PROVIDER_VMWARE_USER_PASSWORD_KEY = 'vmwarePassword';
export const PROVIDER_VMWARE_REMEMBER_PASSWORD_KEY = 'rememberVMwareCredentials';

export const PROVIDER_VMWARE_CHECK_CONNECTION_KEY = 'checkConnectionButton';
export const PROVIDER_VMWARE_CHECK_CONNECTION_BTN_TEXT_KEY = 'checkConnectionButtonText';
export const PROVIDER_VMWARE_CHECK_CONNECTION_BTN_SAVE = 'Check and Save';
export const PROVIDER_VMWARE_CHECK_CONNECTION_BTN_DONT_SAVE = 'Check';
export const PROVIDER_VMWARE_STATUS_KEY = 'vmwareStatus';

export const PROVIDER_VMWARE_VM_KEY = 'vmwareVm';

export const PROVIDER_VMWARE_V2V_NAME_KEY = 'v2vVmwareName';
export const PROVIDER_VMWARE_NEW_VCENTER_NAME_KEY = 'newVCenterName';
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
// TODO: add
import { PROVIDERS_DATA_KEY } from '../../../constants';
import { PROVIDER_VMWARE, PROVIDER_VMWARE_REMEMBER_PASSWORD_KEY, PROVIDER_VMWARE_STATUS_KEY } from '../constants';
import { V2V_WMWARE_STATUS_CONNECTION_SUCCESSFUL } from '../../../../../../utils/status/v2vVMware';
import { VMWareImportProvider } from '../VMWareImportProvider';

export const vmSettingsConnectionSuccessful = {
[PROVIDERS_DATA_KEY]: {
[PROVIDER_VMWARE]: {
[PROVIDER_VMWARE_STATUS_KEY]: {
value: V2V_WMWARE_STATUS_CONNECTION_SUCCESSFUL,
},
},
},
};

export const vmSettingsDontSaveCredentials = {
[PROVIDERS_DATA_KEY]: {
[PROVIDER_VMWARE]: {
[PROVIDER_VMWARE_STATUS_KEY]: {
value: V2V_WMWARE_STATUS_CONNECTION_SUCCESSFUL,
},
[PROVIDER_VMWARE_REMEMBER_PASSWORD_KEY]: {
value: false,
},
},
},
};

export default {
component: VMWareImportProvider,
props: {
vmSettings: vmSettingsConnectionSuccessful,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import React from 'react';
import { mount } from 'enzyme';

import { VMWareImportProvider } from '../VMWareImportProvider';
import {
vmSettingsConnectionSuccessful,
vmSettingsDontSaveCredentials,
} from '../fixtures/VMWareImportProvider.fixture';

const testVMWareImportProvider = () => <VMWareImportProvider />;

Expand All @@ -11,4 +15,14 @@ describe('<VMWareImportProvider />', () => {
const component = mount(testVMWareImportProvider());
expect(component).toMatchSnapshot();
});

it('renders correctly when connection is successful', () => {
const component = mount(<VMWareImportProvider vmSettings={vmSettingsConnectionSuccessful} />);
expect(component).toMatchSnapshot();
});

it('renders correctly when password is not saved', () => {
const component = mount(<VMWareImportProvider vmSettings={vmSettingsDontSaveCredentials} />);
expect(component).toMatchSnapshot();
});
});
Loading

0 comments on commit eee5ed9

Please sign in to comment.