Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 21fb4561 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

[URGENT] fix build tests

parent 8d2f7a9a
No related branches found
No related tags found
No related merge requests found
Pipeline #145126 passed with warnings
...@@ -600,12 +600,6 @@ See the Licence for the specific language governing permissions and limitations ...@@ -600,12 +600,6 @@ See the Licence for the specific language governing permissions and limitations
<version>${mockito.version}</version> <version>${mockito.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>junit-jupiter-engine</artifactId>
......
...@@ -61,11 +61,6 @@ ...@@ -61,11 +61,6 @@
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>junit-jupiter-engine</artifactId>
......
...@@ -54,11 +54,6 @@ ...@@ -54,11 +54,6 @@
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>junit-jupiter-engine</artifactId>
......
...@@ -56,11 +56,6 @@ ...@@ -56,11 +56,6 @@
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>junit-jupiter-engine</artifactId>
......
...@@ -29,6 +29,7 @@ import org.junit.jupiter.params.ParameterizedTest; ...@@ -29,6 +29,7 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource; import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
import org.w3c.dom.Document; import org.w3c.dom.Document;
...@@ -48,13 +49,13 @@ import java.nio.file.Paths; ...@@ -48,13 +49,13 @@ import java.nio.file.Paths;
*/ */
@ContextConfiguration(classes = { SmpXmlSignatureService.class}) @ContextConfiguration(classes = { SmpXmlSignatureService.class})
class ServiceMetadataSignerTest extends AbstractJunit5BaseDao{ class ServiceMetadataSignerTest extends AbstractJunit5BaseDao {
Path resourceDirectory = Paths.get("src", "test", "resources", "keystores"); Path resourceDirectory = Paths.get("src", "test", "resources", "keystores");
ConfigurationService configurationService = Mockito.mock(ConfigurationService.class); ConfigurationService configurationService = Mockito.mock(ConfigurationService.class);
@Autowired @SpyBean
UIKeystoreService uiKeystoreService; UIKeystoreService uiKeystoreService;
@Autowired @Autowired
...@@ -62,7 +63,7 @@ class ServiceMetadataSignerTest extends AbstractJunit5BaseDao{ ...@@ -62,7 +63,7 @@ class ServiceMetadataSignerTest extends AbstractJunit5BaseDao{
@BeforeEach @BeforeEach
public void setup(){ public void setup(){
configurationService = Mockito.spy(configurationService);
ReflectionTestUtils.setField(uiKeystoreService,"configurationService",configurationService); ReflectionTestUtils.setField(uiKeystoreService,"configurationService",configurationService);
ReflectionTestUtils.setField(signer,"uiKeystoreService",uiKeystoreService); ReflectionTestUtils.setField(signer,"uiKeystoreService",uiKeystoreService);
...@@ -88,8 +89,7 @@ class ServiceMetadataSignerTest extends AbstractJunit5BaseDao{ ...@@ -88,8 +89,7 @@ class ServiceMetadataSignerTest extends AbstractJunit5BaseDao{
private Element loadAndSignDocumentForAdmin(String filePath) throws Exception { private Element loadAndSignDocumentForAdmin(String filePath) throws Exception {
Document response = SignatureUtil.loadDocument(filePath); Document response = SignatureUtil.loadDocument(filePath);
Element adminSignature = SignatureUtil.findServiceInfoSig(response); return SignatureUtil.findServiceInfoSig(response);
return adminSignature;
} }
@ParameterizedTest @ParameterizedTest
......
...@@ -39,6 +39,7 @@ import java.io.File; ...@@ -39,6 +39,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files;
import java.security.*; import java.security.*;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
...@@ -65,8 +66,6 @@ public class UIKeystoreServiceTest extends AbstractServiceIntegrationTest { ...@@ -65,8 +66,6 @@ public class UIKeystoreServiceTest extends AbstractServiceIntegrationTest {
public void setup() throws IOException { public void setup() throws IOException {
// restore keystore // restore keystore
resetKeystore(); resetKeystore();
configurationService = Mockito.spy(configurationService);
ReflectionTestUtils.setField(testInstance, "configurationService", configurationService); ReflectionTestUtils.setField(testInstance, "configurationService", configurationService);
// set keystore properties // set keystore properties
...@@ -191,9 +190,8 @@ public class UIKeystoreServiceTest extends AbstractServiceIntegrationTest { ...@@ -191,9 +190,8 @@ public class UIKeystoreServiceTest extends AbstractServiceIntegrationTest {
assertNotNull(testInstance.getKey(S_ALIAS)); assertNotNull(testInstance.getKey(S_ALIAS));
testInstance.deleteKey(S_ALIAS); testInstance.deleteKey(S_ALIAS);
//when //when
SMPRuntimeException result = assertThrows(SMPRuntimeException.class, () -> { SMPRuntimeException result = assertThrows(SMPRuntimeException.class,
testInstance.getCert(S_ALIAS); () -> testInstance.getCert(S_ALIAS));
});
MatcherAssert.assertThat(result.getMessage(), MatcherAssert.assertThat(result.getMessage(),
CoreMatchers.containsString("Wrong configuration, missing key pair from keystore or wrong alias: " + S_ALIAS)); CoreMatchers.containsString("Wrong configuration, missing key pair from keystore or wrong alias: " + S_ALIAS));
...@@ -208,9 +206,8 @@ public class UIKeystoreServiceTest extends AbstractServiceIntegrationTest { ...@@ -208,9 +206,8 @@ public class UIKeystoreServiceTest extends AbstractServiceIntegrationTest {
assertNotNull(testInstance.getKey(S_ALIAS)); assertNotNull(testInstance.getKey(S_ALIAS));
testInstance.deleteKey(S_ALIAS); testInstance.deleteKey(S_ALIAS);
//when //when
SMPRuntimeException result = assertThrows(SMPRuntimeException.class, () -> { SMPRuntimeException result = assertThrows(SMPRuntimeException.class,
testInstance.getKey(S_ALIAS); () -> testInstance.getKey(S_ALIAS));
});
MatcherAssert.assertThat(result.getMessage(), MatcherAssert.assertThat(result.getMessage(),
CoreMatchers.containsString("Wrong configuration, missing key pair from keystore or wrong alias: " + S_ALIAS)); CoreMatchers.containsString("Wrong configuration, missing key pair from keystore or wrong alias: " + S_ALIAS));
...@@ -220,8 +217,8 @@ public class UIKeystoreServiceTest extends AbstractServiceIntegrationTest { ...@@ -220,8 +217,8 @@ public class UIKeystoreServiceTest extends AbstractServiceIntegrationTest {
// Load the KeyStore and get the signing key and certificate. // Load the KeyStore and get the signing key and certificate.
File keystoreFilePath = new File(resourceDirectory.toFile(), keystoreName); File keystoreFilePath = new File(resourceDirectory.toFile(), keystoreName);
KeyStore keyStore = null; KeyStore keyStore;
try (InputStream keystoreInputStream = new FileInputStream(keystoreFilePath)) { try (InputStream keystoreInputStream = Files.newInputStream(keystoreFilePath.toPath())) {
keyStore = KeyStore.getInstance(type); keyStore = KeyStore.getInstance(type);
keyStore.load(keystoreInputStream, password.toCharArray()); keyStore.load(keystoreInputStream, password.toCharArray());
} }
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment