diff options
Diffstat (limited to 'vid-app-common/src/main')
13 files changed, 275 insertions, 128 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java index 3938b164c..a62076073 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java @@ -48,6 +48,14 @@ public class AaiGetVnfResponse { this.additionalProperties.put(name, value); } + public List<VnfResult> getResults() { + return results; + } + + public void setResults(List<VnfResult> results) { + this.results = results; + } + @Override public String toString() { return MoreObjects.toStringHelper(this) diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java index 6059eec74..d03362ba8 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java @@ -34,7 +34,7 @@ public class SubscriberListWithFilterData { public SubscriberListWithFilterData(SubscriberList subscriberList, RoleValidator roleValidator){ List<Subscriber> subscribers = subscriberList != null ? subscriberList.customer : new ArrayList<>(); - List<SubscriberWithFilter> subscribersWithFilter = new ArrayList<>(); + customer = new ArrayList<>(); for (Subscriber subscriber :subscribers){ SubscriberWithFilter subscriberWithFilter = new SubscriberWithFilter(); subscriberWithFilter.setIsPermitted(roleValidator.isSubscriberPermitted(subscriber.globalCustomerId)); @@ -42,10 +42,9 @@ public class SubscriberListWithFilterData { subscriberWithFilter.resourceVersion = subscriber.resourceVersion; subscriberWithFilter.subscriberName = subscriber.subscriberName; subscriberWithFilter.globalCustomerId = subscriber.globalCustomerId; - subscribersWithFilter.add(subscriberWithFilter); + customer.add(subscriberWithFilter); } - this.customer = subscribersWithFilter; - } + } public List<SubscriberWithFilter> customer; } diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java index c30570d22..d6eb0526f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java @@ -27,20 +27,17 @@ import java.util.List; @JsonIgnoreProperties(ignoreUnknown = true) public class RelationshipList { - + + public List<Relationship> relationship; + @JsonProperty("relationship") public List<Relationship> getRelationship() { return relationship; } - + @JsonProperty("relationship") public void setRelationship(List<Relationship> relationship) { this.relationship = relationship; } - public List<Relationship> relationship; - - - - } diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java index 677602be1..6cbd8cdbf 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java @@ -25,6 +25,7 @@ import com.fasterxml.jackson.annotation.*; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; @JsonInclude(JsonInclude.Include.NON_NULL) @@ -83,4 +84,22 @@ public class VnfResult { public void setJsonAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + VnfResult vnfResult = (VnfResult) o; + return Objects.equals(id, vnfResult.id) && + Objects.equals(nodeType, vnfResult.nodeType) && + Objects.equals(url, vnfResult.url) && + Objects.equals(properties, vnfResult.properties) && + Objects.equals(relatedTo, vnfResult.relatedTo) && + Objects.equals(additionalProperties, vnfResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, nodeType, url, properties, relatedTo, additionalProperties); + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java index 8f53fcdbf..92d8de757 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java @@ -133,7 +133,7 @@ public class AAIRestInterface { * * @param baseURL the base URL */ - public void SetRestSrvrBaseURL(String baseURL) + public void setRestSrvrBaseURL(String baseURL) { if (baseURL == null) { logger.info(EELFLoggerDelegate.errorLogger, "REST Server base URL cannot be null."); diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java index e2a914004..3aff7fea7 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java @@ -3,6 +3,7 @@ * VID * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nokia. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,19 @@ package org.onap.vid.controller; +import static org.onap.vid.utils.Logging.getMethodName; + import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.QueryParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import org.onap.portalsdk.core.controller.RestrictedBaseController; @@ -47,25 +60,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.ModelAndView; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.QueryParam; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; - -import static org.onap.vid.utils.Logging.getMethodName; - /** * Controller to handle a&ai requests. */ @@ -73,35 +76,26 @@ import static org.onap.vid.utils.Logging.getMethodName; @RestController public class AaiController extends RestrictedBaseController { - /** - * The from app id. - */ - private String fromAppId = "VidAaiController"; - /** - * The logger. - */ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(AaiController.class); - /** - * The model. - */ - private Map<String, Object> model = new HashMap<>(); - /** - * The servlet context. - */ - @Autowired - private ServletContext servletContext; - /** - * aai service - */ - @Autowired + private static final String FROM_APP_ID = "VidAaiController"; + private AaiService aaiService; - @Autowired - private RoleProvider roleProvider; - @Autowired private AAIRestInterface aaiRestInterface; - @Autowired + private RoleProvider roleProvider; private SystemPropertiesWrapper systemPropertiesWrapper; + @Autowired + public AaiController(AaiService aaiService, + AAIRestInterface aaiRestInterface, + RoleProvider roleProvider, + SystemPropertiesWrapper systemPropertiesWrapper) { + + this.aaiService = aaiService; + this.aaiRestInterface = aaiRestInterface; + this.roleProvider = roleProvider; + this.systemPropertiesWrapper = systemPropertiesWrapper; + } + /** * Welcome method. * @@ -155,7 +149,7 @@ public class AaiController extends RestrictedBaseController { */ @RequestMapping(value = "/aai_get_services", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<String> doGetServices(HttpServletRequest request) throws IOException { - RoleValidator roleValidator = new RoleValidator(roleProvider.getUserRoles(request)); + RoleValidator roleValidator = RoleValidator.by(roleProvider.getUserRoles(request)); AaiResponse subscriberList = aaiService.getServices(roleValidator); return aaiResponseToResponseEntity(subscriberList); @@ -279,7 +273,7 @@ public class AaiController extends RestrictedBaseController { public ResponseEntity<String> getFullSubscriberList(HttpServletRequest request) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); ResponseEntity<String> responseEntity; - RoleValidator roleValidator = new RoleValidator(roleProvider.getUserRoles(request)); + RoleValidator roleValidator = RoleValidator.by(roleProvider.getUserRoles(request)); SubscriberFilteredResults subscriberList = aaiService.getFullSubscriberList(roleValidator); if (subscriberList.getHttpCode() == 200) { responseEntity = new ResponseEntity<>(objectMapper.writeValueAsString(subscriberList.getSubscriberList()), HttpStatus.OK); @@ -342,7 +336,7 @@ public class AaiController extends RestrictedBaseController { ObjectMapper objectMapper = new ObjectMapper(); ResponseEntity responseEntity; List<Role> roles = roleProvider.getUserRoles(request); - RoleValidator roleValidator = new RoleValidator(roles); + RoleValidator roleValidator = RoleValidator.by(roles); AaiResponse subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator); String httpMessage = subscriberData.getT() != null ? objectMapper.writeValueAsString(subscriberData.getT()) : @@ -371,7 +365,7 @@ public class AaiController extends RestrictedBaseController { ResponseEntity responseEntity; List<Role> roles = roleProvider.getUserRoles(request); - RoleValidator roleValidator = new RoleValidator(roles); + RoleValidator roleValidator = RoleValidator.by(roles); AaiResponse<ServiceInstancesSearchResults> searchResult = aaiService.getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator, owningEntities, projects); @@ -533,7 +527,7 @@ public class AaiController extends RestrictedBaseController { try { ObjectMapper objectMapper = new ObjectMapper(); List<Role> roles = roleProvider.getUserRoles(request); - RoleValidator roleValidator = new RoleValidator(roles); + RoleValidator roleValidator = RoleValidator.by(roles); AaiResponse<GetTenantsResponse[]> response = aaiService.getTenants(globalCustomerId, serviceType, roleValidator); if (response.getHttpCode() == 200) { responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(response.getT()), HttpStatus.OK); @@ -620,7 +614,7 @@ public class AaiController extends RestrictedBaseController { try { - resp = aaiRestInterface.RestGet(fromAppId, transId, Unchecked.toURI(uri), xml).getResponse(); + resp = aaiRestInterface.RestGet(FROM_APP_ID, transId, Unchecked.toURI(uri), xml).getResponse(); } catch (WebApplicationException e) { final String message = e.getResponse().readEntity(String.class); @@ -649,7 +643,7 @@ public class AaiController extends RestrictedBaseController { Response resp = null; try { - resp = aaiRestInterface.RestPost(fromAppId, uri, payload, xml); + resp = aaiRestInterface.RestPost(FROM_APP_ID, uri, payload, xml); } catch (Exception e) { LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + "." + methodName + e.toString()); diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/AlwaysValidRoleValidator.java b/vid-app-common/src/main/java/org/onap/vid/roles/AlwaysValidRoleValidator.java new file mode 100644 index 000000000..4e5340fc2 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/roles/AlwaysValidRoleValidator.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.roles; + +public class AlwaysValidRoleValidator implements RoleValidator { + + AlwaysValidRoleValidator() { + // package visibility, only for RoleValidator's factory + } + + @Override + public boolean isSubscriberPermitted(String subscriberName) { + return true; + } + + @Override + public boolean isServicePermitted(String subscriberName, String serviceType) { + return true; + } + + @Override + public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName) { + return true; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java index d3d2b80e2..6c0fd3f52 100644 --- a/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java +++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java @@ -24,6 +24,14 @@ package org.onap.vid.roles; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import io.joshworks.restclient.http.HttpResponse; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; +import javax.servlet.http.HttpServletRequest; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.web.support.UserUtils; import org.onap.vid.aai.exceptions.RoleParsingException; @@ -34,11 +42,6 @@ import org.onap.vid.services.AaiService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.servlet.http.HttpServletRequest; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; - /** * Created by Oren on 7/1/17. @@ -159,7 +162,7 @@ public class RoleProvider { } public RoleValidator getUserRolesValidator(HttpServletRequest request) { - return new RoleValidator(getUserRoles(request)); + return RoleValidator.by(getUserRoles(request)); } } diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java index 315e22dd7..d37477610 100644 --- a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java +++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java @@ -3,13 +3,14 @@ * VID * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 - 2019 Nokia. 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. @@ -20,70 +21,24 @@ package org.onap.vid.roles; -import org.onap.vid.mso.rest.RequestDetails; - import java.util.List; -import java.util.Map; +import org.apache.commons.lang3.StringUtils; +import org.onap.portalsdk.core.util.SystemProperties; -/** - * Created by Oren on 7/12/17. - */ -public class RoleValidator { +public interface RoleValidator { - private boolean disableRoles = true; - private List<Role> userRoles; + static RoleValidator by(List<Role> roles) { + boolean disableRoles = + StringUtils.equals(SystemProperties.getProperty("role_management_activated"), "false"); - public RoleValidator(List<Role> roles) { - this.userRoles = roles; + return disableRoles + ? new AlwaysValidRoleValidator() + : new RoleValidatorByRoles(roles); } - public boolean isSubscriberPermitted(String subscriberName) { - if (this.disableRoles) return true; - - for (Role role : userRoles) { - if (role.getSubscribeName().equals(subscriberName)) - return true; - } - return false; - } - - public boolean isServicePermitted(String subscriberName, String serviceType) { - if (this.disableRoles) return true; - - for (Role role : userRoles) { - if (role.getSubscribeName().equals(subscriberName) && role.getServiceType().equals(serviceType)) - return true; - } - return false; - } + boolean isSubscriberPermitted(String subscriberName); - public boolean isMsoRequestValid(RequestDetails mso_request) { - if (this.disableRoles) return true; + boolean isServicePermitted(String subscriberName, String serviceType); - try { - String globalSubscriberIdRequested = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("subscriberInfo")).get("globalSubscriberId"); - String serviceType = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("requestParameters")).get("subscriptionServiceType"); - return isServicePermitted(globalSubscriberIdRequested, serviceType); - } catch (Exception e) { - //Until we'll get the exact information regarding the tenants and the global customer id, we'll return true on unknown requests to mso - return true; - } - } - - public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName) { - if (this.disableRoles) return true; - - for (Role role : userRoles) { - if (role.getSubscribeName().equals(globalCustomerId) - && role.getServiceType().equals(serviceType) - && (role.getTenant() == null || role.getTenant().equalsIgnoreCase(tenantName))) { - return true; - } - } - return false; - } - - void enableRoles() { - this.disableRoles = false; - } + boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName); } diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByRoles.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByRoles.java new file mode 100644 index 000000000..ad5b519c4 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByRoles.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.roles; + +import java.util.List; +import java.util.Map; +import org.onap.vid.mso.rest.RequestDetails; + +public class RoleValidatorByRoles implements RoleValidator { + + private final List<Role> userRoles; + + RoleValidatorByRoles(List<Role> roles) { + this.userRoles = roles; + } + + @Override + public boolean isSubscriberPermitted(String subscriberName) { + for (Role role : userRoles) { + if (role.getSubscribeName().equals(subscriberName)) { + return true; + } + } + return false; + } + + @Override + public boolean isServicePermitted(String subscriberName, String serviceType) { + for (Role role : userRoles) { + if (role.getSubscribeName().equals(subscriberName) && role.getServiceType().equals(serviceType)) { + return true; + } + } + return false; + } + + @Override + public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName) { + for (Role role : userRoles) { + if (role.getSubscribeName().equals(globalCustomerId) + && role.getServiceType().equals(serviceType) + && (role.getTenant() == null || role.getTenant().equalsIgnoreCase(tenantName))) { + return true; + } + } + return false; + } + + boolean isMsoRequestValid(RequestDetails msoRequest) { + try { + String globalSubscriberIdRequested = (String) ((Map) ((Map) msoRequest.getAdditionalProperties() + .get("requestDetails")).get("subscriberInfo")).get("globalSubscriberId"); + String serviceType = (String) ((Map) ((Map) msoRequest.getAdditionalProperties().get("requestDetails")) + .get("requestParameters")).get("subscriptionServiceType"); + return isServicePermitted(globalSubscriberIdRequested, serviceType); + } catch (Exception e) { + //Until we'll get the exact information regarding the tenants and the global customer id, we'll return true on unknown requests to mso + return true; + } + } + +} diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js index c4f8f14a9..38096a581 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js @@ -22,9 +22,9 @@ 'use strict'; appDS2.controller("changeManagementManualTasksController", ["$uibModalInstance", "jobInfo", "MsoService", "COMPONENT", - "$log", changeManagementManualTasksController]); + "$log", "moment", changeManagementManualTasksController]); - function changeManagementManualTasksController($uibModalInstance, jobInfo, MsoService, COMPONENT, $log) { + function changeManagementManualTasksController($uibModalInstance, jobInfo, MsoService, COMPONENT, $log, moment) { var vm = this; vm.manualTasks = []; @@ -75,6 +75,33 @@ return vm.manualTasks.includes(task); }; + vm.timeoutHumanized = function() { + // moment.duration() can parse ISO 8601 time-intervals, + // e.g. "P1Y2M10DT2H30M" + // https://en.wikipedia.org/wiki/ISO_8601#Time_intervals + let duration = moment.duration(vm.timeout); + + return isDurationValid() + ? durationAsHoursAndMinutes() + ' hours (' + vm.timeout + ')' + : vm.timeout; + + + function isDurationValid() { + return duration.isValid() && duration.toISOString() !== 'P0D'; + } + + function durationAsHoursAndMinutes() { + return '' + + Math.floor(duration.asHours()) + + ':' + + withLeadingZero(duration.minutes()); + } + + function withLeadingZero(x) { + return ("00" + Math.round(x)).slice(-2); + } + }; + vm.__test_only__ = { loadAvailableTasks: loadAvailableTasks, }; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js index 93bc1c2de..deefca7e1 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js @@ -20,6 +20,7 @@ require('./change-management-manual-tasks.controller'); const jestMock = require('jest-mock'); +const moment = require('moment'); describe('changeManagementManualTasksController testing', () => { let $controller; @@ -41,6 +42,7 @@ describe('changeManagementManualTasksController testing', () => { "MsoService": $MsoService, "$uibModalInstance": $uibModalInstance, "$log": $log, + "moment": moment, "jobInfo": { requestState: job.requestStatus.requestState, details: job.requestStatus.statusMessage, @@ -141,6 +143,26 @@ describe('changeManagementManualTasksController testing', () => { }); }); + test('should humanize timeout if proper ISO-8601', () => { + $controller.timeout = 'PT3350S'; + expect($controller.timeoutHumanized()).toEqual('0:55 hours (PT3350S)'); + }); + + test('should humanize timeout if proper ISO-8601', () => { + $controller.timeout = 'P3DT1H1M'; + expect($controller.timeoutHumanized()).toEqual('73:01 hours (P3DT1H1M)'); + }); + + test('should drive-through timeout if not proper ISO-8601', () => { + $controller.timeout = '56 minutes'; + expect($controller.timeoutHumanized()).toEqual('56 minutes'); + }); + + test('should drive-through timeout if undefined', () => { + $controller.timeout = undefined; + expect($controller.timeoutHumanized()).toEqual(undefined); + }); + test('should find manual task using isTaskAvailable', () => { expect($controller.isTaskAvailable('abort')).toBeTruthy(); expect($controller.isTaskAvailable('resume')).toBeTruthy(); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.html index 099a6ad7b..031146e91 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.html +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.html @@ -20,7 +20,7 @@ <div class="modal-body"> <span id="in-progress-modal-description" ng-if="vm.description">{{vm.description}}</span> - <span id="in-progress-modal-timeout" ng-if="vm.timeout">({{vm.timeout}})</span> + <span id="in-progress-modal-timeout" ng-if="vm.timeout" class="text-danger"><strong>(task will time out in {{vm.timeoutHumanized()}})</strong></span> </div> <div class="modal-footer"> |