Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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'
}
Expand Down
25 changes: 0 additions & 25 deletions src/main/resources/logback-spring.xml

This file was deleted.

5 changes: 2 additions & 3 deletions src/test/java/com/iexec/worker/dataset/DataServiceTests.java
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
32 changes: 15 additions & 17 deletions src/test/java/com/iexec/worker/sms/SmsServiceTests.java
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;

Expand All @@ -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()
Expand All @@ -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);
}

Expand All @@ -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));
Expand All @@ -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();
}
Expand All @@ -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(),
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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.<TeeSessionGenerationResponse, TeeSessionGenerationError>builder().data(SESSION).build());

Expand All @@ -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);
}
Expand Down
Loading