Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1041 from mturley/1038-remove-rsa-warning
Browse files Browse the repository at this point in the history
[#1038] [BZ#1755897] Remove warnings related to RSA auth and clean up unused code
  • Loading branch information
mzazrivec committed Oct 2, 2019
2 parents 40746f1 + e10087a commit c5c5e43
Show file tree
Hide file tree
Showing 25 changed files with 68 additions and 453 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { Field, reduxForm } from 'redux-form';
import { length } from 'redux-form-validators';

import ClustersStepForm from './components/ClustersStepForm/ClustersStepForm';
import { QUERY_PROVIDERS_URL } from './MappingWizardClustersStepConstants';
import { FETCH_TARGET_COMPUTE_URLS } from '../../../../../../../../redux/common/targetResources/targetResourcesConstants';
import { getProviderIds } from './helpers';
import { OPENSTACK } from '../../MappingWizardConstants';

class MappingWizardClustersStep extends React.Component {
Expand All @@ -32,18 +30,11 @@ class MappingWizardClustersStep extends React.Component {
fetchSourceClustersAction,
fetchTargetComputeUrls,
fetchTargetClustersAction,
targetProvider,
queryProvidersAction,
queryProvidersUrl
targetProvider
} = this.props;

fetchSourceClustersAction(fetchSourceClustersUrl);
fetchTargetClustersAction(fetchTargetComputeUrls[targetProvider]).then(result => {
const safeToProceed = result.value && result.value.data && result.value.data.resources.length > 0;
if (targetProvider === OPENSTACK && safeToProceed) {
queryProvidersAction(queryProvidersUrl, getProviderIds(result.value.data.resources));
}
});
fetchTargetClustersAction(fetchTargetComputeUrls[targetProvider]);
};

render() {
Expand All @@ -55,10 +46,7 @@ class MappingWizardClustersStep extends React.Component {
isRejectedSourceClusters,
isRejectedTargetClusters,
targetProvider,
rhvConversionHosts,
ospConversionHosts,
providers,
isQueryingProviders
rhvConversionHosts
} = this.props;

if (isRejectedSourceClusters || isRejectedTargetClusters) {
Expand Down Expand Up @@ -88,9 +76,6 @@ class MappingWizardClustersStep extends React.Component {
isFetchingTargetClusters={isFetchingTargetClusters}
targetProvider={targetProvider}
rhvConversionHosts={rhvConversionHosts}
ospConversionHosts={ospConversionHosts}
providers={providers}
isQueryingProviders={isQueryingProviders}
/>
);
}
Expand All @@ -111,11 +96,7 @@ MappingWizardClustersStep.propTypes = {
isRejectedTargetClusters: PropTypes.bool,
targetProvider: PropTypes.string,
rhvConversionHosts: PropTypes.array,
ospConversionHosts: PropTypes.array,
providers: PropTypes.array,
isQueryingProviders: PropTypes.bool,
queryProvidersAction: PropTypes.func,
queryProvidersUrl: PropTypes.string
ospConversionHosts: PropTypes.array
};
MappingWizardClustersStep.defaultProps = {
fetchSourceClustersAction: noop,
Expand All @@ -131,8 +112,7 @@ MappingWizardClustersStep.defaultProps = {
'/api/clusters?expand=resources' +
'&attributes=ext_management_system.emstype,v_parent_datacenter,ext_management_system.name' +
'&filter[]=ext_management_system.emstype=vmwarews',
fetchTargetComputeUrls: FETCH_TARGET_COMPUTE_URLS,
queryProvidersUrl: QUERY_PROVIDERS_URL
fetchTargetComputeUrls: FETCH_TARGET_COMPUTE_URLS
};

export default reduxForm({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import URI from 'urijs';
import API from '../../../../../../../../common/API';
import { FETCH_V2V_SOURCE_CLUSTERS, QUERY_V2V_PROVIDERS } from './MappingWizardClustersStepConstants';
import { FETCH_V2V_SOURCE_CLUSTERS } from './MappingWizardClustersStepConstants';

export { showAlertAction, hideAlertAction } from '../../MappingWizardActions';

Expand All @@ -14,22 +14,3 @@ export const fetchSourceClustersAction = url => {
const uri = new URI(url);
return _getSourceClustersActionCreator(uri.toString());
};

// ****************************************************************************
// QUERY_V2V_PROVIDERS
// ****************************************************************************
const _queryProvidersActionCreator = (url, providerIds) => dispatch =>
dispatch({
type: QUERY_V2V_PROVIDERS,
payload: API.post(url, {
action: 'query',
resources: providerIds.map(id => ({ id }))
})
});

export const queryProvidersAction = (url, providerIds) => {
const uri = new URI(url);
uri.addSearch({ attributes: 'authentications' });

return _queryProvidersActionCreator(uri.toString(), providerIds);
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { OPENSTACK, RHV } from '../../MappingWizardConstants';
import { RHV } from '../../MappingWizardConstants';

export const FETCH_V2V_SOURCE_CLUSTERS = 'FETCH_V2V_SOURCE_CLUSTERS';
export const FETCH_V2V_TARGET_CLUSTERS = 'FETCH_V2V_TARGET_CLUSTERS';
export const QUERY_V2V_PROVIDERS = 'QUERY_V2V_PROVIDERS';

export const QUERY_PROVIDERS_URL = '/api/providers';

export const TARGET_WARNING_MESSAGES = {
[RHV]: __('You must enable at least one conversion host in the cluster. You can continue to create an infrastructure mapping that includes the target cluster, but you must enable a conversion host before running the migration plan.'), // prettier-ignore
[OPENSTACK]: __('You must enable an RSA key pair on the OpenStack provider. You can continue to create an infrastructure mapping without the key pair, but you must enable it before running the migration plan.') // prettier-ignore
export const CONVERSION_HOST_WARNING_MESSAGES = {
[RHV]: __('You must enable at least one conversion host in the cluster. You can continue to create an infrastructure mapping that includes the target cluster, but you must enable a conversion host before running the migration plan.') // prettier-ignore
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Immutable from 'seamless-immutable';

import { FETCH_V2V_SOURCE_CLUSTERS, QUERY_V2V_PROVIDERS } from './MappingWizardClustersStepConstants';
import { FETCH_V2V_SOURCE_CLUSTERS } from './MappingWizardClustersStepConstants';
import { V2V_MAPPING_WIZARD_EXITED } from '../../../../screens/MappingWizard/MappingWizardConstants';

export const initialState = Immutable({
Expand All @@ -11,11 +11,7 @@ export const initialState = Immutable({
targetClusters: [],
isFetchingTargetClusters: false,
isRejectedTargetClusters: false,
errorTargetClusters: null,
providers: [],
isQueryingProviders: false,
isRejectedQueryProviders: false,
errorQueryProviders: null
errorTargetClusters: null
});

export default (state = initialState, action) => {
Expand All @@ -39,19 +35,6 @@ export default (state = initialState, action) => {
.set('isRejectedSourceClusters', true)
.set('isFetchingSourceClusters', false);

case `${QUERY_V2V_PROVIDERS}_PENDING`:
return state.set('isQueryingProviders', true).set('isRejectedQueryProviders', false);
case `${QUERY_V2V_PROVIDERS}_FULFILLED`:
return state
.set('providers', action.payload.data.results)
.set('isQueryingProviders', false)
.set('isRejectedQueryProviders', false)
.set('errorQueryProviders', null);
case `${QUERY_V2V_PROVIDERS}_REJECTED`:
return state
.set('errorQueryProviders', action.payload)
.set('isRejectedQueryProviders', true)
.set('isQueryingProviders', false);
case V2V_MAPPING_WIZARD_EXITED:
return initialState;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,3 @@ describe('mappingWizard actions', () => {
});
});
});

describe('queryProvidersAction', () => {
const url = '/api';
const providerIds = ['1'];
test('dispatches PENDING and FULFILLED actions', () => {
mockRequest({
method: 'POST',
url,
status: 200,
response: [{ mock: 'data' }]
});

return store.dispatch(actions.queryProvidersAction(url, providerIds)).then(() => {
expect(store.getActions()).toMatchSnapshot();
});
});

test('dispatches PENDING and REJECTED actions', () => {
mockRequest({
method: 'POST',
url,
status: 404,
response: { error: 'error' }
});

return store.dispatch(actions.queryProvidersAction(url, providerIds)).catch(() => {
expect(store.getActions()).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ describe('target provider is OSP', () => {
hideAlertAction: jest.fn(),
showAlertAction: jest.fn(),
sourceClusters: [],
targetProvider: OPENSTACK,
queryProvidersAction: jest.fn()
targetProvider: OPENSTACK
});

test('cloud tenants are fetched and a conversion host alert is triggered', () => {
Expand Down Expand Up @@ -56,20 +55,4 @@ describe('target provider is OSP', () => {

wrapper.unmount();
});

test('providers are queried', async () => {
const baseProps = getBaseProps();
const wrapper = mount(
<Provider store={store}>
<MappingWizardClustersStep {...baseProps} />
</Provider>
);

await expect(baseProps.fetchTargetClustersAction).toHaveBeenCalledWith(
FETCH_TARGET_COMPUTE_URLS[baseProps.targetProvider]
);
expect(baseProps.queryProvidersAction).toHaveBeenCalled();

wrapper.unmount();
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Immutable from 'seamless-immutable';
import clustersReducer, { initialState } from '../MappingWizardClustersStepReducer';
import { FETCH_V2V_SOURCE_CLUSTERS, QUERY_V2V_PROVIDERS } from '../MappingWizardClustersStepConstants';
import { FETCH_V2V_SOURCE_CLUSTERS } from '../MappingWizardClustersStepConstants';
import { sourceClusters } from '../mappingWizardClustersStep.fixtures';

test('sets default state', () => {
Expand Down Expand Up @@ -76,67 +75,3 @@ describe('fetching source clusters', () => {
});
});
});

describe('QUERY_V2V_PROVIDERS', () => {
test('querying providers is pending', () => {
const action = { type: `${QUERY_V2V_PROVIDERS}_PENDING` };
const prevState = Immutable({
...initialState,
isRejectedQueryProviders: true
});
const state = clustersReducer(prevState, action);

expect(state).toEqual({
...prevState,
isQueryingProviders: true,
isRejectedQueryProviders: false
});
});

test('querying providers is fulfilled', () => {
const payload = {
data: {
results: [{ mock: 'data' }]
}
};
const action = {
type: `${QUERY_V2V_PROVIDERS}_FULFILLED`,
payload
};
const prevState = Immutable({
...initialState,
isQueryingProviders: true,
isRejectedQueryProviders: true,
errorQueryProviders: 'error'
});
const state = clustersReducer(prevState, action);

expect(state).toEqual({
...prevState,
providers: payload.data.results,
isQueryingProviders: false,
isRejectedQueryProviders: false,
errorQueryProviders: null
});
});

test('fetching a plan is rejected', () => {
const payload = { error: 'error' };
const action = {
type: `${QUERY_V2V_PROVIDERS}_REJECTED`,
payload
};
const prevState = Immutable({
...initialState,
isQueryingProviders: true
});
const state = clustersReducer(prevState, action);

expect(state).toEqual({
...prevState,
isQueryingProviders: false,
isRejectedQueryProviders: true,
errorQueryProviders: payload
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,3 @@ Array [
},
]
`;
exports[`queryProvidersAction dispatches PENDING and FULFILLED actions 1`] = `
Array [
Object {
"type": "QUERY_V2V_PROVIDERS_PENDING",
},
Object {
"payload": Array [
Object {
"mock": "data",
},
],
"type": "QUERY_V2V_PROVIDERS_FULFILLED",
},
]
`;
exports[`queryProvidersAction dispatches PENDING and REJECTED actions 1`] = `
Array [
Object {
"type": "QUERY_V2V_PROVIDERS_PENDING",
},
Object {
"error": true,
"payload": [Error: <mocked error>],
"type": "QUERY_V2V_PROVIDERS_REJECTED",
},
]
`;
Loading

0 comments on commit c5c5e43

Please sign in to comment.