aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManager.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManagerTest.java13
2 files changed, 10 insertions, 15 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManager.java
index 53c2e1d0bc..6fae6f0e72 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManager.java
@@ -86,7 +86,13 @@ public class SecurityManager {
}
private SecurityManager() {
- certificateDirectory = this.getcertDirectory();
+ certificateDirectory = this.getcertDirectory(System.getenv("SDC_CERT_DIR"));
+ }
+
+
+ // Package level constructor use in tests to avoid power mock
+ SecurityManager(String sdcCertDir) {
+ certificateDirectory = this.getcertDirectory(sdcCertDir);
}
public static SecurityManager getInstance() {
@@ -193,8 +199,8 @@ public class SecurityManager {
}
}
- private File getcertDirectory() {
- String certDirLocation = System.getenv("SDC_CERT_DIR");
+ private File getcertDirectory(String sdcCertDir) {
+ String certDirLocation = sdcCertDir;
if (certDirLocation == null) {
certDirLocation = CERTIFICATE_DEFAULT_LOCATION;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManagerTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManagerTest.java
index b1d6fdc97d..7c5cb662c7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManagerTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManagerTest.java
@@ -24,11 +24,6 @@ import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
import java.io.File;
import java.io.IOException;
@@ -38,11 +33,7 @@ import java.nio.file.Paths;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;
-import static org.mockito.ArgumentMatchers.eq;
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(SecurityManager.class)
-@PowerMockIgnore("javax.security.auth.x500.X500Principal")
public class SecurityManagerTest {
private File certDir;
private SecurityManager securityManager;
@@ -54,9 +45,7 @@ public class SecurityManagerTest {
tearDown();
}
certDir.mkdirs();
- PowerMockito.mockStatic(System.class);
- PowerMockito.when(System.getenv(eq("SDC_CERT_DIR"))).thenReturn(certDir.getPath());
- securityManager = SecurityManager.getInstance();
+ securityManager = new SecurityManager(certDir.getPath());
}
@After