diff options
Diffstat (limited to 'common')
34 files changed, 300 insertions, 162 deletions
diff --git a/common/pom.xml b/common/pom.xml index 4427b3755e..b9fd64e04e 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> </parent> <artifactId>common</artifactId> <name>MSO Common classes</name> @@ -16,13 +16,11 @@ </dependency> <dependency> <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <version>3.1.0</version> + <artifactId>javax.servlet-api</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> - <artifactId>spring-aspects</artifactId> - <version>3.1.2.RELEASE</version> + <artifactId>spring-aspects</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> @@ -34,24 +32,13 @@ </dependency> <dependency> <groupId>com.jayway.jsonpath</groupId> - <artifactId>json-path</artifactId> - <version>2.2.0</version> + <artifactId>json-path</artifactId> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> </dependency> <dependency> - <groupId>org.onap.appc.client</groupId> - <artifactId>client-kit</artifactId> - <version>1.3.0</version> - </dependency> - <dependency> - <groupId>org.onap.appc.client</groupId> - <artifactId>client-lib</artifactId> - <version>1.3.0</version> - </dependency> - <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency> @@ -72,12 +59,10 @@ <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> - </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> - <version>3.4</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> @@ -100,21 +85,11 @@ <artifactId>commons-lang3</artifactId> </exclusion> </exclusions> - </dependency> - <!--for yang decoder --> - <!--<dependency> <groupId>org.opendaylight.yangtools</groupId> <artifactId>yang-data-codec-gson</artifactId> - <version>1.1.1-Carbon</version> </dependency> <dependency> <groupId>org.opendaylight.mdsal</groupId> - <artifactId>mdsal-binding-dom-adapter</artifactId> <version>2.2.1-Carbon</version> - </dependency> <dependency> <groupId>org.opendaylight.mdsal</groupId> <artifactId>mdsal-dom-broker</artifactId> - <version>2.2.1-Carbon</version> </dependency> <dependency> <groupId>org.opendaylight.netconf</groupId> - <artifactId>sal-rest-connector</artifactId> <version>1.5.1-Carbon</version> - </dependency> <dependency> <groupId>org.dom4j</groupId> <artifactId>dom4j</artifactId> - <version>2.0.0</version> </dependency> --> + </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-ext</artifactId> </dependency> - <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> @@ -131,8 +106,7 @@ </dependency> <dependency> <groupId>org.springframework.security</groupId> - <artifactId>spring-security-web</artifactId> - <version>5.0.5.RELEASE</version> + <artifactId>spring-security-web</artifactId> </dependency> <dependency> <groupId>org.onap.logging-analytics</groupId> @@ -140,6 +114,14 @@ <version>1.2.2</version> </dependency> <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + </dependency> + <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> diff --git a/common/src/main/java/org/onap/so/client/HttpClient.java b/common/src/main/java/org/onap/so/client/HttpClient.java index ad13745919..12f19ac607 100644 --- a/common/src/main/java/org/onap/so/client/HttpClient.java +++ b/common/src/main/java/org/onap/so/client/HttpClient.java @@ -7,9 +7,9 @@ * 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. @@ -24,10 +24,15 @@ import java.net.URL; import java.util.Map; import java.util.Optional; +import static org.apache.commons.lang3.StringUtils.*; + import org.onap.so.utils.TargetEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class HttpClient extends RestClient { + protected final Logger log = LoggerFactory.getLogger(HttpClient.class); private TargetEntity targetEntity; public HttpClient(URL host, String contentType, TargetEntity targetEntity) { super(host, contentType); @@ -50,4 +55,34 @@ public class HttpClient extends RestClient { return Optional.empty(); } + /** + * Adds a basic authentication header to the request. + * @param auth the encrypted credentials + * @param key the key for decrypting the credentials + */ + @Override + public void addBasicAuthHeader(String auth, String key) { + if(isNotBlank(auth) && isNotBlank(key)){ + super.addBasicAuthHeader(auth, key); + }else{ + log.warn("Not adding basic auth to headers."); + } + } + + /** + * Adds an additional header to the header map + * @param encoded basic auth value + */ + public void addAdditionalHeader(String name, String value) { + try { + if(isNotBlank(name) && isNotBlank(value)){ + headerMap.put(name, value); + }else{ + log.warn("Not adding " + name + " to headers."); + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + } + } diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java index 1a453c6b2f..76134a42f4 100644 --- a/common/src/main/java/org/onap/so/client/RestClient.java +++ b/common/src/main/java/org/onap/so/client/RestClient.java @@ -7,9 +7,9 @@ * 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. @@ -61,7 +61,7 @@ public abstract class RestClient { private static final String APPLICATION_MERGE_PATCH_JSON = "application/merge-patch+json"; public static final String ECOMP_COMPONENT_NAME = "MSO"; - + private static final int MAX_PAYLOAD_SIZE = 1024 * 1024; private WebTarget webTarget; @@ -76,12 +76,12 @@ public abstract class RestClient { protected RestProperties props; protected RestClient(RestProperties props, Optional<URI> path) { - + headerMap = new HashMap<>(); try { host = props.getEndpoint(); } catch (MalformedURLException e) { - + throw new RuntimeException(e); } this.props = props; @@ -105,23 +105,23 @@ public abstract class RestClient { /** * Override method to return false to disable logging. - * + * * @return true - to enable logging, false otherwise */ protected boolean enableLogging() { return true; } - + /** * Override method to return custom value for max payload size. - * + * * @return Default value for MAX_PAYLOAD_SIZE = 1024 * 1024 */ protected int getMaxPayloadSize() { return MAX_PAYLOAD_SIZE; } - + protected Builder getBuilder() { if (webTarget == null) { @@ -134,7 +134,7 @@ public abstract class RestClient { } return builder; } - + protected WebTarget getWebTarget() { return this.webTarget; } @@ -148,7 +148,7 @@ public abstract class RestClient { protected CommonObjectMapperProvider getCommonObjectMapperProvider() { return new CommonObjectMapperProvider(); } - + /** * Adds a basic authentication header to the request. * @param auth the encrypted credentials @@ -188,7 +188,7 @@ public abstract class RestClient { } CommonObjectMapperProvider provider = this.getCommonObjectMapperProvider(); client.register(new JacksonJsonProvider(provider.getMapper())); - + jaxRsClientLogging = new JaxRsClientLogging(); jaxRsClientLogging.setTargetService(getTargetEntity()); client.register(jaxRsClientLogging); @@ -205,11 +205,11 @@ public abstract class RestClient { this.contentType = MediaType.APPLICATION_JSON; } } - + protected List<Predicate<Throwable>> retryOn() { - + List<Predicate<Throwable>> result = new ArrayList<>(); - + result.add(e -> { return e.getCause() instanceof SocketTimeoutException; }); @@ -266,26 +266,26 @@ public abstract class RestClient { public <T> T delete(Class<T> resultClass) { return format(method("DELETE", null), resultClass).orElse(null); } - + public <T> T delete(Object obj, Class<T> resultClass) { return format(method("DELETE", obj), resultClass).orElse(null); } - + public Response method(String method, Object entity) { RetryPolicy policy = new RetryPolicy(); - + List<Predicate<Throwable>> items = retryOn(); - + Predicate<Throwable> pred = items.stream().reduce(Predicate::or).orElse(x -> false); policy.retryOn(error -> pred.test(error)); - + policy.withDelay(this.props.getDelayBetweenRetries(), TimeUnit.MILLISECONDS) .withMaxRetries(this.props.getRetries()); - + return Failsafe.with(policy).get(buildRequest(method, entity)); } - + protected RestRequest buildRequest(String method, Object entity) { return new RestRequest(this, method, entity); } @@ -295,7 +295,7 @@ public abstract class RestClient { } return Optional.of(response.readEntity(resultClass)); } - + private <T> Optional<T> format(Response response, GenericType<T> resultClass) { if (this.props.mapNotFoundToEmpty() && response.getStatus() == Status.NOT_FOUND.getStatusCode()) { return Optional.empty(); diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java index 0e50818f0f..fbc2801e5e 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java @@ -49,6 +49,7 @@ import org.onap.aai.domain.yang.Pserver; import org.onap.aai.domain.yang.RouteTableReferences; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.ServiceSubscription; +import org.onap.aai.domain.yang.SpPartner; import org.onap.aai.domain.yang.Subnet; import org.onap.aai.domain.yang.Tenant; import org.onap.aai.domain.yang.TunnelXconnect; @@ -108,6 +109,7 @@ public enum AAIObjectType implements GraphInventoryObjectType { CONNECTOR(AAINamespaceConstants.BUSINESS, Connector.class), NETWORK_TECHNOLOGY(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, NetworkTechnology.class), SUBNET(AAIObjectType.L3_NETWORK.uriTemplate(), Subnet.class), + SP_PARTNER(AAINamespaceConstants.BUSINESS, SpPartner.class), EXT_AAI_NETWORK(AAINamespaceConstants.NETWORK, ExtAaiNetwork.class), UNKNOWN("", ""); diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java index 45621f09a6..77ea9bcdfe 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java @@ -26,9 +26,11 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; -import org.apache.log4j.Logger; + import org.onap.so.client.aai.AAICommonObjectMapperProvider; import org.onap.so.jsonpath.JsonPathUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; @@ -39,7 +41,7 @@ public class AAIResultWrapper implements Serializable { private static final long serialVersionUID = 5895841925807816737L; private final String jsonBody; private final ObjectMapper mapper; - private final transient Logger logger = Logger.getLogger(AAIResultWrapper.class); + private final transient Logger logger = LoggerFactory.getLogger(AAIResultWrapper.class); public AAIResultWrapper(String json) { this.jsonBody = json; diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java index 874b06e192..2876f77d82 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java @@ -158,12 +158,8 @@ public class SimpleUri implements GraphInventoryResourceUri, Serializable { protected URI build(Object... values) { //This is a workaround because resteasy does not encode URIs correctly final String[] encoded = new String[values.length]; - for (int i = 0; i < values.length; i++) { - try { - encoded[i] = UriUtils.encode(values[i].toString(), StandardCharsets.UTF_8.toString()); - } catch (UnsupportedEncodingException e) { - encoded[i] = values[i].toString(); - } + for (int i = 0; i < values.length; i++) { + encoded[i] = UriUtils.encode(values[i].toString(), StandardCharsets.UTF_8.toString()); } return internalURI.buildFromEncoded(encoded); } diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java index aeaa923d1b..b4cf8eb949 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java @@ -56,11 +56,7 @@ public class UriParserSpringImpl implements UriParser { final Map<String, String> result = new LinkedHashMap<>(); for (Entry<String, String> entry : map.entrySet()) { - try { - result.put(entry.getKey(), UriUtils.decode(entry.getValue(), "UTF-8")); - } catch (UnsupportedEncodingException e) { - result.put(entry.getKey(), ""); - } + result.put(entry.getKey(), UriUtils.decode(entry.getValue(), "UTF-8")); } return result; diff --git a/common/src/main/java/org/onap/so/constants/Defaults.java b/common/src/main/java/org/onap/so/constants/Defaults.java index 13a378eadb..5117f4de95 100644 --- a/common/src/main/java/org/onap/so/constants/Defaults.java +++ b/common/src/main/java/org/onap/so/constants/Defaults.java @@ -31,7 +31,7 @@ public enum Defaults { private final String propName; private final String defaultValue; - + private Defaults(String propName, String defaultValue) { this.defaultValue = defaultValue; this.propName = propName; diff --git a/common/src/main/java/org/onap/so/logger/LogConstants.java b/common/src/main/java/org/onap/so/logger/LogConstants.java index ea3c8e2c4a..2639adf304 100644 --- a/common/src/main/java/org/onap/so/logger/LogConstants.java +++ b/common/src/main/java/org/onap/so/logger/LogConstants.java @@ -23,4 +23,5 @@ package org.onap.so.logger; public class LogConstants { public static final String TARGET_ENTITY_HEADER="X-Target-Entity"; public static final String UNKNOWN_TARGET_ENTITY="Unknown-Target-Entity"; + public static final String HTTP_URL="Http-Url"; } diff --git a/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java b/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java index 4084ad3ff0..eeb8593725 100644 --- a/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java +++ b/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java @@ -30,6 +30,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.ext.Providers; import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.so.logger.LogConstants; import org.onap.so.logging.jaxrs.filter.MDCSetup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,6 +61,7 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { setRequestId(headers); setInvocationId(headers); setServiceName(request); + setHttpUrl(request); setMDCPartnerName(headers); mdcSetup.setClientIPAddress(request); mdcSetup.setEntryTimeStamp(); @@ -109,7 +111,15 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { protected void setServiceName(HttpServletRequest request) { MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, request.getRequestURI()); } - + + protected void setHttpUrl(HttpServletRequest request) { + String queryParams = ""; + if (request.getQueryString() != null) { + queryParams = "?" + request.getQueryString(); + } + MDC.put(LogConstants.HTTP_URL, request.getRequestURL() + queryParams); + } + protected void setRequestId(Map<String, String> headers) { String requestId=headers.get(ONAPLogConstants.Headers.REQUEST_ID.toLowerCase()); if(requestId == null || requestId.isEmpty()) diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java index 87cb481dec..4dfa1d4130 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java @@ -20,13 +20,12 @@ package org.onap.so.serviceinstancebeans; +import java.beans.Transient; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; -import javax.persistence.Transient; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestReferences.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestReferences.java index c30e39a028..088e414094 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestReferences.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestReferences.java @@ -20,6 +20,8 @@ package org.onap.so.serviceinstancebeans; +import java.net.URL; + import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.annotation.JsonInclude; @@ -32,7 +34,7 @@ public class RequestReferences { String requestId; String instanceId; - + URL requestSelfLink; public String getRequestId() { return requestId; @@ -46,9 +48,15 @@ public class RequestReferences { public void setInstanceId(String instanceId) { this.instanceId = instanceId; } + public URL getRequestSelfLink() { + return requestSelfLink; + } + public void setRequestSelfLink(URL requestSelfLink) { + this.requestSelfLink = requestSelfLink; + } @Override public String toString() { - return new ToStringBuilder(this).append("requestId", requestId).append("instanceId", instanceId).toString(); + return new ToStringBuilder(this).append("requestId", requestId).append("instanceId", instanceId).append("requestSelfLink", requestSelfLink).toString(); } diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java index 527aa037ed..9619a943cd 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java @@ -29,6 +29,7 @@ public class RequestStatus { protected String requestState; protected String statusMessage; + protected String rollbackStatusMessage; protected Integer percentProgress; protected String finishTime; @@ -45,6 +46,12 @@ public class RequestStatus { public void setStatusMessage(String statusMessage) { this.statusMessage = statusMessage; } + public String getRollbackStatusMessage() { + return rollbackStatusMessage; + } + public void setRollbackStatusMessage(String rollbackStatusMessage) { + this.rollbackStatusMessage = rollbackStatusMessage; + } public Integer getPercentProgress() { return percentProgress; } @@ -60,6 +67,7 @@ public class RequestStatus { @Override public String toString() { return new ToStringBuilder(this).append("requestState", requestState).append("statusMessage", statusMessage) - .append("percentProgress", percentProgress).append("finishTime", finishTime).toString(); + .append("rollbackStatusMessage", rollbackStatusMessage).append("percentProgress", percentProgress) + .append("finishTime", finishTime).toString(); } } diff --git a/common/src/main/java/org/onap/so/utils/CryptoUtils.java b/common/src/main/java/org/onap/so/utils/CryptoUtils.java index 11d464a85c..c35ced531d 100644 --- a/common/src/main/java/org/onap/so/utils/CryptoUtils.java +++ b/common/src/main/java/org/onap/so/utils/CryptoUtils.java @@ -21,15 +21,15 @@ package org.onap.so.utils; - -import java.security.GeneralSecurityException; -import java.security.NoSuchAlgorithmException; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; import javax.crypto.Cipher; +import javax.crypto.spec.GCMParameterSpec; import javax.crypto.spec.SecretKeySpec; - -import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; +import java.security.GeneralSecurityException; +import java.security.SecureRandom; +import java.util.Arrays; /** @@ -40,8 +40,12 @@ public final class CryptoUtils { private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, CryptoUtils.class); - public static final String AES = "AES"; + private static final String AES = "AES"; private static final String CLOUD_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + private static final int GCM_TAG_LENGTH = 16; + private static final int GCM_IV_LENGTH = 12; + private static final String AES_GCM_NO_PADDING = "AES/GCM/NoPadding"; + /** * encrypt a value and generate a keyfile * if the keyfile is not found then a new one is created @@ -50,10 +54,16 @@ public final class CryptoUtils { */ public static String encrypt (String value, String keyString) throws GeneralSecurityException { SecretKeySpec sks = getSecretKeySpec (keyString); - Cipher cipher = Cipher.getInstance (CryptoUtils.AES); - cipher.init (Cipher.ENCRYPT_MODE, sks, cipher.getParameters ()); - byte[] encrypted = cipher.doFinal (value.getBytes ()); - return byteArrayToHexString (encrypted); + Cipher cipher = Cipher.getInstance(AES_GCM_NO_PADDING); + byte[] initVector = new byte[GCM_IV_LENGTH]; + (new SecureRandom()).nextBytes(initVector); + GCMParameterSpec spec = new GCMParameterSpec(GCM_TAG_LENGTH * java.lang.Byte.SIZE, initVector); + cipher.init(Cipher.ENCRYPT_MODE, sks, spec); + byte[] encoded = value.getBytes(java.nio.charset.StandardCharsets.UTF_8); + byte[] cipherText = new byte[initVector.length + cipher.getOutputSize(encoded.length)]; + System.arraycopy(initVector, 0, cipherText, 0, initVector.length); + cipher.doFinal(encoded, 0, encoded.length, cipherText, initVector.length); + return byteArrayToHexString(cipherText); } /** @@ -63,29 +73,18 @@ public final class CryptoUtils { */ public static String decrypt (String message, String keyString) throws GeneralSecurityException { SecretKeySpec sks = getSecretKeySpec (keyString); - Cipher cipher = Cipher.getInstance (CryptoUtils.AES); - cipher.init (Cipher.DECRYPT_MODE, sks); - byte[] decrypted = cipher.doFinal (hexStringToByteArray (message)); - return new String (decrypted); + byte[] cipherText = hexStringToByteArray(message); + Cipher cipher = Cipher.getInstance(AES_GCM_NO_PADDING); + byte[] initVector = Arrays.copyOfRange(cipherText, 0, GCM_IV_LENGTH); + GCMParameterSpec spec = new GCMParameterSpec(GCM_TAG_LENGTH * java.lang.Byte.SIZE, initVector); + cipher.init(Cipher.DECRYPT_MODE, sks, spec); + byte[] plaintext = cipher.doFinal(cipherText, GCM_IV_LENGTH, cipherText.length - GCM_IV_LENGTH); + return new String(plaintext); } - - /** - * decrypt a value or return defaultValue - * - */ - public static String decryptProperty (String prop, String defaultValue, String encryptionKey) { - try { - return CryptoUtils.decrypt(prop, encryptionKey); - } - catch (GeneralSecurityException e) { - LOGGER.debug("Security exception", e); - } - return defaultValue; - } public static String encryptCloudConfigPassword(String message) { try { - return CryptoUtils.encrypt(message, CryptoUtils.CLOUD_KEY); + return CryptoUtils.encrypt(message, CLOUD_KEY); } catch (GeneralSecurityException e) { LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in encryptPassword", e); return null; @@ -93,16 +92,15 @@ public final class CryptoUtils { } public static String decryptCloudConfigPassword(String message) { try { - return CryptoUtils.decrypt(message, CryptoUtils.CLOUD_KEY); + return CryptoUtils.decrypt(message, CLOUD_KEY); } catch (GeneralSecurityException e) { LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in encryptPassword", e); return null; } } - private static SecretKeySpec getSecretKeySpec (String keyString) throws NoSuchAlgorithmException { + private static SecretKeySpec getSecretKeySpec (String keyString) { byte[] key = hexStringToByteArray (keyString); - SecretKeySpec sks = new SecretKeySpec (key, CryptoUtils.AES); - return sks; + return new SecretKeySpec (key, AES); } public static String byteArrayToHexString (byte[] b) { diff --git a/common/src/main/java/org/onap/so/utils/TargetEntity.java b/common/src/main/java/org/onap/so/utils/TargetEntity.java index 4d48d349b5..a4480f2d95 100644 --- a/common/src/main/java/org/onap/so/utils/TargetEntity.java +++ b/common/src/main/java/org/onap/so/utils/TargetEntity.java @@ -7,9 +7,9 @@ * 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. @@ -24,14 +24,14 @@ import java.util.EnumSet; public enum TargetEntity { OPENSTACK_ADAPTER, BPMN, GRM ,AAI, DMAAP, POLICY, CATALOG_DB, REQUEST_DB, - VNF_ADAPTER, SDNC_ADAPTER, NARAD, MULTICLOUD; + VNF_ADAPTER, SDNC_ADAPTER, SNIRO, SDC, EXTERNAL, MULTICLOUD; private static final String PREFIX = "SO"; - + public static EnumSet<TargetEntity> getSOInternalComponents() { return EnumSet.of(OPENSTACK_ADAPTER, BPMN,CATALOG_DB,REQUEST_DB,VNF_ADAPTER,SDNC_ADAPTER); } - + @Override public String toString(){ if(getSOInternalComponents().contains(this)) @@ -39,4 +39,4 @@ public enum TargetEntity { else return this.name(); } -}
\ No newline at end of file +} diff --git a/common/src/test/java/org/onap/so/adapter_utils/tests/CryptoTest.java b/common/src/test/java/org/onap/so/adapter_utils/tests/CryptoTest.java index 587e4841d7..418220778a 100644 --- a/common/src/test/java/org/onap/so/adapter_utils/tests/CryptoTest.java +++ b/common/src/test/java/org/onap/so/adapter_utils/tests/CryptoTest.java @@ -71,8 +71,6 @@ public class CryptoTest { String encode2String = CryptoUtils.encrypt(testData, testKey); assertNotNull(encode2String); - assertEquals(encodeString,encode2String); - assertEquals(CryptoUtils.decrypt(encodeString, testKey),CryptoUtils.decrypt(encode2String, testKey)); encodeString = CryptoUtils.encryptCloudConfigPassword(testData); diff --git a/common/src/test/java/org/onap/so/client/HttpClientTest.java b/common/src/test/java/org/onap/so/client/HttpClientTest.java new file mode 100644 index 0000000000..221005cb7c --- /dev/null +++ b/common/src/test/java/org/onap/so/client/HttpClientTest.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.exactly; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.verify; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.junit.Rule; +import org.junit.Test; +import org.onap.so.utils.TargetEntity; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; + +public class HttpClientTest{ + + + @Rule + public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicHttpsPort()); + + @Test(expected = Test.None.class) + public void testPost_success() throws MalformedURLException{ + + stubFor(post(urlEqualTo("/services/sdnc/post")) + .willReturn(aResponse().withStatus(200) + .withHeader("Content-Type", "application/json") + .withBody(""))); + + URL url = new URL("http://localhost:" + wireMockConfig().portNumber() + "/services/sdnc/post"); + HttpClient client = new HttpClient(url, "application/json", TargetEntity.BPMN); + + client.addBasicAuthHeader("97FF88AB352DA16E00DDD81E3876431DEF8744465DACA489EB3B3BE1F10F63EDA1715E626D0A4827A3E19CD88421BF", "123"); + client.addAdditionalHeader("Accept", "application/json"); + + client.post("{}"); + + verify(exactly(1), postRequestedFor(urlEqualTo("/services/sdnc/post"))); + } + + @Test(expected = Test.None.class) + public void testPost_nullHeader() throws MalformedURLException{ + + stubFor(post(urlEqualTo("/services/sdnc/post")) + .willReturn(aResponse().withStatus(200) + .withHeader("Content-Type", "application/json") + .withBody(""))); + + URL url = new URL("http://localhost:" + wireMockConfig().portNumber() + "/services/sdnc/post"); + HttpClient client = new HttpClient(url, "application/json", TargetEntity.BPMN); + + client.addAdditionalHeader("Accept", "application/json"); + client.addAdditionalHeader("id", null); + + client.post("{}"); + + verify(exactly(1), postRequestedFor(urlEqualTo("/services/sdnc/post")) + .withHeader("Accept", equalTo("application/json"))); + } + + @Test(expected = Test.None.class) + public void testPost_nullBasicAuth() throws MalformedURLException{ + + stubFor(post(urlEqualTo("/services/sdnc/post")) + .willReturn(aResponse().withStatus(200) + .withHeader("Content-Type", "application/json") + .withBody(""))); + + URL url = new URL("http://localhost:" + wireMockConfig().portNumber() + "/services/sdnc/post"); + HttpClient client = new HttpClient(url, "application/json", TargetEntity.BPMN); + + client.addBasicAuthHeader("", "12345"); + client.addAdditionalHeader("Accept", "application/json"); + + client.post("{}"); + + verify(exactly(1), postRequestedFor(urlEqualTo("/services/sdnc/post")) + .withHeader("Accept", equalTo("application/json"))); + } + +} diff --git a/common/src/test/java/org/onap/so/client/RestClientTest.java b/common/src/test/java/org/onap/so/client/RestClientTest.java index 1443f04f3a..6fca4a1820 100644 --- a/common/src/test/java/org/onap/so/client/RestClientTest.java +++ b/common/src/test/java/org/onap/so/client/RestClientTest.java @@ -20,7 +20,8 @@ package org.onap.so.client; -import static org.mockito.Matchers.any; + +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -39,8 +40,9 @@ import javax.ws.rs.core.UriBuilderException; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.ArgumentMatchers; import org.onap.so.utils.TargetEntity; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class RestClientTest { @@ -55,7 +57,7 @@ public class RestClientTest { RestClient spy = buildSpy(); RestRequest mockCallable = mock(RestRequest.class); when(mockCallable.call()).thenThrow(new WebApplicationException(new SocketTimeoutException())); - doReturn(mockCallable).when(spy).buildRequest(any(String.class), any(Object.class)); + doReturn(mockCallable).when(spy).buildRequest(any(String.class), ArgumentMatchers.isNull()); try { spy.get(); } catch (Exception e) { @@ -70,7 +72,7 @@ public class RestClientTest { RestClient spy = buildSpy(); RestRequest mockCallable = mock(RestRequest.class); when(mockCallable.call()).thenThrow(new WebApplicationException(new NotFoundException())); - doReturn(mockCallable).when(spy).buildRequest(any(String.class), any(Object.class)); + doReturn(mockCallable).when(spy).buildRequest(any(String.class), ArgumentMatchers.isNull()); try { spy.get(); } catch (Exception e) { diff --git a/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java index 40410019f0..f30d2e17aa 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java @@ -25,7 +25,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; @@ -34,13 +34,12 @@ import static org.mockito.Mockito.verify; import java.util.Optional; import java.util.UUID; -import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.client.aai.entities.Configuration; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUri; diff --git a/common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java b/common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java index 008b612cd8..0cee366679 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java @@ -33,7 +33,7 @@ import java.util.HashMap; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.GenericVnf; import com.fasterxml.jackson.core.JsonParseException; @@ -72,9 +72,10 @@ public class AAIPatchConverterTest { AAIPatchConverter validator = new AAIPatchConverter(); HashMap<String, String> map = new HashMap<>(); map.put("ipv4-loopback0-address", ""); + map.put("ipv4-loopback1-address", "192.168.1.1"); String result = validator.marshallObjectToPatchFormat(map); - assertEquals("expect string", "{\"ipv4-loopback0-address\":\"\"}", result); + assertEquals("expect string", "{\"ipv4-loopback1-address\":\"192.168.1.1\"}", result); } @Test diff --git a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java index 6e9c38517d..f4b6141b0a 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java @@ -22,7 +22,7 @@ package org.onap.so.client.aai; import static org.junit.Assert.assertNotNull; import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -39,7 +39,7 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.client.RestClient; import org.onap.so.client.aai.entities.CustomQuery; import org.onap.so.client.aai.entities.uri.AAIResourceUri; diff --git a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java index 22dc1cac30..32a9ca54a8 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java @@ -96,7 +96,7 @@ public class AAIResourcesClientTest { AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); wireMockRule.stubFor(get( urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString())) - .withHeader("Authorization", equalTo("Basic TVNPOk1TTw==")) + .withHeader("Authorization", equalTo("Basic dGVzdDp0ZXN0")) .willReturn( aResponse() .withHeader("Content-Type", "application/json") diff --git a/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java index 752c49eb5b..6abeea9d9b 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java @@ -21,7 +21,7 @@ package org.onap.so.client.aai; import static org.hamcrest.CoreMatchers.containsString; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -39,7 +39,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.client.RestClientSSL; import org.onap.so.client.graphinventory.exceptions.GraphInventoryPatchDepthExceededException; diff --git a/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java index 8c42686e5f..428fa276db 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java @@ -23,7 +23,7 @@ package org.onap.so.client.aai; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -35,6 +35,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.Optional; +import org.json.JSONException; import org.junit.Before; import org.junit.Test; import org.onap.aai.domain.yang.Pserver; @@ -66,7 +67,7 @@ public class AAISingleTransactionClientTest { } @Test - public void testRequest() throws IOException { + public void testRequest() throws JSONException,IOException { AAIResourcesClient client = createClient(); Pserver pserver = new Pserver(); pserver.setHostname("pserver-hostname"); diff --git a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java index cbf8d67a82..621375882b 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java @@ -21,7 +21,7 @@ package org.onap.so.client.aai; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; diff --git a/common/src/test/java/org/onap/so/client/aai/AAIUpdatorTest.java b/common/src/test/java/org/onap/so/client/aai/AAIUpdatorTest.java index fddd1e63ba..8989d6d696 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIUpdatorTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIUpdatorTest.java @@ -20,7 +20,7 @@ package org.onap.so.client.aai; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -28,7 +28,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class AAIUpdatorTest { diff --git a/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java b/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java index a2de528d9f..63c7290065 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java @@ -30,7 +30,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Pserver; diff --git a/common/src/test/java/org/onap/so/client/aai/entities/AAIResultWrapperTest.java b/common/src/test/java/org/onap/so/client/aai/entities/AAIResultWrapperTest.java index d4bf1b0224..324be0114d 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/AAIResultWrapperTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/AAIResultWrapperTest.java @@ -35,7 +35,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.GenericVnf; import org.onap.so.client.aai.AAICommonObjectMapperProvider; import org.springframework.util.SerializationUtils; diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUriTest.java index 71ec49789e..0d2da3339a 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUriTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/AllottedResourceLookupUriTest.java @@ -21,7 +21,7 @@ package org.onap.so.client.aai.entities.uri; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java index 26f9d871fd..7e70f2d5f4 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java @@ -29,7 +29,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.collection.IsIterableContainingInOrder.contains; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -181,10 +181,6 @@ public class ServiceInstanceUriTest { ServiceInstanceUri spy = spy(instance); AAIResourcesClient client = createClient(); doReturn(client).when(spy).getResourcesClient(); - /*AAIResultWrapper wrapper = mock(AAIResultWrapper.class); - when(client.get(Matchers.<AAIResourceUri>any(AAIResourceUri.class), Matchers.<Class<NotFoundException>>any())).thenReturn(wrapper); - when(wrapper.getJson()).thenReturn("{\"results\":[]}"); - doReturn(client).when(spy).getResourcesClient();*/ stubFor(get(urlPathMatching("/aai/v[0-9]+/nodes/service-instances/service-instance/key3")) .willReturn(aResponse() .withStatus(404) diff --git a/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java b/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java index 7b783762fa..388e89a438 100644 --- a/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java +++ b/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java @@ -21,44 +21,43 @@ package org.onap.so.client.grm; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.matching; import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static com.github.tomakehurst.wiremock.client.WireMock.*; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; + import java.io.File; import java.nio.file.Files; -import java.util.ArrayList; import java.util.List; import java.util.Map; import javax.ws.rs.core.MediaType; -import ch.qos.logback.classic.spi.ILoggingEvent; -import org.apache.log4j.MDC; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.client.grm.beans.OperationalInfo; -import org.onap.so.client.grm.beans.Property; import org.onap.so.client.grm.beans.ServiceEndPoint; import org.onap.so.client.grm.beans.ServiceEndPointList; import org.onap.so.client.grm.beans.ServiceEndPointLookupRequest; import org.onap.so.client.grm.beans.ServiceEndPointRequest; -import org.onap.so.client.grm.beans.Version; import org.onap.so.client.grm.exceptions.GRMClientCallFailed; +import org.onap.so.utils.TestAppender; +import org.slf4j.MDC; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.junit.WireMockRule; -import org.onap.so.utils.TestAppender; +import ch.qos.logback.classic.spi.ILoggingEvent; public class GRMClientTest { @@ -75,8 +74,6 @@ public class GRMClientTest { System.setProperty("mso.config.path", "src/test/resources"); } - private ObjectMapper mapper = new ObjectMapper(); - @Test public void testFind() throws Exception { TestAppender.events.clear(); diff --git a/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java b/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java index 4cb9bd0e16..46f9de2268 100644 --- a/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java +++ b/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java @@ -23,9 +23,9 @@ package org.onap.so.client.policy; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import java.io.File; import java.io.IOException; diff --git a/common/src/test/java/org/onap/so/client/sdno/SDNOValidatorTest.java b/common/src/test/java/org/onap/so/client/sdno/SDNOValidatorTest.java index 89dd2f554f..d66f5f64f7 100644 --- a/common/src/test/java/org/onap/so/client/sdno/SDNOValidatorTest.java +++ b/common/src/test/java/org/onap/so/client/sdno/SDNOValidatorTest.java @@ -21,7 +21,7 @@ package org.onap.so.client.sdno; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; diff --git a/common/src/test/resources/aai.properties b/common/src/test/resources/aai.properties index 897659b332..2936e841bb 100644 --- a/common/src/test/resources/aai.properties +++ b/common/src/test/resources/aai.properties @@ -1,3 +1,3 @@ aai.endpoint=http://localhost:8443 -aai.auth=2630606608347B7124C244AB0FE34F6F +aai.auth=5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C mso.msoKey=07a7159d3bf51a0e53be7a8f89699be7
\ No newline at end of file |