diff options
Diffstat (limited to 'runtime')
9 files changed, 190 insertions, 159 deletions
diff --git a/runtime/src/main/resources/application-noaaf.properties b/runtime/src/main/resources/application-noaaf.properties index 12a08704f..9f13a314c 100644 --- a/runtime/src/main/resources/application-noaaf.properties +++ b/runtime/src/main/resources/application-noaaf.properties @@ -150,10 +150,10 @@ clamp.config.httpclient.connectTimeout=10000 # # Configuration Settings for Policy Engine Components clamp.config.policy.api.url=http://localhost:8085 -clamp.config.policy.api.userName=healthcheck +clamp.config.policy.api.userName=policyadmin clamp.config.policy.api.password=zb!XztG34 clamp.config.policy.pap.url=http://localhost:8085 -clamp.config.policy.pap.userName=healthcheck +clamp.config.policy.pap.userName=policyadmin clamp.config.policy.pap.password=zb!XztG34 # @@ -194,5 +194,5 @@ clamp.config.cds.password=ccsdkapps # Configuration settings for ControlLoop Runtime Rest API clamp.config.controlloop.runtime.url=http://localhost:6969 -clamp.config.controlloop.runtime.userName=healthcheck +clamp.config.controlloop.runtime.userName=runtimeUser clamp.config.controlloop.runtime.password=zb!XztG34 diff --git a/runtime/src/main/resources/application.properties b/runtime/src/main/resources/application.properties index 08260047e..21b37c69f 100644 --- a/runtime/src/main/resources/application.properties +++ b/runtime/src/main/resources/application.properties @@ -149,10 +149,10 @@ clamp.config.httpclient.connectTimeout=10000 # # Configuration Settings for Policy Engine Components clamp.config.policy.api.url=http://policy.api.simpledemo.onap.org:6969 -clamp.config.policy.api.userName=healthcheck +clamp.config.policy.api.userName=policyadmin clamp.config.policy.api.password=zb!XztG34 clamp.config.policy.pap.url=http://policy.api.simpledemo.onap.org:6969 -clamp.config.policy.pap.userName=healthcheck +clamp.config.policy.pap.userName=policyadmin clamp.config.policy.pap.password=zb!XztG34 # @@ -204,5 +204,5 @@ clamp.config.cds.password=ccsdkapps # Configuration settings for ControlLoop Runtime Rest API clamp.config.controlloop.runtime.url=http://localhost:6969 -clamp.config.controlloop.runtime.userName=healthcheck +clamp.config.controlloop.runtime.userName=runtimeUser clamp.config.controlloop.runtime.password=zb!XztG34 diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/config/CldsReferencePropertiesItTestCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/config/CldsReferencePropertiesItTestCase.java index eeed51c12..79f3b12d7 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/config/CldsReferencePropertiesItTestCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/config/CldsReferencePropertiesItTestCase.java @@ -46,7 +46,7 @@ public class CldsReferencePropertiesItTestCase { */ @Test public void testGetStringValue() { - assertEquals("healthcheck", refProp.getStringValue("policy.api.userName")); + assertEquals("policyadmin", refProp.getStringValue("policy.api.userName")); } /** diff --git a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeInstantiationResponseItTestCase.java b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeInstantiationResponseItTestCase.java index ae80d0498..fdb815d75 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeInstantiationResponseItTestCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeInstantiationResponseItTestCase.java @@ -41,6 +41,8 @@ public class RuntimeInstantiationResponseItTestCase { private static final String DIRECT_GET_TOSCA_INSTANTIATION = "direct:get-tosca-instantiation"; + private static final String DIRECT_POST_TOSCA_INSTANTANCE_PROPERTIES = "direct:post-tosca-instance-properties"; + private static final String SERVICE_TEMPLATE_NAME = "name"; private static final String SERVICE_TEMPLATE_VERSION = "version"; @@ -51,6 +53,12 @@ public class RuntimeInstantiationResponseItTestCase { + "\"version\": \"1.0.1\",\"definition\": {},\"state\": \"UNINITIALISED\",\"orderedState\": \"UNINITIALISED\"," + "\"description\": \"PMSH control loop instance 0\",\"elements\": {}}]}"; + private static final String SAMPLE_TOSCA_TEMPLATE = + "{\"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\"," + + "\"data_types\": {},\"node_types\": {}, \"policy_types\": {}," + + " \"topology_template\": {}," + + " \"name\": \"ToscaServiceTemplateSimple\", \"version\": \"1.0.0\", \"metadata\": {}}"; + @Test public void testToscaServiceTemplateStatus() { ProducerTemplate prodTemplate = camelContext.createProducerTemplate(); @@ -93,4 +101,18 @@ public class RuntimeInstantiationResponseItTestCase { assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE)) .is2xxSuccessful()).isTrue(); } + + @Test + public void testCommissioningOfToscaServiceTemplateStatus() { + ProducerTemplate prodTemplate = camelContext.createProducerTemplate(); + + Exchange exchangeResponse = + prodTemplate.send(DIRECT_POST_TOSCA_INSTANTANCE_PROPERTIES, ExchangeBuilder.anExchange(camelContext) + .withBody(SAMPLE_TOSCA_TEMPLATE) + .withProperty("raiseHttpExceptionFlag", "true") + .build()); + + assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE)) + .is2xxSuccessful()).isTrue(); + } } diff --git a/runtime/src/test/resources/application.properties b/runtime/src/test/resources/application.properties index bc0c290db..f2cf0dd33 100644 --- a/runtime/src/test/resources/application.properties +++ b/runtime/src/test/resources/application.properties @@ -139,10 +139,10 @@ clamp.config.httpclient.connectTimeout=10000 # # Configuration Settings for Policy Engine Components clamp.config.policy.api.url=http://localhost:${docker.http-cache.port.host} -clamp.config.policy.api.userName=healthcheck +clamp.config.policy.api.userName=policyadmin clamp.config.policy.api.password=zb!XztG34 clamp.config.policy.pap.url=http://localhost:${docker.http-cache.port.host} -clamp.config.policy.pap.userName=healthcheck +clamp.config.policy.pap.userName=policyadmin clamp.config.policy.pap.password=zb!XztG34 # Sdc service properties @@ -183,5 +183,5 @@ clamp.config.tosca.converter.dictionary.support.enabled=true # Configuration settings for ControlLoop Runtime Rest API clamp.config.controlloop.runtime.url=http://localhost:${docker.http-cache.port.host} -clamp.config.controlloop.runtime.userName=healthcheck +clamp.config.controlloop.runtime.userName=runtimeUser clamp.config.controlloop.runtime.password=zb!XztG34 diff --git a/runtime/src/test/resources/http-cache/third_party_proxy.py b/runtime/src/test/resources/http-cache/third_party_proxy.py index 5c80cdda4..67af21470 100644 --- a/runtime/src/test/resources/http-cache/third_party_proxy.py +++ b/runtime/src/test/resources/http-cache/third_party_proxy.py @@ -331,6 +331,15 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): jsonGenerated = "{\"controlLoopList\": [{\"name\": \"PMSHInstance0\",\"version\": \"1.0.1\",\"definition\": {},\"state\": \"UNINITIALISED\",\"orderedState\": \"UNINITIALISED\",\"description\": \"PMSH control loop instance 0\",\"elements\": {}}]}"; self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content) return True + elif (self.path.startswith("/onap/controlloop/v2/instanceProperties")) and http_type == "POST": + print("self.path start with POST /onap/controlloop/v2/instanceProperties, copying body to response ...") + if not os.path.exists(cached_file_folder): + os.makedirs(cached_file_folder, 0o777) + with open(cached_file_header, 'w+') as f: + f.write("{\"Content-Length\": \"" + str(len(self.data_string)) + "\", \"Content-Type\": \""+str(self.headers['Content-Type'])+"\"}") + with open(cached_file_content, 'w+') as f: + f.write(self.data_string) + return True else: return False diff --git a/runtime/src/test/resources/robotframework/robotframework-test.properties b/runtime/src/test/resources/robotframework/robotframework-test.properties index 499719aa6..493c83c3d 100644 --- a/runtime/src/test/resources/robotframework/robotframework-test.properties +++ b/runtime/src/test/resources/robotframework/robotframework-test.properties @@ -136,10 +136,10 @@ clamp.config.httpclient.connectTimeout=10000 # # Configuration Settings for Policy Engine Components clamp.config.policy.api.url=http://localhost:${docker.http-cache.port.host} -clamp.config.policy.api.userName=healthcheck +clamp.config.policy.api.userName=policyadmin clamp.config.policy.api.password=zb!XztG34 clamp.config.policy.pap.url=http://localhost:${docker.http-cache.port.host} -clamp.config.policy.pap.userName=healthcheck +clamp.config.policy.pap.userName=policyadmin clamp.config.policy.pap.password=zb!XztG34 # Sdc service properties diff --git a/runtime/ui-react/src/components/dialogs/Policy/PolicyEditor.js b/runtime/ui-react/src/components/dialogs/Policy/PolicyEditor.js index be77f14e9..1e2754151 100644 --- a/runtime/ui-react/src/components/dialogs/Policy/PolicyEditor.js +++ b/runtime/ui-react/src/components/dialogs/Policy/PolicyEditor.js @@ -23,7 +23,7 @@ import React from 'react' import PolicyToscaService from '../../../api/PolicyToscaService'; -import { JSONEditor } from '@json-editor/json-editor/dist/nonmin/jsoneditor.js'; +import { JSONEditor } from '@json-editor/json-editor/dist/nonmin/jsoneditor.js'; import "@fortawesome/fontawesome-free/css/all.css" import styled from 'styled-components'; import Button from 'react-bootstrap/Button'; @@ -33,160 +33,160 @@ import PolicyService from '../../../api/PolicyService'; import OnapUtils from '../../../utils/OnapUtils'; const DivWhiteSpaceStyled = styled.div` - white-space: pre; + white-space: pre; ` const JsonEditorDiv = styled.div` - margin-top: 20px; - background-color: ${props => props.theme.loopViewerBackgroundColor}; - text-align: justify; - font-size: ${props => props.theme.policyEditorFontSize}; - border: 1px solid #C0C0C0; + margin-top: 20px; + background-color: ${ props => props.theme.loopViewerBackgroundColor }; + text-align: justify; + font-size: ${ props => props.theme.policyEditorFontSize }; + border: 1px solid #C0C0C0; ` const PanelDiv = styled.div` - text-align: justify; - font-size: ${props => props.theme.policyEditorFontSize}; - background-color: ${props => props.theme.loopViewerBackgroundColor}; + text-align: justify; + font-size: ${ props => props.theme.policyEditorFontSize }; + background-color: ${ props => props.theme.loopViewerBackgroundColor }; ` export default class PolicyEditor extends React.Component { - state = { - policyModelType: this.props.policyModelType, - policyModelTypeVersion: this.props.policyModelTypeVersion, - policyName: (typeof this.props.policyName !== "undefined") ? this.props.policyName : "org.onap.policy.new", - policyVersion: (typeof this.props.policyVersion !== "undefined") ? this.props.policyVersion : "0.0.1", - policyProperties: this.props.policyProperties, - showSuccessAlert: false, - showFailAlert: false, - jsonEditor: null, - jsonEditorDivId: this.props.policyModelType + "_" + this.props.policyModelTypeVersion + "_" + this.props.policyName + "_" + this.props.policyVersion, - } - - constructor(props, context) { - super(props, context); - this.createJsonEditor = this.createJsonEditor.bind(this); - this.getToscaModelForPolicy = this.getToscaModelForPolicy.bind(this); - this.disableAlert = this.disableAlert.bind(this); - this.handleCreateNewVersion = this.handleCreateNewVersion.bind(this); - this.handleChangePolicyName = this.handleChangePolicyName.bind(this); - this.handleChangePolicyVersion = this.handleChangePolicyVersion.bind(this); - } - - disableAlert() { - this.setState ({ showSuccessAlert: false, showFailAlert: false }); - } - - customValidation(editorData) { - // method for sub-classes to override with customized validation - return []; - } - - handleCreateNewVersion() { - var editorData = this.state.jsonEditor.getValue(); - var errors = this.state.jsonEditor.validate(); - errors = errors.concat(this.customValidation(editorData)); - - if (errors.length !== 0) { - console.error("Errors detected during policy data validation ", errors); - this.setState({ - showFailAlert: true, - showMessage: 'Errors detected during policy data validation:\n' + OnapUtils.jsonEditorErrorFormatter(errors) - }); - return; + state = { + policyModelType: this.props.policyModelType, + policyModelTypeVersion: this.props.policyModelTypeVersion, + policyName: (typeof this.props.policyName !== "undefined") ? this.props.policyName : "org.onap.policy.new", + policyVersion: (typeof this.props.policyVersion !== "undefined") ? this.props.policyVersion : "0.0.1", + policyProperties: this.props.policyProperties, + showSuccessAlert: false, + showFailAlert: false, + jsonEditor: null, + jsonEditorDivId: this.props.policyModelType + "_" + this.props.policyModelTypeVersion + "_" + this.props.policyName + "_" + this.props.policyVersion, + } + + constructor(props, context) { + super(props, context); + this.createJsonEditor = this.createJsonEditor.bind(this); + this.getToscaModelForPolicy = this.getToscaModelForPolicy.bind(this); + this.disableAlert = this.disableAlert.bind(this); + this.handleCreateNewVersion = this.handleCreateNewVersion.bind(this); + this.handleChangePolicyName = this.handleChangePolicyName.bind(this); + this.handleChangePolicyVersion = this.handleChangePolicyVersion.bind(this); + } + + disableAlert() { + this.setState({ showSuccessAlert: false, showFailAlert: false }); + } + + customValidation(editorData) { + // method for sub-classes to override with customized validation + return []; + } + + handleCreateNewVersion() { + var editorData = this.state.jsonEditor.getValue(); + var errors = this.state.jsonEditor.validate(); + errors = errors.concat(this.customValidation(editorData)); + + if (errors.length !== 0) { + console.error("Errors detected during policy data validation ", errors); + this.setState({ + showFailAlert: true, + showMessage: 'Errors detected during policy data validation:\n' + OnapUtils.jsonEditorErrorFormatter(errors) + }); + return; + } else { + console.info("NO validation errors found in policy data"); + PolicyService.createNewPolicy(this.state.policyModelType, this.state.policyModelTypeVersion, + this.state.policyName, this.state.policyVersion, editorData).then(respPolicyCreation => { + if (typeof (respPolicyCreation) === "undefined") { + //it indicates a failure + this.setState({ + showFailAlert: true, + showMessage: 'Policy Creation Failure' + }); } else { - console.info("NO validation errors found in policy data"); - PolicyService.createNewPolicy(this.state.policyModelType, this.state.policyModelTypeVersion, - this.state.policyName, this.state.policyVersion, editorData).then(respPolicyCreation => { - if (typeof(respPolicyCreation) === "undefined") { - //it indicates a failure - this.setState({ - showFailAlert: true, - showMessage: 'Policy Creation Failure' - }); - } else { - this.setState({ - showSuccessAlert: true, - showMessage: 'Policy '+ this.state.policyName + '/' + this.state.policyVersion + ' created successfully' - }); - this.props.policiesTableUpdateFunction(); - } - }) + this.setState({ + showSuccessAlert: true, + showMessage: 'Policy ' + this.state.policyName + '/' + this.state.policyVersion + ' created successfully' + }); + this.props.policiesTableUpdateFunction(); } + }) } - - getToscaModelForPolicy() { - PolicyToscaService.getToscaPolicyModel(this.state.policyModelType, this.state.policyModelTypeVersion).then(respJsonPolicyTosca => { - if (respJsonPolicyTosca !== {}) { - this.setState({ - jsonSchemaPolicyTosca: respJsonPolicyTosca, - jsonEditor: this.createJsonEditor(respJsonPolicyTosca, this.state.policyProperties), - }) - } - }); - } - - componentDidMount() { - this.getToscaModelForPolicy(); - } - - createJsonEditor(toscaModel, editorData) { - return new JSONEditor(document.getElementById(this.state.jsonEditorDivId), - { - schema: toscaModel, - startval: editorData, - theme: 'bootstrap4', - iconlib: 'fontawesome5', - object_layout: 'grid', - disable_properties: false, - disable_edit_json: false, - disable_array_reorder: true, - disable_array_delete_last_row: true, - disable_array_delete_all_rows: false, - array_controls_top: true, - keep_oneof_values: false, - collapsed: true, - show_errors: 'always', - display_required_only: false, - show_opt_in: false, - prompt_before_delete: true, - required_by_default: false + } + + getToscaModelForPolicy() { + PolicyToscaService.getToscaPolicyModel(this.state.policyModelType, this.state.policyModelTypeVersion).then(respJsonPolicyTosca => { + if (respJsonPolicyTosca !== {}) { + this.setState({ + jsonSchemaPolicyTosca: respJsonPolicyTosca, + jsonEditor: this.createJsonEditor(respJsonPolicyTosca, this.state.policyProperties), }) - } - - handleChangePolicyName(event) { - this.setState({ - policyName: event.target.value, - }); - } - - handleChangePolicyVersion(event) { - this.setState({ - policyVersion: event.target.value, - }); - } - - render() { - return ( - <PanelDiv> - <Alert variant="success" show={this.state.showSuccessAlert} onClose={this.disableAlert} dismissible> - <DivWhiteSpaceStyled> - {this.state.showMessage} - </DivWhiteSpaceStyled> - </Alert> - <Alert variant="danger" show={this.state.showFailAlert} onClose={this.disableAlert} dismissible> - <DivWhiteSpaceStyled> - {this.state.showMessage} - </DivWhiteSpaceStyled> - </Alert> - <TextField required id="policyName" label="Required" defaultValue={this.state.policyName} - onChange={this.handleChangePolicyName} variant="outlined" size="small"/> - <TextField required id="policyVersion" label="Required" defaultValue={this.state.policyVersion} - onChange={this.handleChangePolicyVersion} size="small" variant="outlined"/> - <Button variant="secondary" title="Create a new policy version from the defined parameters" - onClick={this.handleCreateNewVersion}>Create New Version</Button> - <JsonEditorDiv id={this.state.jsonEditorDivId} title="Policy Properties"/> - </PanelDiv> - ); - } -}
\ No newline at end of file + } + }); + } + + componentDidMount() { + this.getToscaModelForPolicy(); + } + + createJsonEditor(toscaModel, editorData) { + return new JSONEditor(document.getElementById(this.state.jsonEditorDivId), + { + schema: toscaModel, + startval: editorData, + theme: 'bootstrap4', + iconlib: 'fontawesome5', + object_layout: 'grid', + disable_properties: false, + disable_edit_json: false, + disable_array_reorder: true, + disable_array_delete_last_row: true, + disable_array_delete_all_rows: false, + array_controls_top: true, + keep_oneof_values: false, + collapsed: true, + show_errors: 'always', + display_required_only: false, + show_opt_in: false, + prompt_before_delete: true, + required_by_default: false + }) + } + + handleChangePolicyName(event) { + this.setState({ + policyName: event.target.value, + }); + } + + handleChangePolicyVersion(event) { + this.setState({ + policyVersion: event.target.value, + }); + } + + render() { + return ( + <PanelDiv> + <Alert variant="success" show={ this.state.showSuccessAlert } onClose={ this.disableAlert } dismissible> + <DivWhiteSpaceStyled> + { this.state.showMessage } + </DivWhiteSpaceStyled> + </Alert> + <Alert variant="danger" show={ this.state.showFailAlert } onClose={ this.disableAlert } dismissible> + <DivWhiteSpaceStyled> + { this.state.showMessage } + </DivWhiteSpaceStyled> + </Alert> + <TextField required id="policyName" label="Required" defaultValue={ this.state.policyName } + onChange={ this.handleChangePolicyName } variant="outlined" size="small"/> + <TextField required id="policyVersion" label="Required" defaultValue={ this.state.policyVersion } + onChange={ this.handleChangePolicyVersion } size="small" variant="outlined"/> + <Button variant="secondary" title="Create a new policy version from the defined parameters" + onClick={ this.handleCreateNewVersion }>Create New Version</Button> + <JsonEditorDiv id={ this.state.jsonEditorDivId } title="Policy Properties"/> + </PanelDiv> + ); + } +} diff --git a/runtime/ui-react/src/components/dialogs/Policy/__snapshots__/PolicyEditor.test.js.snap b/runtime/ui-react/src/components/dialogs/Policy/__snapshots__/PolicyEditor.test.js.snap index 959b52a36..bf84e91d1 100644 --- a/runtime/ui-react/src/components/dialogs/Policy/__snapshots__/PolicyEditor.test.js.snap +++ b/runtime/ui-react/src/components/dialogs/Policy/__snapshots__/PolicyEditor.test.js.snap @@ -37,7 +37,7 @@ exports[`Verify PolicyEditor Test the render method 1`] = ` > <styled.div> <div - className="sc-dlfnbm iSTbVM" + className="sc-dlfnbm eVKaeY" > <Alert closeLabel="Close alert" @@ -777,7 +777,7 @@ exports[`Verify PolicyEditor Test the render method 1`] = ` title="Policy Properties" > <div - className="sc-gsTCUz dAYWPx" + className="sc-gsTCUz hXXDCR" id="onap.policies.monitoring.tcagen2_1.0.0_org.onap.new_1.0.0" title="Policy Properties" /> |