import org.onap.vid.mso.rest.MsoRestClientNew;
import org.onap.vid.services.CloudOwnerService;
import org.onap.vid.services.CloudOwnerServiceImpl;
+import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.togglz.core.manager.FeatureManager;
}
@Bean
- public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper, HttpsAuthClient httpsAuthClient){
+ public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper, HttpsAuthClient httpsAuthClient, SystemPropertiesWrapper systemPropertiesWrapper){
// Satisfy both interfaces -- MsoInterface and RestMsoImplementation
return new MsoRestClientNew(new SyncRestClient(unirestObjectMapper), SystemProperties.getProperty(
- MsoProperties.MSO_SERVER_URL),httpsAuthClient);
+ MsoProperties.MSO_SERVER_URL),httpsAuthClient, systemPropertiesWrapper);
}
import org.apache.http.HttpException;
import org.eclipse.jetty.util.security.Password;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.aai.ExceptionWithRequestInfo;
import org.onap.vid.aai.util.HttpClientMode;
import org.onap.vid.aai.util.HttpsAuthClient;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.mso.rest.RestInterface;
import org.onap.vid.utils.Logging;
+import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
protected HttpsAuthClient httpsAuthClient;
+ protected SystemPropertiesWrapper systemProperties;
private static final String START_LOG = " start";
private static final String APPLICATION_JSON = "application/json";
*/
@Autowired
- protected RestMsoImplementation(HttpsAuthClient httpsAuthClient){
+ protected RestMsoImplementation(HttpsAuthClient httpsAuthClient, SystemPropertiesWrapper systemProperties){
this.httpsAuthClient=httpsAuthClient;
+ this.systemProperties = systemProperties;
}
@SuppressWarnings("Duplicates")
{
final String methodname = "initRestClient()";
- final String username = SystemProperties.getProperty(MsoProperties.MSO_USER_NAME);
- final String password = SystemProperties.getProperty(MsoProperties.MSO_PASSWORD);
- final String mso_url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL);
+ final String username = systemProperties.getProperty(MsoProperties.MSO_USER_NAME);
+ final String password = systemProperties.getProperty(MsoProperties.MSO_PASSWORD);
+ final String mso_url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL);
final String decrypted_password = Password.deobfuscate(password);
String authString = username + ":" + decrypted_password;
try {
restObject.set(t);
- url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
final String methodName = getMethodName();
logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {})", getMethodCallerName(), methodName, path, clazz);
- String url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ String url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
logger.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + " sending request to url= " + url);
MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
try {
MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
- url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
Logging.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url, r);
cres = client.target(url)
.request()
public Invocation.Builder prepareClient(String path, String methodName) {
MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
- String url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ String url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + " sending request to url= " + url);
// Change the content length
return client.target(url)
MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
userId.ifPresent(id->commonHeaders.put("X-RequestorID", Collections.singletonList(id)));
- url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
Logging.logRequest(outgoingRequestsLogger, httpMethod, url, payload);
// Change the content length
final Invocation.Builder restBuilder = client.target(url)
MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
- url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
Logging.logRequest(outgoingRequestsLogger, HttpMethod.PUT, url, r);
// Change the content length
final Response cres = client.target(url)
import org.onap.vid.mso.RestMsoImplementation;
import org.onap.vid.mso.RestObject;
import org.onap.vid.utils.Logging;
+import org.onap.vid.utils.SystemPropertiesWrapper;
/**
*/
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestClientNew.class);
- public MsoRestClientNew(SyncRestClient client, String baseUrl, HttpsAuthClient authClient) {
- super(authClient);
+ public MsoRestClientNew(SyncRestClient client, String baseUrl, HttpsAuthClient authClient, SystemPropertiesWrapper systemPropertiesWrapper) {
+ super(authClient,systemPropertiesWrapper);
this.client = client;
this.baseUrl = baseUrl;
this.commonHeaders = initCommonHeaders();
}
private Map<String, String> initCommonHeaders() {
- String username = SystemProperties.getProperty(MsoProperties.MSO_USER_NAME);
- String password = SystemProperties.getProperty(MsoProperties.MSO_PASSWORD);
+ String username = systemProperties.getProperty(MsoProperties.MSO_USER_NAME);
+ String password = systemProperties.getProperty(MsoProperties.MSO_PASSWORD);
String decrypted_password = Password.deobfuscate(password);
String authString = username + ":" + decrypted_password;
map.put(HttpHeaders.AUTHORIZATION, "Basic " + authStringEnc);
map.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
- map.put(X_FROM_APP_ID, SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME));
+ map.put(X_FROM_APP_ID, systemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME));
map.put(SystemProperties.ECOMP_REQUEST_ID, Logging.extractOrGenerateRequestId());
return ImmutableMap.copyOf(map);
}
import org.glassfish.jersey.client.JerseyInvocation;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.aai.util.HttpsAuthClient;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.mso.rest.RequestDetails;
+import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
@Mock
private JerseyInvocation jerseyInvocation;
+ @Mock
+ private SystemPropertiesWrapper systemProperties;
+
@InjectMocks
- private RestMsoImplementation restMsoImplementation = new RestMsoImplementation(mockHttpsAuthClient);
+ private RestMsoImplementation restMsoImplementation = new RestMsoImplementation(mockHttpsAuthClient, systemProperties);
- String path = "/test_path/";
- String rawData = "test-row-data";
+ private String path = "/test_path/";
+ private String rawData = "test-row-data";
@BeforeClass
public void setUp(){
initMocks(this);
+ when(systemProperties.getProperty(MsoProperties.MSO_PASSWORD)).thenReturn("OBF:1ghz1kfx1j1w1m7w1i271e8q1eas1hzj1m4i1iyy1kch1gdz");
}
@Test
RestObject<HttpRequest> restObject = new RestObject<>();
prepareMocks("",HttpStatus.ACCEPTED.value(),"");
- when(mockClient.target(SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL))).thenThrow(new MsoTestException("test-target-exception"));
+ when(systemProperties.getProperty(MsoProperties.MSO_SERVER_URL)).thenReturn("SAMPLE_URL");
+ when(mockClient.target("SAMPLE_URL")).thenThrow(new MsoTestException("test-target-exception"));
// when
restMsoImplementation.Get(httpRequest, "", restObject,false);
}
}
-}
\ No newline at end of file
+}
import org.onap.vid.mso.MsoResponseWrapper;
import org.onap.vid.mso.MsoResponseWrapperInterface;
import org.onap.vid.mso.RestObject;
+import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.test.context.ContextConfiguration;
@ContextConfiguration(classes = {SystemProperties.class})
private MsoRestClientNew msoRestClient() {
final WebConfig webConfig = new WebConfig();
- return new MsoRestClientNew(new SyncRestClient(webConfig.unirestFasterxmlObjectMapper(new ObjectMapper())), baseUrl(),null);
+ return new MsoRestClientNew(new SyncRestClient(webConfig.unirestFasterxmlObjectMapper(new ObjectMapper())), baseUrl(), null, new SystemPropertiesWrapper());
}
private MsoRestClientNew createTestSubject() {
- return new MsoRestClientNew(null, "",null);
+ return new MsoRestClientNew(null, "", null, new SystemPropertiesWrapper());
}
}
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.controller.LocalWebConfig;
import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.mso.MsoProperties;
import org.onap.vid.mso.MsoResponseWrapper;
import org.onap.vid.mso.MsoResponseWrapperInterface;
import org.onap.vid.mso.MsoUtil;
import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.model.CloudConfiguration;
import org.onap.vid.mso.model.RequestReferences;
+import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.web.WebAppConfiguration;
import org.testng.annotations.BeforeClass;
@Mock
private SyncRestClient client;
+ @Mock
+ private SystemPropertiesWrapper systemProperties;
private MsoRestClientNew restClient;
@BeforeClass
private void setUp(){
initMocks(this);
- restClient = new MsoRestClientNew(client,baseUrl,null);
-
+ when(systemProperties.getProperty(MsoProperties.MSO_PASSWORD)).thenReturn("OBF:1ghz1kfx1j1w1m7w1i271e8q1eas1hzj1m4i1iyy1kch1gdz");
+ when(systemProperties.getProperty("app_display_name")).thenReturn("vid");
+ restClient = new MsoRestClientNew(client,baseUrl,null,systemProperties);
}
@Test