diff --git a/build.gradle b/build.gradle index 2d560860b..5b4d7c4f7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ plugins { id 'java' id 'io.freefair.lombok' version '8.14.4' - id 'org.springframework.boot' version '3.3.8' - id 'io.spring.dependency-management' version '1.1.6' + id 'org.springframework.boot' version '3.5.8' + id 'io.spring.dependency-management' version '1.1.7' id 'jacoco' id 'org.sonarqube' version '6.3.1.5724' id 'maven-publish' @@ -12,7 +12,7 @@ group = 'com.iexec.worker' ext { gitTag = 'git tag --points-at HEAD'.execute().text.trim() - springCloudVersion = '2023.0.5' + springCloudVersion = '2025.0.2' commonsMathsVersion = '3.6.1' testContainersVersion = '1.20.4' } diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml deleted file mode 100644 index 13a7c645a..000000000 --- a/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - diff --git a/src/test/java/com/iexec/worker/dataset/DataServiceTests.java b/src/test/java/com/iexec/worker/dataset/DataServiceTests.java index 48eac955e..77ff2a970 100644 --- a/src/test/java/com/iexec/worker/dataset/DataServiceTests.java +++ b/src/test/java/com/iexec/worker/dataset/DataServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2026 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,8 +72,7 @@ private TaskDescription.TaskDescriptionBuilder getTaskDescriptionBuilder() { .chainTaskId(CHAIN_TASK_ID) .datasetUri(HTTP_URI) .datasetChecksum(CHECKSUM) - .datasetAddress(DATASET_ADDRESS) - .isTeeTask(false); + .datasetAddress(DATASET_ADDRESS); } @BeforeEach diff --git a/src/test/java/com/iexec/worker/sms/SmsServiceTests.java b/src/test/java/com/iexec/worker/sms/SmsServiceTests.java index 39cacb76e..bc42060bb 100644 --- a/src/test/java/com/iexec/worker/sms/SmsServiceTests.java +++ b/src/test/java/com/iexec/worker/sms/SmsServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2026 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,11 +27,11 @@ import feign.Request; import feign.RequestTemplate; import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.MockitoAnnotations; +import org.mockito.junit.jupiter.MockitoExtension; import java.util.HashMap; @@ -40,10 +40,10 @@ import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; +@ExtendWith(MockitoExtension.class) class SmsServiceTests { private static final String CHAIN_TASK_ID = "0x1"; - private static final String HASH = "hash"; private static final String TOKEN = "token"; private static final WorkerpoolAuthorization WORKERPOOL_AUTHORIZATION = spy(WorkerpoolAuthorization .builder() @@ -66,17 +66,15 @@ class SmsServiceTests { @InjectMocks private SmsService smsService; - @BeforeEach - void beforeEach() { - MockitoAnnotations.openMocks(this); - doReturn(HASH).when(WORKERPOOL_AUTHORIZATION).getHash(); + void attachSmsUrlToTask() { + smsService.attachSmsUrlToTask(CHAIN_TASK_ID, smsUrl); when(smsClientProvider.getSmsClient(smsUrl)).thenReturn(smsClient); } // region getSmsClient @Test void shouldGetSmsClient() { - smsService.attachSmsUrlToTask(CHAIN_TASK_ID, smsUrl); + attachSmsUrlToTask(); assertThat(smsService.getSmsClient(CHAIN_TASK_ID)).isEqualTo(smsClient); } @@ -90,7 +88,7 @@ void shouldNotAndGetSmsClientIfNoSmsUrlForTask() { // region pushToken @Test void shouldPushToken() { - smsService.attachSmsUrlToTask(CHAIN_TASK_ID, smsUrl); + attachSmsUrlToTask(); // send 404 NOT_FOUND on first call then 204 NO_CONTENT doThrow(FeignException.NotFound.class).doNothing().when(smsClient).isWeb2SecretSet(anyString(), anyString()); when(signerService.signMessageHash(anyString())).thenReturn(new Signature(signature)); @@ -99,7 +97,7 @@ void shouldPushToken() { @Test void shouldUpdateToken() { - smsService.attachSmsUrlToTask(CHAIN_TASK_ID, smsUrl); + attachSmsUrlToTask(); when(signerService.signMessageHash(anyString())).thenReturn(new Signature(signature)); assertThat(smsService.pushToken(WORKERPOOL_AUTHORIZATION, TOKEN)).isTrue(); } @@ -113,7 +111,7 @@ void shouldNotPushTokenOnEmptySignature() { @Test void shouldNotPushTokenOnFeignException() { - smsService.attachSmsUrlToTask(CHAIN_TASK_ID, smsUrl); + attachSmsUrlToTask(); when(signerService.signMessageHash(anyString())).thenReturn(new Signature(signature)); doThrow(FeignException.NotFound.class).when(smsClient).isWeb2SecretSet(anyString(), anyString()); when(smsClient.setWeb2Secret(signature, WORKERPOOL_AUTHORIZATION.getWorkerWallet(), @@ -123,7 +121,7 @@ void shouldNotPushTokenOnFeignException() { @Test void shouldNotUpdateTokenOnFeignException() { - smsService.attachSmsUrlToTask(CHAIN_TASK_ID, smsUrl); + attachSmsUrlToTask(); when(signerService.signMessageHash(anyString())).thenReturn(new Signature(signature)); when(smsClient.updateWeb2Secret(signature, WORKERPOOL_AUTHORIZATION.getWorkerWallet(), IEXEC_RESULT_IEXEC_IPFS_TOKEN, TOKEN)).thenThrow(FeignException.InternalServerError.class); @@ -132,7 +130,7 @@ void shouldNotUpdateTokenOnFeignException() { @Test void shouldNotFindTokenOnFeignException() { - smsService.attachSmsUrlToTask(CHAIN_TASK_ID, smsUrl); + attachSmsUrlToTask(); when(signerService.signMessageHash(anyString())).thenReturn(new Signature(signature)); doThrow(FeignException.class).when(smsClient).isWeb2SecretSet(anyString(), anyString()); assertThat(smsService.pushToken(WORKERPOOL_AUTHORIZATION, TOKEN)).isFalse(); @@ -145,7 +143,7 @@ void shouldCreateTeeSession() throws TeeSessionGenerationException { final Signature signatureStub = new Signature(signature); when(signerService.signMessageHash(WORKERPOOL_AUTHORIZATION.getHash())) .thenReturn(signatureStub); - smsService.attachSmsUrlToTask(CHAIN_TASK_ID, smsUrl); + attachSmsUrlToTask(); when(smsClient.generateTeeSession(signatureStub.getValue(), WORKERPOOL_AUTHORIZATION)) .thenReturn(ApiResponseBody.builder().data(SESSION).build()); @@ -163,11 +161,11 @@ void shouldNotCreateTeeSessionOnFeignException() throws JsonProcessingException final Signature signatureStub = new Signature(signature); when(signerService.signMessageHash(WORKERPOOL_AUTHORIZATION.getHash())) .thenReturn(signatureStub); - smsService.attachSmsUrlToTask(CHAIN_TASK_ID, smsUrl); + attachSmsUrlToTask(); when(smsClient.generateTeeSession(signatureStub.getValue(), WORKERPOOL_AUTHORIZATION)) .thenThrow(new FeignException.InternalServerError("", request, responseBody, null)); - final TeeSessionGenerationException exception = Assertions.catchThrowableOfType(() -> smsService.createTeeSession(WORKERPOOL_AUTHORIZATION), TeeSessionGenerationException.class); + final TeeSessionGenerationException exception = Assertions.catchThrowableOfType(TeeSessionGenerationException.class, () -> smsService.createTeeSession(WORKERPOOL_AUTHORIZATION)); assertThat(exception.getTeeSessionGenerationError()).isEqualTo(TeeSessionGenerationError.NO_SESSION_REQUEST); verify(smsClient).generateTeeSession(signatureStub.getValue(), WORKERPOOL_AUTHORIZATION); }