aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation
diff options
context:
space:
mode:
authoratulpurohit <atul.purohit1@vodafone.com>2019-11-05 14:31:56 +0530
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-01-13 09:33:40 +0000
commit8b346842194edb8a9e8c4cd2764ae8ebbce988f0 (patch)
tree3ea20981d4cdd5858c4a99eb49c0370503c3c6cb /openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation
parent0ef638b2eb44c9f473e5ad8bea119845d968fde7 (diff)
Refresh option in validation result page
Issue-ID: SDC-2585 Co-authored-by: nikhil.soni@vodafone.com Signed-off-by: atulpurohit <atul.purohit1@vodafone.com> Change-Id: I78f1385d219837c300cb33aff82b7459f137babb Signed-off-by: atulpurohit <atul.purohit1@vodafone.com>
Diffstat (limited to 'openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation')
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js11
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js108
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js3
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx23
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx189
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetupView.jsx14
6 files changed, 248 insertions, 100 deletions
diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js
index a6237e878a..27d9b5ebf8 100644
--- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js
+++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js
@@ -30,14 +30,21 @@ export const mapActionsToProps = dispatch => {
SoftwareProductValidationActionHelper.onErrorThrown(dispatch, msg);
},
- onTestSubmit: (softwareProductId, version, status, tests) => {
+ onTestSubmit: (
+ softwareProductId,
+ version,
+ status,
+ tests,
+ requestId
+ ) => {
SoftwareProductValidationActionHelper.navigateToSoftwareProductValidationResults(
dispatch,
{
softwareProductId,
version,
status,
- tests
+ tests,
+ requestId
}
);
},
diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js
index 1ebb94b77c..fc6de3e2eb 100644
--- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js
+++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js
@@ -15,18 +15,40 @@
*/
import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js';
import Configuration from 'sdc-app/config/Configuration.js';
-import getValue from 'nfvo-utils/getValue.js';
import { actionTypes } from './SoftwareProductValidationConstants.js';
import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js';
import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js';
import i18n from 'nfvo-utils/i18n/i18n.js';
-function postVSPCertificationChecks(tests) {
+function createCertificationFormData(tests) {
+ var formData = new FormData();
+ var testData = [];
+ for (var test of tests) {
+ if (test.files) {
+ for (var file of test.files) {
+ formData.append('files', file.file, file.name);
+ }
+ }
+ delete test.files;
+ testData.push(test);
+ }
+ formData.append('testdata', JSON.stringify(testData));
+
+ return formData;
+}
+function postVSPCertificationChecks(
+ tests,
+ version,
+ softwareProductId,
+ requestId
+) {
const restPrefix = Configuration.get('restPrefix');
+ var id = version.id;
+ var formData = createCertificationFormData(tests);
return RestAPIUtil.post(
- `${restPrefix}/v1.0/externaltesting/executions`,
- getValue(tests)
+ `${restPrefix}/v1.0/externaltesting/executions?vspId=${softwareProductId}&vspVersionId=${id}&requestId=${requestId}`,
+ formData
);
}
@@ -35,41 +57,59 @@ function fetchVspChecks() {
return RestAPIUtil.fetch(`${restPrefix}/v1.0/externaltesting/testcasetree`);
}
+function extractEndPoint(tests) {
+ return [...new Set(tests.map(test => test.endpoint))];
+}
const SoftwareProductValidationActionHelper = {
navigateToSoftwareProductValidationResults(
dispatch,
- { softwareProductId, version, status, tests }
+ { softwareProductId, version, status, tests, requestId }
) {
- postVSPCertificationChecks(tests)
- .then(response => {
- dispatch({
- type: actionTypes.POST_VSP_TESTS,
- vspTestResults: response
- });
- ScreensHelper.loadScreen(dispatch, {
- screen: enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS,
- screenType: screenTypes.SOFTWARE_PRODUCT,
- props: {
- softwareProductId,
- version,
- status
- }
- });
- })
- .catch(error => {
- let errMessage = error.message || error.responseJSON.message;
- let title = error.responseJSON
- ? error.responseJSON.status
- : i18n('Error');
- dispatch({
- type: modalActionTypes.GLOBAL_MODAL_ERROR,
- data: {
- title: title,
- msg: errMessage,
- cancelButtonText: i18n('OK')
- }
+ return new Promise((resolve, reject) => {
+ postVSPCertificationChecks(
+ tests,
+ version,
+ softwareProductId,
+ requestId
+ )
+ .then(response => {
+ var testResultKeys = {};
+ testResultKeys.endPoints = extractEndPoint(tests);
+ testResultKeys.requestId = requestId;
+ dispatch({
+ type: actionTypes.POST_VSP_TESTS,
+ vspTestResults: response,
+ testResultKeys: testResultKeys
+ });
+ ScreensHelper.loadScreen(dispatch, {
+ screen:
+ enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS,
+ screenType: screenTypes.SOFTWARE_PRODUCT,
+ props: {
+ softwareProductId,
+ version,
+ status
+ }
+ });
+ resolve(response);
+ })
+ .catch(error => {
+ let errMessage =
+ error.message || error.responseJSON.message;
+ let title = error.responseJSON
+ ? error.responseJSON.status
+ : i18n('Error');
+ dispatch({
+ type: modalActionTypes.GLOBAL_MODAL_ERROR,
+ data: {
+ title: title,
+ msg: errMessage,
+ cancelButtonText: i18n('OK')
+ }
+ });
+ reject(error);
});
- });
+ });
},
fetchVspChecks(dispatch) {
diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js
index 4513e23205..4a7f257e73 100644
--- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js
+++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js
@@ -20,7 +20,8 @@ export default (state = {}, action) => {
case actionTypes.POST_VSP_TESTS:
return {
...state,
- vspTestResults: action.vspTestResults
+ vspTestResults: action.vspTestResults,
+ testResultKeys: action.testResultKeys
};
case actionTypes.FETCH_VSP_CHECKS:
return {
diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx
index fac69616bb..36cc7c7672 100644
--- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx
+++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx
@@ -15,7 +15,7 @@
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
-
+import Configuration from 'sdc-app/config/Configuration.js';
import i18n from 'nfvo-utils/i18n/i18n.js';
import { Button } from 'onap-ui-react';
import { Tab, Tabs } from 'onap-ui-react';
@@ -74,7 +74,9 @@ class SoftwareProductValidation extends Component {
buildChildElements(setItem, testScenario) {
let parentElement = {};
parentElement.value = setItem.name;
- parentElement.label = setItem.description;
+ parentElement.label = setItem.description
+ ? setItem.description
+ : setItem.name;
parentElement.children = [];
if (setItem.children !== undefined) {
setItem.children.forEach(element => {
@@ -89,11 +91,13 @@ class SoftwareProductValidation extends Component {
}
if (setItem.tests !== undefined) {
setItem.tests.forEach(element => {
- parentElement.children.push({
- value: element.testCaseName,
- label: element.description
- });
- this.setMapAndGeneralData(element, testScenario);
+ if (element.inputs) {
+ parentElement.children.push({
+ value: element.testCaseName,
+ label: element.testCaseName
+ });
+ this.setMapAndGeneralData(element, testScenario);
+ }
});
}
return parentElement;
@@ -115,6 +119,8 @@ class SoftwareProductValidation extends Component {
parentNode.children.push({
value: element.testCaseName,
label: element.description
+ ? element.description
+ : element.testCaseName
});
this.setMapAndGeneralData(element, scenario);
});
@@ -129,10 +135,11 @@ class SoftwareProductValidation extends Component {
let certificationList = [];
let { setVspTestsMap } = this.props;
if (Object.keys(res).length !== 0 && res.children) {
+ let allTestScenario = Configuration.get('allTestScenario');
res.children.forEach(element => {
if (element.name === 'certification') {
certificationData = element;
- } else if (element.name === 'compliance') {
+ } else if (element.name === allTestScenario) {
complianceData = element;
}
});
diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx
index 8888c92f6d..cda3fe2c92 100644
--- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx
+++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx
@@ -15,7 +15,7 @@
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
-
+import UUID from 'uuid-js';
import i18n from 'nfvo-utils/i18n/i18n.js';
import { Button } from 'onap-ui-react';
import GridSection from 'nfvo-components/grid/GridSection.jsx';
@@ -35,23 +35,51 @@ class VspInputs extends React.Component {
changeInputs(e, check, parameterName) {
let { testsRequest, generalInfo, setTestsRequest } = this.props;
- testsRequest[check].parameters[parameterName] = e;
+ if (e instanceof File) {
+ var timestamp = new Date().getTime();
+ var fileExtension = (
+ e.name.match(/[^\\\/]\.([^.\\\/]+)$/) || [null]
+ ).pop();
+ var fileName = fileExtension
+ ? timestamp + '.' + fileExtension
+ : timestamp;
+ testsRequest[check].parameters[parameterName] =
+ 'file://' + fileName;
+
+ testsRequest[check].files = testsRequest[check].files
+ ? testsRequest[check].files
+ : [];
+ testsRequest[check].files.push({ file: e, name: fileName });
+ } else {
+ testsRequest[check].parameters[parameterName] = e;
+ }
+
generalInfo[check][parameterName] = { isValid: true, errorText: '' };
setTestsRequest(testsRequest, generalInfo);
}
- renderInputs(check) {
+ renderInputs(check, indexKey) {
let { vspTestsMap, testsRequest, generalInfo } = this.props;
return (
- <div className="div-clear-both">
+ <div key={indexKey} className="div-clear-both">
<GridSection
title={i18n('{title} Inputs :', {
- title: vspTestsMap[check].title
+ title: vspTestsMap[check].title.split(/\r?\n/)[0]
})}>
{vspTestsMap[check].parameters.map((parameter, index) => {
+ parameter.metadata = parameter.metadata
+ ? parameter.metadata
+ : {};
+ if (
+ !this.props.filterField(parameter) ||
+ parameter.metadata.hidden
+ ) {
+ return;
+ }
if (
- parameter.type === 'text' &&
- !parameter.metadata.hidden
+ parameter.type === 'text' ||
+ parameter.type === 'string' ||
+ parameter.type === 'json'
) {
return (
<GridItem key={index}>
@@ -112,6 +140,31 @@ class VspInputs extends React.Component {
</Input>
</GridItem>
);
+ } else if (parameter.type === 'binary') {
+ return (
+ <GridItem key={index}>
+ <Input
+ label={parameter.description}
+ type="file"
+ isRequired={!parameter.isOptional}
+ isValid={
+ generalInfo[check][parameter.name]
+ .isValid
+ }
+ errorText={
+ generalInfo[check][parameter.name]
+ .errorText
+ }
+ onChange={e => {
+ this.changeInputs(
+ e.target ? e.target.value : e,
+ check,
+ parameter.name
+ );
+ }}
+ />
+ </GridItem>
+ );
}
})}
</GridSection>
@@ -127,18 +180,18 @@ class VspInputs extends React.Component {
} = this.props;
return (
<div>
- {complianceChecked.map(complianceCheck => {
+ {complianceChecked.map((complianceCheck, index) => {
if (vspTestsMap[complianceCheck].parameters.length === 0) {
return <div />;
} else {
- return this.renderInputs(complianceCheck);
+ return this.renderInputs(complianceCheck, index);
}
})}
- {certificationChecked.map(certificateCheck => {
+ {certificationChecked.map((certificateCheck, index) => {
if (vspTestsMap[certificateCheck].parameters.length === 0) {
return <div />;
} else {
- return this.renderInputs(certificateCheck);
+ return this.renderInputs(certificateCheck, index);
}
})}
</div>
@@ -159,7 +212,19 @@ class VspValidationInputs extends Component {
shouldComponentUpdate() {
return true;
}
-
+ filterField(parameter) {
+ if (
+ parameter.name === 'host-username' ||
+ parameter.name === 'vsp' ||
+ parameter.name === 'vsp-zip' ||
+ parameter.name === 'host-password' ||
+ parameter.name === 'host-url'
+ ) {
+ return false;
+ } else {
+ return true;
+ }
+ }
validateInputs() {
let areInputsValid = true;
let { softwareProductValidation, setGeneralInfo } = this.props;
@@ -178,43 +243,57 @@ class VspValidationInputs extends Component {
);
let isParameterValid = true;
let errorText = '';
- if (
- parameter.type === 'text' &&
- parameter.metadata.choices
- ) {
- if (
- !parameter.isOptional &&
- !requestParameters[parameterName]
- ) {
- isParameterValid = false;
- errorText = i18n('Field is required');
- }
- } else if (parameter.type === 'text') {
+ if (!this.filterField(parameter)) {
+ // Not required any action
+ } else {
if (
- !parameter.isOptional &&
- !requestParameters[parameterName]
+ (parameter.type === 'text' ||
+ parameter.type === 'string') &&
+ parameter.metadata.choices
) {
- isParameterValid = false;
- errorText = i18n('Field is required');
+ if (
+ !parameter.isOptional &&
+ !requestParameters[parameterName]
+ ) {
+ isParameterValid = false;
+ errorText = i18n('Field is required');
+ }
} else if (
- (!parameter.isOptional &&
- !requestParameters[parameterName]) ||
- (parameter.metadata.maxLength &&
- requestParameters[parameterName].length >
- parseInt(parameter.metadata.maxLength)) ||
- (parameter.metadata.minLength &&
- requestParameters[parameterName].length <
- parseInt(parameter.metadata.minLength) &&
- requestParameters[parameterName].length > 0)
+ parameter.type === 'text' ||
+ parameter.type === 'string' ||
+ parameter.type === 'json' ||
+ parameter.type === 'binary'
) {
- isParameterValid = false;
- errorText = i18n(
- 'Value Should Be Minimum of {minLength} characters and a Maximum of {maxLength} characters',
- {
- minLength: parameter.metadata.minLength,
- maxLength: parameter.metadata.maxLength
- }
- );
+ if (
+ !parameter.isOptional &&
+ !requestParameters[parameterName]
+ ) {
+ isParameterValid = false;
+ errorText = i18n('Field is required');
+ } else if (
+ (!parameter.isOptional &&
+ !requestParameters[parameterName]) ||
+ (parameter.metadata.maxLength &&
+ requestParameters[parameterName].length >
+ parseInt(
+ parameter.metadata.maxLength
+ )) ||
+ (parameter.metadata.minLength &&
+ requestParameters[parameterName].length <
+ parseInt(
+ parameter.metadata.minLength
+ ) &&
+ requestParameters[parameterName].length > 0)
+ ) {
+ isParameterValid = false;
+ errorText = i18n(
+ 'Value Should Be Minimum of {minLength} characters and a Maximum of {maxLength} characters',
+ {
+ minLength: parameter.metadata.minLength,
+ maxLength: parameter.metadata.maxLength
+ }
+ );
+ }
}
}
generalInfo[testCaseName][
@@ -244,13 +323,22 @@ class VspValidationInputs extends Component {
} = this.props;
Object.keys(softwareProductValidation.testsRequest).forEach(key => {
- tests.push(softwareProductValidation.testsRequest[key]);
+ var testReq = softwareProductValidation.testsRequest[key];
+ this.removeParameterFromTest(testReq);
+ tests.push(testReq);
});
if (this.validateInputs()) {
- onTestSubmit(softwareProductId, version, status, tests);
+ var requestId = UUID.create()
+ .toString()
+ .split('-')[0];
+ onTestSubmit(softwareProductId, version, status, tests, requestId);
}
}
-
+ removeParameterFromTest(testReq) {
+ delete testReq.parameters['host-username'];
+ delete testReq.parameters['host-password'];
+ delete testReq.parameters['host-url'];
+ }
prepareDataForVspInputs() {
let { setTestsRequest } = this.props;
let {
@@ -279,7 +367,10 @@ class VspValidationInputs extends Component {
isValid={true}
onSubmit={() => this.performVSPTests()}
isReadOnlyMode={false}>
- <VspInputs {...this.prepareDataForVspInputs()} />
+ <VspInputs
+ {...this.prepareDataForVspInputs()}
+ filterField={this.filterField}
+ />
<Button
size="default"
data-test-id="proceed-to-validation-results-btn"
diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetupView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetupView.jsx
index 012d50ac93..d1952bf7f2 100644
--- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetupView.jsx
+++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/setup/VspValidationSetupView.jsx
@@ -206,10 +206,14 @@ class ComplianceTests extends React.Component {
let { complianceNodes, setComplianceChecked } = this.props;
return (
<div className="validation-setup-checkbox-tree-section">
- <GridSection title={i18n('Compliance Checks')}>
+ <GridSection title={i18n('Available Tests')}>
<GridItem colSpan={2}>
<div className="validation-view-title">
- {complianceNodes[0] ? complianceNodes[0].value : ''}
+ {complianceNodes[0] && complianceNodes[0].value ? (
+ complianceNodes[0].value
+ ) : (
+ <br />
+ )}
</div>
<div
className="validation-setup-available-tests-section"
@@ -237,9 +241,7 @@ class ComplianceTests extends React.Component {
/>
)}
{complianceNodes.length === 0 && (
- <div>
- {i18n('No Compliance Checks are Available')}
- </div>
+ <div>{i18n('No Tests are Available')}</div>
)}
</div>
</GridItem>
@@ -247,7 +249,7 @@ class ComplianceTests extends React.Component {
{complianceNodes.length > 0 && (
<div>
<div className="validation-view-title">
- {i18n('Selected Compliance Tests')}
+ {i18n('Selected Tests')}
</div>
<div>
<select