diff options
40 files changed, 721 insertions, 851 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java index 723bed17f7..8cacf8526a 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java @@ -58,9 +58,12 @@ public class MsoHeatEnvironmentEntry { return; byte[] b = this.rawEntry.toString().getBytes(); MsoYamlEditorWithEnvt yaml = new MsoYamlEditorWithEnvt(b); - this.parameters = yaml.getParameterListFromEnvt(); - // this.resources = yaml.getResourceListFromEnvt(); - StringBuilder sb = this.getResourceRegistryRawEntry(); + StringBuilder sb = null; + if (yaml != null) { + this.parameters = yaml.getParameterListFromEnvt(); + // this.resources = yaml.getResourceListFromEnvt(); + sb = this.getResourceRegistryRawEntry(); + } if (sb == null) { this.resourceRegistryEntryRaw = new StringBuilder(""); } else { diff --git a/adapters/mso-adapter-utils/src/main/resources/application-local.yaml b/adapters/mso-adapter-utils/src/main/resources/application-local.yaml deleted file mode 100644 index 5fc2144bd6..0000000000 --- a/adapters/mso-adapter-utils/src/main/resources/application-local.yaml +++ /dev/null @@ -1,64 +0,0 @@ -# will be used as entry in DB to say SITE OFF/ON for healthcheck -# MSO Properties go here -mso: - catalog: - db: - spring: - endpoint: "http://localhost:8080" - db: - auth: Basic YnBlbDptc28tZGItMTUwNyE= -cloud_config: - identity_services: - MT_KEYSTONE: - identity_url: "http://localhost:5000/v2.0" - mso_id: "john" - mso_pass: "313DECE408AF7759D442D7B06DD9A6AA" - admin_tenant: "admin" - member_role: "_member_" - tenant_metadata: false - identity_server_type: "KEYSTONE" - identity_authentication_type: "USERNAME_PASSWORD" - DAN_KEYSTONE: - identity_url: "http://192.168.170.21:5000/v2.0" - mso_id: "jc1348" - mso_pass: "313DECE408AF7759D442D7B06DD9A6AA" - admin_tenant: "service" - member_role: "_member_" - tenant_metadata: false - identity_server_type: "KEYSTONE" - identity_authentication_type: "USERNAME_PASSWORD" - cloud_sites: - regionOne: - region_id: "regionOne" - clli: "MT2" - aic_version: "2.5" - identity_service_id: "MT_KEYSTONE" - DAN: - region_id: "RegionOne" - clli: "MT" - aic_version: "2.5" - identity_service_id: "DAN_KEYSTONE" - DEFAULT: - region_id: "" - clli: "MTN6" - aic_version: "3.0" - identity_service_id: "ORDM3" -adapters: - po: - retryCodes: "504" - retryDelay: "5" - retryCount: "3" - tenant: - tenant_description: "ECOMP Tenant" - region_type: "single" - user_role: "admin" - success_status_string: "Success" - no_regions_status_string: "no regions" - orm_request_path: "/v1/orm/customers/" - x_aic_orm_client_string: "ECOMP-MSO" - keystone_url_version: "/v2.0" - keystone_reg_ex: "/[vV][0-9]" - orm_url_replace_this: "8080" - orm_url_replace_with_this: "7080" - quota_value: "10" - set_default_quota: "false" diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/application-local.yaml b/adapters/mso-catalog-db-adapter/src/main/resources/application-local.yaml deleted file mode 100644 index d7c13eaa14..0000000000 --- a/adapters/mso-catalog-db-adapter/src/main/resources/application-local.yaml +++ /dev/null @@ -1,35 +0,0 @@ - -catalog: - db: - endpoint: http://localhost:8090 - -ssl-enable: false -mso: - site-name: localDevEnv - logPath: logs - catalog: - db: - spring: - endpoint: http://localhost:8090 - db: - auth: Basic YnBlbDptc28tZGItMTUwNyE= -spring: - security: - usercredentials: - - - username: test - password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' - role: BPEL-Client - - - username: bpel - password: '$2a$12$1xyutEZNfjGewIZRfKaE8eZE99f5sYFUmmM80BobI65KNjmcK0JuO' - role: BPEL-Client - - - username: mso_admin - password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa' - role: ACTUATOR - -server: - port: 8090 - - diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index 5dff4705af..d9f47f5c3a 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -1294,15 +1294,23 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Resource Property List<ContrailPolicyRef> prlist = new ArrayList<>(); int index = 1; - for (String pf : pFqdns) { - if (!commonUtils.isNullOrEmpty(pf)) { - ContrailPolicyRef pr = new ContrailPolicyRef(); - ContrailPolicyRefSeq refSeq = new ContrailPolicyRefSeq(String.valueOf(index), "0"); - pr.setSeq(refSeq); - index++; - logger.debug("Contrail PolicyRefs Data:{}", pr); - prlist.add(pr); + + if (pFqdns != null) { + for (String pf : pFqdns) { + if (!commonUtils.isNullOrEmpty(pf)) { + ContrailPolicyRef pr = new ContrailPolicyRef(); + ContrailPolicyRefSeq refSeq = new ContrailPolicyRefSeq(String.valueOf(index), "0"); + pr.setSeq(refSeq); + index++; + logger.debug("Contrail PolicyRefs Data:{}", pr); + prlist.add(pr); + } } + } else { + String error = "Null pFqdns at start of mergePolicyRefs"; + logger.error(LoggingAnchor.THREE, MessageEnum.RA_MARSHING_ERROR, ErrorCode.BusinessProcesssError.getValue(), + error); + throw new MsoAdapterException(error); } JsonNode node = null; diff --git a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml deleted file mode 100644 index 66d63d436b..0000000000 --- a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml +++ /dev/null @@ -1,105 +0,0 @@ -# will be used as entry in DB to say SITE OFF/ON for healthcheck -# MSO Properties go here -org: - onap: - so: - adapters: - default_keystone_url_version: /v2.0 - default_keystone_reg_ex: "/[vV][0-9]" - vnf: - bpelauth: 1DDAD7A55A230BB446AA2125053EFB46455F43E48B60155E1C53236E175DFC722A6BE120F6DB390C60034C7564AEB653EA - checkRequiredParameters: true - addGetFilesOnVolumeReq: false - sockettimeout: 30 - connecttimeout: 30 - retrycount: 5 - retryinterval: -15 - retrylist: 408,429,500,502,503,504,900 - network: - bpelauth: 1DDAD7A55A230BB446AA2125053EFB46455F43E48B60155E1C53236E175DFC722A6BE120F6DB390C60034C7564AEB653EA - sockettimeout: 5 - connecttimeout: 5 - retrycount: 5 - retryinterval: -15 - retrylist: 408,429,500,502,503,504,900 - encryptionKey: aa3871669d893c7fb8abbcda31b88b4f - tenant: - default_x_aic_orm_client_string: ECOMP-MSO - default_keystone_url_version: /v2.0 - default_keystone_reg_ex: "/[vV][0-9]" - default_tenant_description: ECOMP Tenant - default_region_type: single - default_user_role: admin - default_success_status_string: Success - default_no_regions_status_string: no regions - default_orm_request_path: /v1/orm/customers/ - default_orm_url_replace_this: 8080 - default_orm_url_replace_with_this: 7080 - default_quota_value: 10 - set_default_quota: false - po: - retryCodes: 504 - retryDelay: 5 - retryCount: 3 - pollTimeout: 7500 - pollInterval: 15 - -server-port: 8080 -ssl-enable: false -tomcat: - max-threads: 50 -mso: - msoKey: 07a7159d3bf51a0e53be7a8f89699be7 - auth: 6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436 - audit: - lock-time: 240000 - logPath: logs - msb-ip: localhost - msb-port: ${wiremock.server.port} - workflow: - endpoint: http://bpmn-infra:8081/sobpmnengine - topics: - retryMultiplier: 1000 - config: - cadi: - aafId: test - catalog: - db: - spring: - endpoint: "http://localhost:8080" - db: - auth: Basic YnBlbDptc28tZGItMTUwNyE= - site-name: localDevEnv - async: - core-pool-size: 50 - max-pool-size: 50 - queue-capacity: 500 - -spring: - security: - usercredentials: - - - username: sdnc - password: '$2a$12$mukkC6IvLikKGBdwqGnev.H0ccvV6K13TFeLvyNhJoCuNkRjWhqi6' - role: SDNC-Client - - - username: sitecontrol - password: '$2a$12$VBUF.qBmeK1FNyO2MqTpD.P2M1tvlesZlhCkAjjHvF9hmYNVdMDmu' - role: SiteControl-Client - - - username: bpel - password: '$2a$12$/GW0/AVAUooTag.7GDc9a.jW7XH3nq/.QsJJJFZJ0N24iXB2W9ksO' - role: BPEL-Client - - - username: sniro - password: '$2a$12$lbOQWS1iDmdQPxW2Mb6OiuTzGaPUrkrvoKVn2zwpFWb6n5Y86Lf1y' - role: SNIRO-Client - - - username: apih - password: '$2a$12$e1BGJ7qknMN/b7bqsQvU2OT9iGunt9IlfQclKlCs6n240oHBfcO5y' - role: MSO-Client - - - username: mso_admin - password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa' - role: ACTUATOR - diff --git a/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml b/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml deleted file mode 100644 index 5d3a837180..0000000000 --- a/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml +++ /dev/null @@ -1,51 +0,0 @@ -# will be used as entry in DB to say SITE OFF/ON for healthcheck
-
-server:
- port: 8090
- tomcat:
- max-threads: 50
-ssl-enable: false
-mso:
- adapters:
- requestDb:
- auth: Basic YnBlbDptc28tZGItMTUwNyE=
- endpoint: http://localhost:8081
- logPath: logs
- site-name: localSite
- infra-requests:
- archived:
- period: 180
-spring:
- datasource:
- url: jdbc:mariadb://localhost:3306/requestdb
- username: catalog
- password: catalog123
- driver-class-name: org.mariadb.jdbc.Driver
- initialize: true
- initialization-mode: never
- jpa:
- generate-ddl: false
- show-sql: false
- hibernate:
- ddl-auto: validate
- naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
- enable-lazy-load-no-trans: true
- database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
- security:
- usercredentials:
- -
- username: bpel
- password: '$2a$12$1xyutEZNfjGewIZRfKaE8eZE99f5sYFUmmM80BobI65KNjmcK0JuO'
- role: BPEL-Client
- -
- username: mso_admin
- password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa'
- role: ACTUATOR
-
-
-flyway:
- baseline-on-migrate: false
- url: jdbc:mariadb://localhost:3306/requestdb
- user: catalog
- password: catalog123
-
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/resources/application-local.yaml b/adapters/mso-sdnc-adapter/src/main/resources/application-local.yaml deleted file mode 100644 index 4141548c29..0000000000 --- a/adapters/mso-sdnc-adapter/src/main/resources/application-local.yaml +++ /dev/null @@ -1,133 +0,0 @@ -management: - context-path: /manage -mso: - async: - core-pool-size: 50 - max-pool-size: 50 - queue-capacity: 500 - logPath: /app/logs/sdnc - catalog: - db: - spring: - endpoint: "http://localhost:8080" - db: - auth: Basic YnBlbDptc28tZGItMTUwNyE= - site-name: local -org: - onap: - so: - adapters: - sdnc: - '.': - put: PUT|60000|sdncurl5| - query: GET|60000|sdncurl2| - restdelete: DELETE|60000|sdncurl5| - '': - contrail-route-topology-operation: - activate: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - assign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - create: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - deactivate: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - delete: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - unassign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - network-topology-operation: - activate: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - assign: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - changeassign: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - changedelete: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - delete: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - reserve: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - rollback: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - security-zone-topology-operation: - activate: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - assign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - create: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - deactivate: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - delete: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - unassign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - service-topology-operation: - assign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - deactivate: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - delete: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - rollback: POST|270000|sdncur10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - vnf-topology-operation: - activate: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - assign: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - changeassign: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - changedelete: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - delete: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - rollback: POST|270000|sdncurl6|sdnc-request-header|org:onap:sdnctl:vnf - bpelauth: BBD450258299BD2FEF7E3EBA3CD2B58AD417355332319856D761654AA876830A9839820D33DE8426A81E5D48649A4BE6FE7021F5 - bpelurl: http://localhost:8080/mso/SDNCAdapterCallbackService - generic-resource: - network-topology-operation: - activate: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - assign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - deactivate: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - unassign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - vf-module-topology-operation: - activate: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - assign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - changeassign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - changedelete: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - deactivate: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - delete: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - rollback: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - unassign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - vnf-topology-operation: - activate: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - assign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - changeassign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - changedelete: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - deactivate: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - delete: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - rollback: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - unassign: POST|270000|sdncurl10|sdnc-request-header|org:onap:sdnc:northbound:generic-resource - infra: - '': - query: GET|60000|sdncurl5| - mobility: - '': - query: GET|60000|sdncurl5| - myurl: http://localhost:8080/adapters/rest/SDNCNotify - rest: - bpelurl: http://localhost:8080/mso/WorkflowMessage - sdncauth: 1C2DC9B30545C5F673B3C33904608E942476F0C969B3CF7A2509459AB83C9062EFAAE89E91D6DB - sdncconnecttime: 5000 - sdncurl10: 'https://localhost:8443/restconf/operations/GENERIC-RESOURCE-API:' - sdncurl12: https://localhost:8443/ - sdncurl5: https://localhost:8443/restconf/config - sdncurl6: 'https://localhost:8443/restconf/operations/VNF-API:' - vfmodule: - '': - query: GET|60000|sdncurl12| - network: - encryptionKey: aa3871669d893c7fb8abbcda31b88b4f -spring: - security: - usercredentials: - - - username: sdnc - password: '$2a$12$mukkC6IvLikKGBdwqGnev.H0ccvV6K13TFeLvyNhJoCuNkRjWhqi6' - role: SDNC-Client - - - username: sitecontrol - password: '$2a$12$VBUF.qBmeK1FNyO2MqTpD.P2M1tvlesZlhCkAjjHvF9hmYNVdMDmu' - role: SiteControl-Client - - - username: bpel - password: '$2a$12$/GW0/AVAUooTag.7GDc9a.jW7XH3nq/.QsJJJFZJ0N24iXB2W9ksO' - role: BPEL-Client - - - username: sniro - password: '$2a$12$lbOQWS1iDmdQPxW2Mb6OiuTzGaPUrkrvoKVn2zwpFWb6n5Y86Lf1y' - role: SNIRO-Client - - - username: apih - password: '$2a$12$e1BGJ7qknMN/b7bqsQvU2OT9iGunt9IlfQclKlCs6n240oHBfcO5y' - role: MSO-Client - - - username: mso_admin - password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa' - role: ACTUATOR -ssl-enable: false diff --git a/adapters/mso-vfc-adapter/src/main/resources/application-local.yaml b/adapters/mso-vfc-adapter/src/main/resources/application-local.yaml deleted file mode 100644 index 414dabb0a1..0000000000 --- a/adapters/mso-vfc-adapter/src/main/resources/application-local.yaml +++ /dev/null @@ -1,34 +0,0 @@ -server: - port: 8091 - tomcat: - max-threads: 50 -ssl-enable: false -mso: - logPath: logs - site-name: localSite -spring: - datasource: - jdbc-url: jdbc:mariadb://localhost:3306/requestdb - username: mso - password: mso123 - driver-class-name: org.mariadb.jdbc.Driver - initialize: true - initialization-mode: never - jpa: - generate-ddl: false - show-sql: false - hibernate: - ddl-auto: validate - naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy - enable-lazy-load-no-trans: true - database-platform: org.hibernate.dialect.MySQL5InnoDBDialect - security: - usercredentials: - - - username: bpel - password: '$2a$12$1xyutEZNfjGewIZRfKaE8eZE99f5sYFUmmM80BobI65KNjmcK0JuO' - role: BPEL-Client - - - username: mso_admin - password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa' - role: ACTUATOR diff --git a/asdc-controller/src/main/resources/application-local.yaml b/asdc-controller/src/main/resources/application-local.yaml deleted file mode 100644 index 1b21d8b571..0000000000 --- a/asdc-controller/src/main/resources/application-local.yaml +++ /dev/null @@ -1,95 +0,0 @@ -# will be used as entry in DB to say SITE OFF/ON for healthcheck - -server-port: 8080 -ssl-enable: false - - - -# H2 -spring: - datasource: - jdbc-url: jdbc:mariadb://localhost:3306/catalogdb - username: root - password: password - driver-class-name: org.mariadb.jdbc.Driver - initialize: true - - jpa: - show-sql: true - hibernate: - ddl-auto: validate - naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy - enable-lazy-load-no-trans: true - database-platform: org.hibernate.dialect.MySQL5InnoDBDialect - security: - usercredentials: - - - username: asdc - password: '$2a$12$4R2QhxH7elzoZYoC.HJKTOHYDoaC9LbJD44Q9/tm4t/UzPF9Cgifi' - role: Asdc-Client - - - username: mso_admin - password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa' - role: ACTUATOR -request: - datasource: - jdbc-url: jdbc:mariadb://localhost:3306/requestdb - username: root - password: password - driver-class-name: org.mariadb.jdbc.Driver - initialize: true - initialization-mode: never - -#Actuator -management: - endpoints: - web: - base-path: /manage - server: - servlet: - context-path: /manage - metrics: - se-global-registry: false - export: - prometheus: - enabled: true # Whether exporting of metrics to Prometheus is enabled. - step: 1m # Step size (i.e. reporting frequency) to use. - - -mso: - logPath: logs - catalog: - db: - spring: - endpoint: "http://localhost:8090" - db: - auth: Basic YnBlbDptc28tZGItMTUwNyE= - site-name: siteName - aai: - endpoint: https://localhost:8443 - asdc-connections: - asdc-controller1: - user: msopreist - consumerGroup: msoasdc-id-local - consumerId: msoasdc-id-local - environmentName: Pre-IST - asdcAddress: localhost:8443 - password: CB655C3C236F1F0370A347E3A0E0E133BE10ADCF4D16377E7378D3FE46A4BF60C27DF1FFB4 - pollingInterval: 30 - pollingTimeout: 30 - relevantArtifactTypes: HEAT,HEAT_ENV,HEAT_VOL - useHttpsWithDmaap: true - activateServerTLSAuth: false - keyStorePassword: - keyStorePath: - watchDogTimeout: 1 - isFitlerInEmptyResources: true - messageBusAddress: localhost,localhost,localhost - asdc: - config: - key: 566B754875657232314F5548556D3665 - components: - count: 3, - componentNames: SO,AAI,SDNC - scheduling: - enabled: false diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java index b76316bf0e..b2dbd97bfc 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java @@ -60,7 +60,7 @@ public class ExtractPojosForBB { if (gBBInput.getCustomer().getServiceSubscription() == null && gBBInput.getServiceInstance() != null) { result = Optional.of((T) gBBInput.getServiceInstance()); - } else { + } else if (gBBInput.getCustomer().getServiceSubscription() != null) { result = lookupObjectInList( gBBInput.getCustomer().getServiceSubscription().getServiceInstances(), value); } diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java index d099cbebcc..b6bccdb5c9 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/xml/XmlToolTest.java @@ -28,7 +28,7 @@ public class XmlToolTest { private String encodeResponseNamespace = "<Response xmlns:ns2=\"http://ecomp.att.com/mso/request/types/v1\">good</Response>"; private String attribute = "<Response>good&\"bad\"</Response>"; - private String updatedAttribute = "<Response>good&"bad"</Response>"; + // private String updatedAttribute = "<Response>good&"bad"</Response>"; private String content = "<dummy><configuration-event>" + "<event-type>test</event-type>" + "<event-correlator-type>test</event-correlator-type>" + "<event-correlator>123</event-correlator>" diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java index 8fe7e4f868..9319353e5a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java @@ -94,7 +94,7 @@ public class ServicePluginFactory { THIRD_SP_DEFAULT_ENDPOINT = prop.getProperty("third.sp.default.endpoint"); INVENTORY_OSS_DEFAULT_ENDPOINT = prop.getProperty("inventory.oss.default.endpoint"); } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to load property file!"); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index e3540ecc58..583e3e172a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -77,7 +77,6 @@ public class AAICreateTasks { private static final Logger logger = LoggerFactory.getLogger(AAICreateTasks.class); private static final String networkTypeProvider = "PROVIDER"; - private static final String A_LA_CARTE = "aLaCarte"; private static String NETWORK_COLLECTION_NAME = "networkCollectionName"; private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList"; private static String HEAT_STACK_ID = "heatStackId"; @@ -107,12 +106,8 @@ public class AAICreateTasks { public void createServiceInstance(BuildingBlockExecution execution) { try { - Boolean alaCarte = execution.getVariable(A_LA_CARTE); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); - if (Boolean.TRUE.equals(alaCarte) && aaiSIResources.checkInstanceServiceNameInUse(serviceInstance)) { - throw new DuplicateNameException("service-instance", serviceInstance.getServiceInstanceName()); - } Customer customer = execution.getGeneralBuildingBlock().getCustomer(); aaiSIResources.createServiceInstance(serviceInstance, customer); } catch (Exception ex) { @@ -199,11 +194,7 @@ public class AAICreateTasks { public void createVnf(BuildingBlockExecution execution) { try { - Boolean alaCarte = execution.getVariable(A_LA_CARTE); GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - if (Boolean.TRUE.equals(alaCarte) && aaiVnfResources.checkNameInUse(vnf.getVnfName())) { - throw new DuplicateNameException("generic-vnf", vnf.getVnfName()); - } ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); execution.setVariable("homing", Boolean.TRUE.equals(vnf.isCallHoming())); @@ -262,10 +253,6 @@ public class AAICreateTasks { GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - Boolean alaCarte = execution.getVariable(A_LA_CARTE); - if (Boolean.TRUE.equals(alaCarte) && aaiVolumeGroupResources.checkNameInUse(volumeGroup)) { - throw new DuplicateNameException("volume-group", volumeGroup.getVolumeGroupName()); - } aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion); aaiVolumeGroupResources.connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion); aaiVolumeGroupResources.connectVolumeGroupToTenant(volumeGroup, cloudRegion); @@ -278,10 +265,6 @@ public class AAICreateTasks { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); - Boolean alaCarte = execution.getVariable(A_LA_CARTE); - if (Boolean.TRUE.equals(alaCarte) && aaiVfModuleResources.checkNameInUse(vfModule)) { - throw new DuplicateNameException("vf-module", vfModule.getVfModuleName()); - } int moduleIndex = 0; if (vfModule.getModelInfoVfModule() != null && !Boolean.TRUE.equals(vfModule.getModelInfoVfModule().getIsBaseBoolean())) { @@ -327,14 +310,9 @@ public class AAICreateTasks { */ public void createNetwork(BuildingBlockExecution execution) { try { - Boolean alaCarte = execution.getVariable(A_LA_CARTE); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); - if (Boolean.TRUE.equals(alaCarte) - && aaiNetworkResources.checkNetworkNameInUse(l3network.getNetworkName())) { - throw new DuplicateNameException("l3Network", l3network.getNetworkName()); - } // set default to false. ToBe updated by SDNC l3network.setIsBoundToVpn(false); // define is bound to vpn flag as true if NEUTRON_NETWORK_TYPE is PROVIDER @@ -385,16 +363,11 @@ public class AAICreateTasks { */ public void createNetworkCollectionInstanceGroup(BuildingBlockExecution execution) { try { - Boolean alaCarte = execution.getVariable(A_LA_CARTE); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); InstanceGroup instanceGroup = serviceInstance.getCollection().getInstanceGroup(); // set name generated for NetworkCollection/NetworkCollectionInstanceGroup in previous step of the BB flow instanceGroup.setInstanceGroupName(execution.getVariable(NETWORK_COLLECTION_NAME)); - if (Boolean.TRUE.equals(alaCarte) - && aaiInstanceGroupResources.checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName())) { - throw new DuplicateNameException("instance-group", instanceGroup.getInstanceGroupName()); - } // put shell in AAI aaiNetworkResources.createNetworkInstanceGroup(instanceGroup); } catch (Exception ex) { @@ -511,12 +484,7 @@ public class AAICreateTasks { public void createConfiguration(BuildingBlockExecution execution) { try { - Boolean alaCarte = execution.getVariable(A_LA_CARTE); Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID); - if (Boolean.TRUE.equals(alaCarte) - && aaiConfigurationResources.checkConfigurationNameInUse(configuration.getConfigurationName())) { - throw new DuplicateNameException("configuration", configuration.getConfigurationName()); - } aaiConfigurationResources.createConfiguration(configuration); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); @@ -525,14 +493,9 @@ public class AAICreateTasks { public void createInstanceGroupVnf(BuildingBlockExecution execution) { try { - Boolean alaCarte = execution.getVariable(A_LA_CARTE); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID); - if (Boolean.TRUE.equals(alaCarte) - && aaiInstanceGroupResources.checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName())) { - throw new DuplicateNameException("instance-group", instanceGroup.getInstanceGroupName()); - } aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java index 155455e654..ea0b408e41 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java @@ -108,7 +108,7 @@ public class NamingServiceCreateTasks { namingRequestObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE); namingRequestObject.setServiceModelNameValue(serviceInstance.getModelInfoServiceInstance().getModelName()); namingRequestObject.setModelVersionValue(serviceInstance.getModelInfoServiceInstance().getModelVersion()); - namingRequestObject.setNetworkNameValue(execution.getVariable(network.getNetworkName())); + namingRequestObject.setNetworkNameValue(network.getNetworkName()); namingRequestObject.setVpnNameValue(vpnBinding.getVpnName()); namingRequestObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java index b889493d2e..ed3ec759c3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java @@ -60,7 +60,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; -import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.client.aai.entities.uri.AAIResourceUri; @@ -130,14 +129,6 @@ public class AAICreateTasksTest extends BaseTaskTest { } @Test - public void createServiceInstanceNameInUseExceptionTest() throws Exception { - expectedException.expect(BpmnError.class); - doReturn(true).when(aaiServiceInstanceResources).checkInstanceServiceNameInUse(serviceInstance); - execution.setVariable("aLaCarte", Boolean.TRUE); - aaiCreateTasks.createServiceInstance(execution); - } - - @Test public void createServiceInstanceExceptionTest() throws Exception { expectedException.expect(BpmnError.class); @@ -162,14 +153,6 @@ public class AAICreateTasksTest extends BaseTaskTest { } @Test - public void createVolumeGroupDuplicateNameTest() throws Exception { - expectedException.expect(BpmnError.class); - execution.setVariable("aLaCarte", Boolean.TRUE); - doReturn(true).when(aaiVolumeGroupResources).checkNameInUse(volumeGroup); - aaiCreateTasks.createVolumeGroup(execution); - } - - @Test public void createVolumeGroupExceptionTest() throws Exception { expectedException.expect(BpmnError.class); @@ -349,14 +332,6 @@ public class AAICreateTasksTest extends BaseTaskTest { } @Test - public void createVnfDuplicateNameTest() throws Exception { - expectedException.expect(BpmnError.class); - doReturn(true).when(aaiVnfResources).checkNameInUse(genericVnf.getVnfName()); - execution.setVariable("aLaCarte", Boolean.TRUE); - aaiCreateTasks.createVnf(execution); - } - - @Test public void createVnfExceptionTest() throws Exception { expectedException.expect(BpmnError.class); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "notfound"); @@ -386,14 +361,6 @@ public class AAICreateTasksTest extends BaseTaskTest { } @Test - public void createVfModuleDuplicateNameTest() throws Exception { - expectedException.expect(BpmnError.class); - execution.setVariable("aLaCarte", Boolean.TRUE); - doReturn(true).when(aaiVfModuleResources).checkNameInUse(vfModule); - aaiCreateTasks.createVfModule(execution); - } - - @Test public void createServiceSubscriptionTest() { doNothing().when(aaiServiceInstanceResources).createServiceSubscription(customer); aaiCreateTasks.createServiceSubscription(execution); @@ -441,14 +408,6 @@ public class AAICreateTasksTest extends BaseTaskTest { } @Test - public void createNetworkNameInUseExceptionTest() throws Exception { - expectedException.expect(BpmnError.class); - execution.setVariable("aLaCarte", Boolean.TRUE); - doReturn(true).when(aaiNetworkResources).checkNetworkNameInUse(network.getNetworkName()); - aaiCreateTasks.createNetwork(execution); - } - - @Test public void createNetworkExceptionTest() throws Exception { expectedException.expect(BpmnError.class); @@ -560,15 +519,6 @@ public class AAICreateTasksTest extends BaseTaskTest { } @Test - public void createConfigurationNameInUseExceptionTest() throws Exception { - expectedException.expect(BpmnError.class); - doReturn(true).when(aaiConfigurationResources) - .checkConfigurationNameInUse(configuration.getConfigurationName()); - execution.setVariable("aLaCarte", Boolean.TRUE); - aaiCreateTasks.createConfiguration(execution); - } - - @Test public void connectVnfToCloudRegionTest() throws Exception { gBBInput = execution.getGeneralBuildingBlock(); doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion()); @@ -609,15 +559,6 @@ public class AAICreateTasksTest extends BaseTaskTest { } @Test - public void createInstanceGroupVnfNameInUseExceptionTest() throws Exception { - expectedException.expect(BpmnError.class); - doReturn(true).when(aaiInstanceGroupResources) - .checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName()); - execution.setVariable("aLaCarte", Boolean.TRUE); - aaiCreateTasks.createInstanceGroupVnf(execution); - } - - @Test public void createInstanceGroupVnfExceptionTest() throws Exception { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(aaiInstanceGroupResources) diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java index 44e5e0e707..609d2dabd8 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.namingservice.tasks; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; @@ -31,6 +32,7 @@ import static org.mockito.Mockito.when; import java.util.Optional; import org.junit.Before; import org.junit.Test; +import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; @@ -47,6 +49,8 @@ import org.onap.so.client.aai.AAICommonObjectMapperProvider; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.Relationships; import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.namingservice.NamingRequestObject; +import org.onap.so.client.namingservice.NamingServiceConstants; public class NamingServiceCreateTasksTest extends BaseTaskTest { @InjectMocks @@ -106,9 +110,17 @@ public class NamingServiceCreateTasksTest extends BaseTaskTest { String generatedName = "generatedWanTransportServiceName"; doReturn(generatedName).when(namingServiceResources).generateServiceInstanceName(any()); NamingServiceCreateTasks spy = Mockito.spy(namingServiceCreateTasks); + ArgumentCaptor<NamingRequestObject> captor = ArgumentCaptor.forClass(NamingRequestObject.class); spy.createWanTransportServiceName(execution); - verify(namingServiceResources, times(1)).generateServiceInstanceName(any()); + verify(namingServiceResources, times(1)).generateServiceInstanceName(captor.capture()); + assertTrue(captor.getAllValues().get(0).getExternalKeyValue().startsWith("testServiceInstanceId")); + assertEquals(captor.getAllValues().get(0).getNamingTypeValue(), NamingServiceConstants.NAMING_TYPE_SERVICE); + assertEquals(captor.getAllValues().get(0).getResourceNameValue(), + NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME); + assertEquals(captor.getAllValues().get(0).getPolicyInstanceNameValue(), null); + assertTrue(captor.getAllValues().get(0).getServiceModelNameValue().startsWith("testModelName")); + assertTrue(captor.getAllValues().get(0).getModelVersionValue().startsWith("testModelVersion")); assertEquals(generatedName, serviceInstance.getServiceInstanceName()); } @@ -118,10 +130,20 @@ public class NamingServiceCreateTasksTest extends BaseTaskTest { .thenReturn(buildL3Network()); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VPN_ID))) .thenReturn(buildVpnBinding()); + ArgumentCaptor<NamingRequestObject> captor = ArgumentCaptor.forClass(NamingRequestObject.class); String generatedName = "generatedWanTransportServiceName"; doReturn(generatedName).when(namingServiceResources).generateServiceInstanceName(any()); namingServiceCreateTasks.createVpnBondingServiceName(execution); - verify(namingServiceResources, times(1)).generateServiceInstanceName(any()); + verify(namingServiceResources, times(1)).generateServiceInstanceName(captor.capture()); + assertTrue(captor.getAllValues().get(0).getExternalKeyValue().startsWith("testServiceInstanceId")); + assertEquals(captor.getAllValues().get(0).getPolicyInstanceNameValue(), null); + assertEquals(captor.getAllValues().get(0).getNamingTypeValue(), NamingServiceConstants.NAMING_TYPE_SERVICE); + assertTrue(captor.getAllValues().get(0).getServiceModelNameValue().startsWith("testModelName")); + assertTrue(captor.getAllValues().get(0).getModelVersionValue().startsWith("testModelVersion")); + assertTrue(captor.getAllValues().get(0).getNetworkNameValue().startsWith("testNetworkName")); + assertTrue(captor.getAllValues().get(0).getVpnNameValue().startsWith("testVpnName")); + assertEquals(captor.getAllValues().get(0).getResourceNameValue(), + NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME); assertEquals(generatedName, serviceInstance.getServiceInstanceName()); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application-local.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application-local.yaml deleted file mode 100644 index a39d28038c..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application-local.yaml +++ /dev/null @@ -1,179 +0,0 @@ -# will be used as entry in DB to say SITE OFF/ON for healthcheck
-
-server:
- port: 8080
- tomcat:
- max-threads: 50
-ssl-enable: false
-
-apih-healthcheck-urn: /ecomp/mso/healthcheck,/ecomp/mso/homing/healthcheck,/ecomp/mso/infra/healthcheck,/asdc/healthcheck,/dbadapters/healthcheck,/ecomp/mso/catalog/v2/healthcheck
-jra-healthcheck-urn: /networks/rest/healthcheck,/adapters/rest/healthcheck,/vnfs/rest/healthcheck,/tenants/rest/healthcheck,/appc/rest/healthcheck,/workflows/messages/healthcheck
-camunda-healthcheck-urn: /mso/healthcheck
-
-apih-nodehealthcheck-urn: /ecomp/mso/infra/nodehealthcheck
-jra-nodehealthcheck-urn: /adapters/rest/nodehealthcheck
-camunda-nodehealthcheck-urn: /mso/nodehealthcheck
-
-
-
-mso:
- health:
- endpoints:
- catalogdb: http://localhost:8800
- sdnc: http://localhost:8400
- openstack: http://localhost:8300
- requestdb: http://localhost:8700
- bpmn: http://localhost:8200
- asdc: http://localhost:8400
- requestdbattsvc: http://localhost:8600
-
- adapters:
- requestDb:
- auth: Basic YnBlbDptc28tZGItMTUwNyE=
- endpoint: http://localhost:8081
- logPath: logs
- site-name: mtanj
- catalog:
- db:
- spring:
- endpoint: "http://localhost:8080"
- db:
- auth: Basic YnBlbDptc28tZGItMTUwNyE=
- config:
- path: /src/main/resources/
- infra:
- default:
- alacarte:
- orchestrationUri: /mso/async/services/ALaCarteOrchestrator
- recipeTimeout: 180
- testApi: VNF_API
- service:
- macro:
- default:
- testApi: GR_API
- apih:
- homing:
- sdna:
- url: http://localhost:8089/
- password: 4E0BDC08EE8EDC0572ABBE9FD2D59B62DB725A00B8469E39393D6C86D64284C5D34A57D56F7B58C375316F
- camundaURL: http://localhost:8089/
- camundaAuth: E8E19DD16CC90D2E458E8FF9A884CC0452F8F3EB8E321F96038DE38D5C1B0B02DFAE00B88E2CF6E2A4101AB2C011FC161212EE
- async:
- core-pool-size: 50
- max-pool-size: 50
- queue-capacity: 500
- sdc:
- client:
- auth: 97FF88AB352DA16E00DDD81E3876431DEF8744465DACA489EB3B3BE1F10F63EDA1715E626D0A4827A3E19CD88421BF
- activate:
- instanceid: test
- userid: cs0008
- endpoint: http://localhost:28090
- msoKey: 07a7159d3bf51a0e53be7a8f89699be7
- tenant:
- isolation:
- retry:
- count: 3
- aai:
- endpoint: http://localhost:28090
- auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C
- grm:
- endpoint: http://localhost:28090
- username: gmruser
- password: test
- so:
- operational-environment:
- dmaap:
- username: testuser
- password: VjR5NDcxSzA=
- host: http://localhost:28090
- publisher:
- topic: com.att.ecomp.mso.operationalEnvironmentEvent
-
-# controls what actions the infra API (APIH) allows sent in on REST request
-vnf:
- v1:
- ApiAllowableActions:
- v2:
- ApiAllowableActions:
- v3:
- ApiAllowableActions:
-
-network:
- v1:
- ApiAllowableActions:
- v2:
- ApiAllowableActions:
- v3:
- ApiAllowableActions:
-
-volume:
- v1:
- ApiAllowableActions:
- v2:
- ApiAllowableActions:
- v3:
- ApiAllowableActions:
-
-# H2
-spring:
- datasource:
- url: jdbc:h2:mem:AZ;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
- username: sa
- password: sa
- driver-class-name: org.h2.Driver
- intialize: true
- h2:
- console:
- enabled: true
- path: /h2
-
- jpa:
- show-sql: true
- hibernate:
- dialect: org.hibernate.dialect.H2Dialect
- ddl-auto: validate
- naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
- enable_lazy_load_no_trans: true
- jersey:
- type: filter
- security:
- usercredentials:
- -
- username: sitecontrol
- password: '$2a$12$VBUF.qBmeK1FNyO2MqTpD.P2M1tvlesZlhCkAjjHvF9hmYNVdMDmu'
- role: SiteControl-Client
- -
- username: gui
- password: '$2a$12$9Y4daXavh.oX5fz6t/e7TuCdj7EKW5B5ibqq425fN3/xpp0/Fhyti'
- role: GUI-Client
- -
- username: infraportal
- password: '$2a$12$IpUEhQijWTNbq0fGYVkA9upZrDvdIK6QfblIaKAiwi0vBQRE.C6Ri'
- role: InfraPortal-Client
- -
- username: bpel
- password: '$2a$12$1xyutEZNfjGewIZRfKaE8eZE99f5sYFUmmM80BobI65KNjmcK0JuO'
- role: BPEL-Client
- -
- username: mso_admin
- password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa'
- role: ACTUATOR
-request:
- datasource:
- url: jdbc:h2:mem:AZ;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
- username: sa
- password: sa
- driver-class-name: org.h2.Driver
- intialize: true
-
-#Actuator
-management:
- context-path: /manage
-
-org:
- onap:
- so:
- adapters:
- network:
- encryptionKey: aa3871669d893c7fb8abbcda31b88b4f
diff --git a/mso-api-handlers/mso-requests-db-repositories/pom.xml b/mso-api-handlers/mso-requests-db-repositories/pom.xml index f890dabedd..4dbf22cd87 100644 --- a/mso-api-handlers/mso-requests-db-repositories/pom.xml +++ b/mso-api-handlers/mso-requests-db-repositories/pom.xml @@ -30,7 +30,6 @@ <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId> - <optional>true</optional> </dependency> <dependency> <groupId>com.h2database</groupId> diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/configuration/ExposeEntityIdResourceConfiguration.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/configuration/ExposeEntityIdResourceConfiguration.java new file mode 100644 index 0000000000..575e5ff347 --- /dev/null +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/configuration/ExposeEntityIdResourceConfiguration.java @@ -0,0 +1,21 @@ +package org.onap.so.db.request.configuration; + +import org.onap.so.db.request.beans.RequestProcessingData; +import org.springframework.data.rest.core.config.RepositoryRestConfiguration; +import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapter; +import org.springframework.stereotype.Component; + +@Component +public class ExposeEntityIdResourceConfiguration extends RepositoryRestConfigurerAdapter { + + /** + * Spring Data Rest hides the ID by default, in order to have it in the JSON you have to manually configure that for + * your entity + * + * @param config + */ + @Override + public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { + config.exposeIdsFor(RequestProcessingData.class); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index 7a24d14e9b..4d16d9c272 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -354,7 +354,7 @@ public class RequestsDbClient { public void updateRequestProcessingData(RequestProcessingData requestProcessingData) { HttpHeaders headers = getHttpHeaders(); - URI uri = getUri(requestProcessingDataURI); + URI uri = getUri(requestProcessingDataURI + "/" + requestProcessingData.getId()); HttpEntity<RequestProcessingData> entity = new HttpEntity<>(requestProcessingData, headers); restTemplate.put(uri, entity); } diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java new file mode 100644 index 0000000000..fdbc04acb4 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java @@ -0,0 +1,35 @@ +package org.onap.so.db.request.client; + +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.Mockito.times; +import java.net.URI; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.db.request.beans.RequestProcessingData; +import org.springframework.http.HttpEntity; +import org.springframework.web.client.RestTemplate; + + +@RunWith(MockitoJUnitRunner.class) +public class RequestDbClientTest { + + @InjectMocks + protected RequestsDbClient requestsDbClient; + + @Mock + protected RestTemplate restTemplate; + + @Test + public void updateRequestProcessingDataTest() { + RequestProcessingData requestProcessingData = new RequestProcessingData(); + requestProcessingData.setId(1); + URI uri = URI.create("/requestProcessingData/1"); + requestsDbClient.updateRequestProcessingData(requestProcessingData); + Mockito.verify(restTemplate, times(1)).put(eq(uri), isA(HttpEntity.class)); + } +} diff --git a/so-monitoring/readme.md b/so-monitoring/readme.md new file mode 100644 index 0000000000..d4b876c763 --- /dev/null +++ b/so-monitoring/readme.md @@ -0,0 +1,35 @@ +# SO Monitoring + +---- + +## Introduction + +SO Monitoring provides multiple useful features: +* Search/Filtering Menu +* A graphical user interface +* Workflow pathing +* Subflow navigation +* Access to the workflow variables + +## Compiling / Running + +Compiling is simple: `mvn clean install` +Compilation may fail if your code is not formatted properly. + +## Components + +### so-monitoring-handler + + +### so-monitoring-service + +Backend API for so-monitoring. Requires basic auth to access it. + +Default credentials: +- with role GUI-Client: gui/password1$ + +Note that these default users should be changed for production. + +### so-monitoring-ui + +UI for so-monitoring has a separate README.md - so-monitoring/so-monitoring-ui/src/main/frontend/README.md diff --git a/so-monitoring/so-monitoring-service/pom.xml b/so-monitoring/so-monitoring-service/pom.xml index ff70a77239..f5448aaf5c 100644 --- a/so-monitoring/so-monitoring-service/pom.xml +++ b/so-monitoring/so-monitoring-service/pom.xml @@ -64,6 +64,10 @@ <artifactId>spring-boot-configuration-processor</artifactId> <scope>compile</scope> </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-security</artifactId> + </dependency> </dependencies> <build> diff --git a/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/UserController.java b/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/UserController.java new file mode 100644 index 0000000000..3959631f94 --- /dev/null +++ b/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/UserController.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Samsung + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.monitoring.rest.api; + +import java.security.Principal; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class UserController { + + @RequestMapping("/user") + public Principal user(Principal user) { + return user; + } +} diff --git a/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/WebApplicationConfig.java b/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/WebApplicationConfig.java index cadd60b0d9..2b53ed8953 100644 --- a/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/WebApplicationConfig.java +++ b/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/WebApplicationConfig.java @@ -2,7 +2,9 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -21,16 +23,15 @@ package org.onap.so.monitoring.rest.api; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; /** * @author waqas.ikram@ericsson.com */ @Configuration -public class WebApplicationConfig extends WebMvcConfigurerAdapter { +public class WebApplicationConfig implements WebMvcConfigurer { @Override public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); registry.addViewController("/details/**").setViewName("forward:/"); } } diff --git a/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/WebSecurityConfigImpl.java b/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/WebSecurityConfigImpl.java new file mode 100644 index 0000000000..298f52bd35 --- /dev/null +++ b/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/WebSecurityConfigImpl.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Samsung + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.monitoring.rest.api; + +import org.onap.so.security.WebSecurityConfig; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; + +@EnableWebSecurity +@Configuration("att-security-config") +@Order(2) +public class WebSecurityConfigImpl extends WebSecurityConfig { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.authorizeRequests().antMatchers("/actuator", "/actuator/*", "/login", "/", "/index.html", "/*.js", + "/*.js.map", "/favicon.png").permitAll().anyRequest().authenticated().and().httpBasic(); + } +} diff --git a/so-monitoring/so-monitoring-service/src/main/resources/application.yaml b/so-monitoring/so-monitoring-service/src/main/resources/application.yaml index 8235c7480a..347845e422 100644 --- a/so-monitoring/so-monitoring-service/src/main/resources/application.yaml +++ b/so-monitoring/so-monitoring-service/src/main/resources/application.yaml @@ -16,3 +16,10 @@ mso: url: http://so-request-db-adapter.onap:8083/infraActiveRequests/ auth: Basic YnBlbDpwYXNzd29yZDEk +spring: + security: + usercredentials: + - + username: gui + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: GUI-Client diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/README.md b/so-monitoring/so-monitoring-ui/src/main/frontend/README.md index 329de0f833..65731cdc5d 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/README.md +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/README.md @@ -6,6 +6,15 @@ This project was generated with [Angular CLI](https://github.com/angular/angular Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
+FYI: You may need to change environments.ts to hit to your backend: not so-monitoring:30224 but localhost:8088
+
+### Logging in
+
+Backend API for so-monitoring. Requires basic auth to access it.
+
+Default credentials:
+- with role GUI-Client: gui/password1$
+
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/app-routing.module.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/app-routing.module.ts index 428998dc62..03e77fc2d9 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/app-routing.module.ts +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/app-routing.module.ts @@ -2,6 +2,8 @@ ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. All rights reserved. ================================================================================ + Modifications Copyright (c) 2019 Samsung +================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -24,17 +26,25 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { HomeComponent } from './home/home.component'; import { DetailsComponent } from './details/details.component'; +import {AuthGuard} from "./auth.guard"; +import {LoginComponent} from "./login/login.component"; const routes: Routes = [ { // Route to home page path: '', - component: HomeComponent + component: HomeComponent, + canActivate: [AuthGuard] }, { // Route to page to show individual process based on ID path: 'details/:id', component: DetailsComponent + }, + { + // Route to login page + path: 'login', + component: LoginComponent } ]; diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/app.module.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/app.module.ts index 23308639b6..71294bfffe 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/app.module.ts +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/app.module.ts @@ -2,6 +2,8 @@ ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. All rights reserved. ================================================================================ + Modifications Copyright (c) 2019 Samsung +================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -28,7 +30,7 @@ import { AppComponent } from './app.component'; import { SidebarComponent } from './sidebar/sidebar.component'; import { TopbarComponent } from './topbar/topbar.component'; import { HomeComponent } from './home/home.component'; -import { HttpClientModule } from '@angular/common/http'; +import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { DetailsComponent } from './details/details.component'; import { ToastrNotificationService } from './toastr-notification-service.service'; @@ -37,6 +39,9 @@ import { MatFormFieldModule, MatInputModule, MatTableModule, MatTabsModule, MatS import { NgxSpinnerModule } from 'ngx-spinner'; import { RouterModule, Routes } from '@angular/router'; import { APP_BASE_HREF } from '@angular/common'; +import { LoginComponent } from './login/login.component'; +import {BasicAuthInterceptor} from "./basic-auth.interceptor"; +import {ErrorInterceptor} from "./error.interceptor"; @NgModule({ declarations: [ @@ -44,7 +49,8 @@ import { APP_BASE_HREF } from '@angular/common'; SidebarComponent, TopbarComponent, HomeComponent, - DetailsComponent + DetailsComponent, + LoginComponent ], imports: [ BrowserModule, @@ -64,12 +70,16 @@ import { APP_BASE_HREF } from '@angular/common'; RouterModule, MatPaginatorModule, MatSortModule, - RouterModule.forRoot([]) + RouterModule.forRoot([]), + ReactiveFormsModule ], schemas: [ CUSTOM_ELEMENTS_SCHEMA ], - providers: [ToastrNotificationService], + providers: [ + { provide: HTTP_INTERCEPTORS, useClass: BasicAuthInterceptor, multi: true }, + { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true }, + ToastrNotificationService], bootstrap: [AppComponent] }) export class AppModule { } diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/auth.guard.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/auth.guard.ts new file mode 100644 index 0000000000..f437a21710 --- /dev/null +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/auth.guard.ts @@ -0,0 +1,46 @@ +/** + ============LICENSE_START======================================================= + Copyright (C) 2019 Samsung. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= + + @authors: k.kazak@samsung.com + **/ + +import { Injectable } from '@angular/core'; +import {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router} from '@angular/router'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class AuthGuard implements CanActivate { + + constructor(private router:Router) { } + + canActivate( + next: ActivatedRouteSnapshot, + state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean { + if (localStorage.getItem('authdata')) { + // logged in + return true; + } + + // not logged in + this.router.navigate(['/login'], { queryParams: {returnUrl: state.url}}); + return false; + } +} diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/authentication.service.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/authentication.service.ts new file mode 100644 index 0000000000..d7610eed0d --- /dev/null +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/authentication.service.ts @@ -0,0 +1,50 @@ +/** + ============LICENSE_START======================================================= + Copyright (C) 2019 Samsung. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= + + @authors: k.kazak@samsung.com + **/ + +import {Injectable} from '@angular/core'; +import {HttpClient} from "@angular/common/http"; +import {environment} from "../environments/environment"; + +@Injectable({ + providedIn: 'root' +}) +export class AuthenticationService { + + constructor(private http: HttpClient) { + } + + login(username: string, password: string) { + // remove old data from storage + localStorage.removeItem('authdata'); + // add to local storage + var authdata = window.btoa(username + ':' + password); + localStorage.setItem('authdata', authdata); + + // make request + return this.http.get(environment.authBackendURL); + } + + logout() { + // remove from local storage + localStorage.removeItem('authdata'); + } +} diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/basic-auth.interceptor.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/basic-auth.interceptor.ts new file mode 100644 index 0000000000..4990d05ecb --- /dev/null +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/basic-auth.interceptor.ts @@ -0,0 +1,43 @@ +/** + ============LICENSE_START======================================================= + Copyright (C) 2019 Samsung. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= + + @authors: k.kazak@samsung.com + **/ + +import { Injectable } from '@angular/core'; +import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +@Injectable() +export class BasicAuthInterceptor implements HttpInterceptor { + intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { + //add authorization header with basic auth credentials if available + let auth = localStorage.getItem('authdata'); + if (auth) { + const authReq = request.clone({ + headers: request.headers.set('Authorization', 'Basic Z3VpOnBhc3N3b3JkMSQ=') + }); + + // send cloned request with header to the next handler. + return next.handle(authReq); + } + + return next.handle(request); + } +} diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/data.service.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/data.service.ts index b391672728..8dfae3da1e 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/data.service.ts +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/data.service.ts @@ -21,7 +21,7 @@ SPDX-License-Identifier: Apache-2.0 */ import { Injectable } from '@angular/core'; -import { HttpClient, HttpErrorResponse } from '@angular/common/http'; +import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http'; import { BpmnInfraRequest } from './model/bpmnInfraRequest.model'; import { catchError } from 'rxjs/operators'; import { Observable } from 'rxjs'; diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/error.interceptor.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/error.interceptor.ts new file mode 100644 index 0000000000..afe792c80f --- /dev/null +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/error.interceptor.ts @@ -0,0 +1,45 @@ +/** + ============LICENSE_START======================================================= + Copyright (C) 2019 Samsung. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= + + @authors: k.kazak@samsung.com + **/ + +import { Injectable } from '@angular/core'; +import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http'; +import { Observable, throwError } from 'rxjs'; +import { catchError } from 'rxjs/operators'; +import {AuthenticationService} from "./authentication.service"; + +@Injectable() +export class ErrorInterceptor implements HttpInterceptor { + constructor(private authenticationService: AuthenticationService) {} + + intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { + return next.handle(request).pipe(catchError(err => { + if (err.status === 401) { + // auto logout if 401 response returned from api + this.authenticationService.logout(); + location.reload(true); + } + + const error = err.error.message || err.statusText; + return throwError(error); + })) + } +} diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/login/login.component.html b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/login/login.component.html new file mode 100644 index 0000000000..107e1da04a --- /dev/null +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/login/login.component.html @@ -0,0 +1,43 @@ +<!-- +============LICENSE_START======================================================= +Copyright (C) 2019 Samsung. All rights reserved. +================================================================================ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +============LICENSE_END========================================================= + +@authors: k.kazak@samsung.com +--> +<h2>Login</h2> +<form [formGroup]="loginForm" (ngSubmit)="onSubmit()"> + <div class="form-group"> + <label for="username">Username</label> + <input type="text" formControlName="username" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.username.errors }" /> + <div *ngIf="submitted && f.username.errors" class="invalid-feedback"> + <div *ngIf="f.username.errors.required">Username is required</div> + </div> + </div> + <div class="form-group"> + <label for="password">Password</label> + <input type="password" formControlName="password" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.password.errors }" /> + <div *ngIf="submitted && f.password.errors" class="invalid-feedback"> + <div *ngIf="f.password.errors.required">Password is required</div> + </div> + </div> + <div class="form-group"> + <button [disabled]="loading" class="btn btn-primary">Login</button> + <img *ngIf="loading" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" /> + </div> + <div *ngIf="error" class="alert alert-danger">{{error}}</div> +</form> diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/login/login.component.spec.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/login/login.component.spec.ts new file mode 100644 index 0000000000..8cf379d04f --- /dev/null +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/login/login.component.spec.ts @@ -0,0 +1,108 @@ +/** + ============LICENSE_START======================================================= + Copyright (C) 2019 Samsung. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= + + @authors: k.kazak@samsung.com + **/ + +import {async, ComponentFixture, inject, TestBed} from '@angular/core/testing'; + +import {LoginComponent} from './login.component'; +import {AuthenticationService} from "../authentication.service"; +import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core"; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {RouterTestingModule} from "@angular/router/testing"; +import {ActivatedRoute, Router, RouterModule} from "@angular/router"; + +describe('LoginComponent', () => { + // Create SPY Object for Jasmine tests to mock DataService + let spyDataService: jasmine.SpyObj<AuthenticationService>; + let component: LoginComponent; + let fixture: ComponentFixture<LoginComponent>; + let router: Router; + + beforeEach(async(() => { + spyDataService = jasmine.createSpyObj('AuthenticationService', ['login', 'logout']); + + TestBed.configureTestingModule({ + providers: [LoginComponent, + {provide: AuthenticationService, useValue: spyDataService}, + {provide: ActivatedRoute, useValue: { snapshot: {queryParams: { returnUrl: 'test'}}}} + ], + imports: [RouterTestingModule, ReactiveFormsModule, FormsModule, RouterModule.forRoot([])], + declarations: [LoginComponent], + schemas: [ + CUSTOM_ELEMENTS_SCHEMA + ] + }); + + fixture = TestBed.createComponent(LoginComponent); + component = fixture.componentInstance; + router = TestBed.get(Router); + })); + + + it('should create', inject([LoginComponent], + (component: LoginComponent) => { + expect(component).toBeTruthy(); + })); + + it('should logout and route to test directory', inject([LoginComponent], + (component: LoginComponent) => { + component.ngOnInit(); + expect(component.returnUrl).toBe('test'); + })); + + it('should logout and route to root directory', inject([LoginComponent], + (component: LoginComponent) => { + router.initialNavigation(); + component.ngOnInit(); + expect(component.returnUrl).toBe('test'); + })); + + it('should submit without success', inject([LoginComponent], + (component: LoginComponent) => { + component.ngOnInit(); + expect(component.loginForm.valid).toBe(false); + component.onSubmit(); + expect(component.submitted).toBe(true); + })); + + it('should submit without success', inject([LoginComponent], + (component: LoginComponent) => { + component.ngOnInit(); + expect(component.loginForm.valid).toBe(false); + spyDataService.login.and.returnValue(Promise.resolve()); + + let compiled = fixture.debugElement.nativeElement; + let username = compiled.querySelector('input[type="text"]'); + let password = compiled.querySelector('input[type="password"]'); + + fixture.detectChanges(); + + // Change value + username.value = 'test'; + password.value = 'password'; + + // dispatch input event + dispatchEvent(new Event('input')); + + component.onSubmit(); + expect(component.submitted).toBe(true); + })); +}); diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/login/login.component.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/login/login.component.ts new file mode 100644 index 0000000000..4a3f4e6b0f --- /dev/null +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/login/login.component.ts @@ -0,0 +1,81 @@ +/** + ============LICENSE_START======================================================= + Copyright (C) 2019 Samsung. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= + + @authors: k.kazak@samsung.com + **/ + +import { Component, OnInit } from '@angular/core'; +import {FormBuilder, FormGroup, Validators, ReactiveFormsModule} from "@angular/forms"; +import {ActivatedRoute, Router} from "@angular/router"; +import {AuthenticationService} from "../authentication.service"; +import {first} from "rxjs/internal/operators"; + +@Component({ + selector: 'app-login', + templateUrl: './login.component.html', + styleUrls: [] +}) +export class LoginComponent implements OnInit { + + loginForm: FormGroup; + loading = false; + submitted = false; + returnUrl: string; + error = ''; + + constructor(private formBuilder: FormBuilder, + private route: ActivatedRoute, + private router: Router, + private authenticationService: AuthenticationService) { } + + ngOnInit() { + this.loginForm = this.formBuilder.group({ + username: ['', Validators.required], + password: ['', Validators.required] + }); + + // logout + this.authenticationService.logout(); + + this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/'; + } + + // convenience getter for easy access to form fields + get f() { return this.loginForm.controls; } + + onSubmit() { + this.submitted = true; + + // stop here if form is invalid + if (this.loginForm.invalid) { + return; + } + + this.loading = true; + this.authenticationService.login(this.f.username.value, this.f.password.value) + .subscribe( + next => { + this.router.navigate([this.returnUrl]); + }, + error => { + this.error = error; + this.loading = false; + }); + } +} diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/sidebar/sidebar.component.html b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/sidebar/sidebar.component.html index e8b54d7ae3..1c623518c7 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/sidebar/sidebar.component.html +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/sidebar/sidebar.component.html @@ -1,29 +1,34 @@ -<!--
-============LICENSE_START=======================================================
- Copyright (C) 2018 Ericsson. All rights reserved.
-================================================================================
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
- limitations under the License.
-
-SPDX-License-Identifier: Apache-2.0
-============LICENSE_END=========================================================
-
-@authors: ronan.kenny@ericsson.com, waqas.ikram@ericsson.com
--->
-
-<nav>
- <ul>
- <li>
- <a routerLink="/">Home</a>
- </li>
- </ul>
-</nav>
+<!-- +============LICENSE_START======================================================= + Copyright (C) 2018 Ericsson. All rights reserved. +================================================================================ + Modifications Copyright (c) 2019 Samsung +================================================================================ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and + limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +============LICENSE_END========================================================= + +@authors: ronan.kenny@ericsson.com, waqas.ikram@ericsson.com +--> + +<nav> + <ul> + <li> + <a routerLink="/">Home</a> + </li> + <li> + <a routerLink="/login">Logout</a> + </li> + </ul> +</nav> diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts index f0c63fe582..484a156fa9 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts @@ -2,6 +2,8 @@ ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. All rights reserved. ================================================================================ + Modifications Copyright (c) 2019 Samsung +================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -24,5 +26,6 @@ SPDX-License-Identifier: Apache-2.0 export const environment = { production: false, - soMonitoringBackendURL: 'http://so-monitoring:30224/so/monitoring/' + soMonitoringBackendURL: 'http://so-monitoring:30224/so/monitoring/', + authBackendURL: 'http://so-monitoring:30224/user' }; |