diff --git a/gradle.properties b/gradle.properties index 6fc953e..dff8d7b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ # x-release-please-start-version version=9.0.0 # x-release-please-end -iexecCommonVersion=9.0.0 -iexecCommonsPocoVersion=5.0.0 +iexecCommonsPocoVersion=5.3.1 +iexecCommonVersion=9.2.0 nexusUser nexusPassword diff --git a/src/main/java/com/iexec/resultproxy/authorization/AuthorizationService.java b/src/main/java/com/iexec/resultproxy/authorization/AuthorizationService.java index 8ef65a3..a7b7daf 100644 --- a/src/main/java/com/iexec/resultproxy/authorization/AuthorizationService.java +++ b/src/main/java/com/iexec/resultproxy/authorization/AuthorizationService.java @@ -92,7 +92,7 @@ public Optional isAuthorizedOnExecutionWithDetailedIssue(fin } final boolean isTeeTask = !workerpoolAuthorization.getEnclaveChallenge().equals(BytesUtils.EMPTY_ADDRESS); - final boolean isTeeTaskOnchain = TeeUtils.isTeeTag(chainDeal.getTag()); + final boolean isTeeTaskOnchain = TeeUtils.getTeeFramework(chainDeal.getTag()) != null; if (isTeeTask != isTeeTaskOnchain) { log.error("Could not match on-chain task type [isTeeTask:{}, isTeeTaskOnchain:{}, chainTaskId:{}, walletAddress:{}]", isTeeTask, isTeeTaskOnchain, chainTaskId, workerpoolAuthorization.getWorkerWallet()); diff --git a/src/main/java/com/iexec/resultproxy/proxy/ProxyService.java b/src/main/java/com/iexec/resultproxy/proxy/ProxyService.java index c5455a1..587b113 100644 --- a/src/main/java/com/iexec/resultproxy/proxy/ProxyService.java +++ b/src/main/java/com/iexec/resultproxy/proxy/ProxyService.java @@ -103,7 +103,7 @@ boolean canUploadResult(ResultModel model, String walletAddress) { return false; } - final boolean isTeeTask = TeeUtils.isTeeTag(chainDeal.getTag()); + final boolean isTeeTask = TeeUtils.getTeeFramework(chainDeal.getTag()) != null; // Standard tasks if (!isTeeTask) { diff --git a/src/main/java/com/iexec/resultproxy/result/Result.java b/src/main/java/com/iexec/resultproxy/result/Result.java index f96c542..f1d0c75 100644 --- a/src/main/java/com/iexec/resultproxy/result/Result.java +++ b/src/main/java/com/iexec/resultproxy/result/Result.java @@ -5,6 +5,10 @@ import lombok.Data; import lombok.NoArgsConstructor; +/** + * @deprecated never used + */ +@Deprecated(forRemoval = true) @Data @AllArgsConstructor @NoArgsConstructor diff --git a/src/test/java/com/iexec/resultproxy/TestUtils.java b/src/test/java/com/iexec/resultproxy/TestUtils.java index 15f8a67..45362c7 100644 --- a/src/test/java/com/iexec/resultproxy/TestUtils.java +++ b/src/test/java/com/iexec/resultproxy/TestUtils.java @@ -19,12 +19,13 @@ import com.iexec.commons.poco.chain.ChainDeal; import com.iexec.commons.poco.chain.ChainTask; import com.iexec.commons.poco.chain.ChainTaskStatus; -import com.iexec.commons.poco.tee.TeeUtils; +import com.iexec.commons.poco.order.OrderTag; import lombok.AccessLevel; import lombok.NoArgsConstructor; import java.time.Instant; import java.time.temporal.ChronoUnit; +import java.util.Optional; @NoArgsConstructor(access = AccessLevel.PRIVATE) public class TestUtils { @@ -36,18 +37,24 @@ public class TestUtils { public static final String POOL_WRONG_SIGNATURE = "0xf869daaca2407b7eabd27c3c4c5a3f3565172ca7211ac1d8bfacea2beb511a4029446a07cccc0884" + "c2193b269dfb341461db8c680a8898bb53862d6e48340c2e1b"; - public static ChainDeal getChainDeal() { - return ChainDeal.builder() + public static final String RESULT_DIGEST = "0x3210"; + public static final String RESULT_HASH = "0x97f68778e2fa9d60e58ceb64de2c0e72e309400c3168c69499db2140fad28039"; + public static final String WALLET_ADDRESS = "0x123abc"; + public static final String WORKER_ADDRESS = "0xabc123"; + + public static Optional getChainDeal(final OrderTag tag) { + return Optional.of(ChainDeal.builder() .poolOwner(POOL_ADDRESS) - .tag(TeeUtils.TEE_SCONE_ONLY_TAG) - .build(); + .tag(tag.getValue()) + .requester(WALLET_ADDRESS) + .build()); } - public static ChainTask getChainTask(ChainTaskStatus status) { - return ChainTask.builder() + public static Optional getChainTask(final ChainTaskStatus status) { + return Optional.of(ChainTask.builder() .dealid(CHAIN_DEAL_ID) .finalDeadline(Instant.now().plus(5L, ChronoUnit.SECONDS).toEpochMilli()) .status(status) - .build(); + .build()); } } diff --git a/src/test/java/com/iexec/resultproxy/authorization/AuthorizationServiceTests.java b/src/test/java/com/iexec/resultproxy/authorization/AuthorizationServiceTests.java index ea8c6ab..2e38120 100644 --- a/src/test/java/com/iexec/resultproxy/authorization/AuthorizationServiceTests.java +++ b/src/test/java/com/iexec/resultproxy/authorization/AuthorizationServiceTests.java @@ -17,9 +17,9 @@ package com.iexec.resultproxy.authorization; import com.iexec.common.result.ResultModel; -import com.iexec.commons.poco.chain.ChainDeal; import com.iexec.commons.poco.chain.ChainTask; import com.iexec.commons.poco.chain.WorkerpoolAuthorization; +import com.iexec.commons.poco.order.OrderTag; import com.iexec.commons.poco.security.Signature; import com.iexec.commons.poco.utils.BytesUtils; import com.iexec.commons.poco.utils.HashUtils; @@ -28,6 +28,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.beans.factory.annotation.Autowired; @@ -63,8 +65,6 @@ @ExtendWith(MockitoExtension.class) class AuthorizationServiceTests { - private static final String RESULT_DIGEST = "0x3210"; - @Container private static final MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse(System.getProperty("mongo.image"))); @@ -93,13 +93,12 @@ void beforeEach() throws GeneralSecurityException { } // region isAuthorizedOnExecutionWithDetailedIssue - @Test - void shouldBeAuthorizedOnExecutionOfTeeTaskWithDetails() { - final ChainDeal chainDeal = getChainDeal(); - final ChainTask chainTask = getChainTask(ACTIVE); + @ParameterizedTest + @EnumSource(value = OrderTag.class, names = {"TEE_GRAMINE", "TEE_SCONE", "TEE_TDX"}) + void shouldBeAuthorizedOnExecutionOfTeeTaskWithDetails(final OrderTag tag) { final WorkerpoolAuthorization auth = getWorkerpoolAuthorization(true); - when(iexecHubService.getChainTask(auth.getChainTaskId())).thenReturn(Optional.of(chainTask)); - when(iexecHubService.getChainDeal(chainTask.getDealid())).thenReturn(Optional.of(chainDeal)); + when(iexecHubService.getChainTask(auth.getChainTaskId())).thenReturn(getChainTask(ACTIVE)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(getChainDeal(tag)); final Optional isAuth = authorizationService.isAuthorizedOnExecutionWithDetailedIssue(auth); assertThat(isAuth).isEmpty(); @@ -118,17 +117,16 @@ void shouldNotBeAuthorizedOnExecutionOfTeeTaskWithEmptyAuthorizationWithDetails( assertThat(isAuth).isEqualTo(Optional.of(EMPTY_PARAMS_UNAUTHORIZED)); } - @Test - void shouldNotBeAuthorizedOnExecutionOfTeeTaskWhenTaskTypeNotMatchedOnchainWithDetails() { - final ChainDeal chainDeal = getChainDeal(); - final ChainTask chainTask = getChainTask(ACTIVE); + @ParameterizedTest + @EnumSource(value = OrderTag.class, names = {"TEE_GRAMINE", "TEE_SCONE", "TEE_TDX"}) + void shouldNotBeAuthorizedOnExecutionOfTeeTaskWhenTaskTypeNotMatchedOnchainWithDetails(final OrderTag tag) { final WorkerpoolAuthorization auth = WorkerpoolAuthorization.builder() .chainTaskId("0x1111111111111111111111111111111111111111111111111111111111111111") .workerWallet("0x87ae2b87b5db23830572988fb1f51242fbc471ce") .enclaveChallenge(BytesUtils.EMPTY_ADDRESS) .build(); - when(iexecHubService.getChainTask(auth.getChainTaskId())).thenReturn(Optional.of(chainTask)); - when(iexecHubService.getChainDeal(chainTask.getDealid())).thenReturn(Optional.of(chainDeal)); + when(iexecHubService.getChainTask(auth.getChainTaskId())).thenReturn(getChainTask(ACTIVE)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(getChainDeal(tag)); final Optional isAuth = authorizationService.isAuthorizedOnExecutionWithDetailedIssue(auth); assertThat(isAuth).isEqualTo(Optional.of(NO_MATCH_ONCHAIN_TYPE)); @@ -158,26 +156,24 @@ void shouldNotBeAuthorizedOnExecutionOfTeeTaskWhenFinalDeadlineReached() { @Test void shouldNotBeAuthorizedOnExecutionOfTeeTaskWhenGetDealFailedWithDetails() { - final ChainTask chainTask = getChainTask(ACTIVE); final Signature wrongSignature = new Signature(POOL_WRONG_SIGNATURE); final WorkerpoolAuthorization auth = getWorkerpoolAuthorizationWithWrongSignature(wrongSignature); - when(iexecHubService.getChainTask(auth.getChainTaskId())).thenReturn(Optional.of(chainTask)); - when(iexecHubService.getChainDeal(chainTask.getDealid())).thenReturn(Optional.empty()); + when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(getChainTask(ACTIVE)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.empty()); final Optional isAuth = authorizationService.isAuthorizedOnExecutionWithDetailedIssue(auth); assertThat(isAuth).isEqualTo(Optional.of(GET_CHAIN_DEAL_FAILED)); } - @Test - void shouldNotBeAuthorizedOnExecutionOfTeeTaskWhenPoolSignatureIsNotValidWithDetails() { - final ChainDeal chainDeal = getChainDeal(); - final ChainTask chainTask = getChainTask(ACTIVE); + @ParameterizedTest + @EnumSource(value = OrderTag.class, names = {"TEE_GRAMINE", "TEE_SCONE", "TEE_TDX"}) + void shouldNotBeAuthorizedOnExecutionOfTeeTaskWhenPoolSignatureIsNotValidWithDetails(final OrderTag tag) { final Signature wrongSignature = new Signature(POOL_WRONG_SIGNATURE); final WorkerpoolAuthorization auth = getWorkerpoolAuthorizationWithWrongSignature(wrongSignature); - when(iexecHubService.getChainTask(auth.getChainTaskId())).thenReturn(Optional.of(chainTask)); - when(iexecHubService.getChainDeal(chainTask.getDealid())).thenReturn(Optional.of(chainDeal)); + when(iexecHubService.getChainTask(auth.getChainTaskId())).thenReturn(getChainTask(ACTIVE)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(getChainDeal(tag)); final Optional isAuth = authorizationService.isAuthorizedOnExecutionWithDetailedIssue(auth); assertThat(isAuth).isEqualTo(Optional.of(INVALID_SIGNATURE)); @@ -277,7 +273,7 @@ void shouldNotAddAuthorizationTwiceInCollection() { // endregion // region utils - String getEnclaveSignature(final ECKeyPair ecKeyPair) { + private String getEnclaveSignature(final ECKeyPair ecKeyPair) { final String resultHash = HashUtils.concatenateAndHash(CHAIN_TASK_ID, RESULT_DIGEST); final String resultSeal = HashUtils.concatenateAndHash(workerCreds.getAddress(), CHAIN_TASK_ID, RESULT_DIGEST); final String messageHash = HashUtils.concatenateAndHash(resultHash, resultSeal); diff --git a/src/test/java/com/iexec/resultproxy/proxy/ProxyServiceTest.java b/src/test/java/com/iexec/resultproxy/proxy/ProxyServiceTest.java index fefe63f..0505dc8 100644 --- a/src/test/java/com/iexec/resultproxy/proxy/ProxyServiceTest.java +++ b/src/test/java/com/iexec/resultproxy/proxy/ProxyServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 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. @@ -18,21 +18,20 @@ import com.iexec.common.result.ResultModel; import com.iexec.commons.poco.chain.ChainContribution; -import com.iexec.commons.poco.chain.ChainDeal; -import com.iexec.commons.poco.chain.ChainTask; -import com.iexec.commons.poco.chain.ChainTaskStatus; -import com.iexec.commons.poco.tee.TeeUtils; -import com.iexec.commons.poco.utils.BytesUtils; +import com.iexec.commons.poco.order.OrderTag; import com.iexec.resultproxy.authorization.AuthorizationService; import com.iexec.resultproxy.chain.IexecHubService; import com.iexec.resultproxy.ipfs.IpfsResultService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import org.mockito.Spy; +import org.mockito.junit.jupiter.MockitoExtension; import java.io.File; import java.util.Base64; @@ -40,16 +39,13 @@ import static com.iexec.commons.poco.chain.ChainContributionStatus.CONTRIBUTED; import static com.iexec.commons.poco.chain.ChainContributionStatus.REVEALED; -import static com.iexec.commons.poco.chain.ChainTaskStatus.ACTIVE; -import static com.iexec.commons.poco.chain.ChainTaskStatus.UNSET; +import static com.iexec.commons.poco.chain.ChainTaskStatus.*; import static com.iexec.resultproxy.TestUtils.*; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; +@ExtendWith(MockitoExtension.class) class ProxyServiceTest { - private static final String RESULT_HASH = "0x97f68778e2fa9d60e58ceb64de2c0e72e309400c3168c69499db2140fad28039"; - private static final String WALLET_ADDRESS = "0x123abc"; - private static final String WORKER_ADDRESS = "0xabc123"; /** * Contains a valid result zip, with the following files: *
    @@ -59,22 +55,6 @@ class ProxyServiceTest { */ private static final byte[] RESULT_ZIP = Base64.getDecoder().decode("UEsDBBQACAgIADhKL1cAAAAAAAAAAAAAAAANAAAAY29tcHV0ZWQuanNvbqtWSkktSS3KzczLLC7JTNbNLy0pKC3RLUgsyVCyUlDSz0ytSE2OB4rqF6UWl+aU6JVUlCjVAgBQSwcIv08alTcAAAA2AAAAUEsDBBQACAgIADhKL1cAAAAAAAAAAAAAAAAKAAAAcmVzdWx0LnR4dG2NsQrDMAxEd33FdbOhoL1boUM/wnCE4MFg2qEZOvjjK9tKhhIbW9LTnQQC6G8ET7DX/5CQhnlJHol3FQkGAuOAU9ENPaqZE45k6h0NSC/N0Ff231DzgW3qbWxqDqeCZuDYkfpCehIQoeYHEtMOR4NRcHKantF55JlrfV9xr2XNF5HHsi2fvCFoyd+8srw03iDyA1BLBwgqyEkSkwAAAE0BAABQSwECFAAUAAgICAA4Si9Xv08alTcAAAA2AAAADQAAAAAAAAAAAAAAAAAAAAAAY29tcHV0ZWQuanNvblBLAQIUABQACAgIADhKL1cqyEkSkwAAAE0BAAAKAAAAAAAAAAAAAAAAAHIAAAByZXN1bHQudHh0UEsFBgAAAAACAAIAcwAAAD0BAAAAAA=="); - private static final ChainDeal STD_DEAL = ChainDeal.builder() - .chainDealId(CHAIN_DEAL_ID) - .tag(BytesUtils.toByte32HexString(0L)) - .build(); - - private static final ChainDeal TEE_DEAL = ChainDeal.builder() - .tag(TeeUtils.TEE_SCONE_ONLY_TAG) - .requester(WALLET_ADDRESS) - .build(); - - private static final ChainTask CHAIN_TASK = ChainTask.builder() - .chainTaskId(CHAIN_TASK_ID) - .dealid(CHAIN_DEAL_ID) - .status(ChainTaskStatus.REVEALING) - .build(); - /** * {@link ChainContribution} with a hash * corresponding to {@link ProxyServiceTest#RESULT_ZIP} hash, @@ -112,7 +92,6 @@ class ProxyServiceTest { @BeforeEach void init() { - MockitoAnnotations.openMocks(this); when(ipfsResultService.doesResultExist(CHAIN_TASK_ID)).thenReturn(false); } @@ -139,7 +118,7 @@ void isNotAbleToUploadSinceNoChainTask() { @Test void isNotAbleToUploadSinceNoChainDeal() { - when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(Optional.of(CHAIN_TASK)); + when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(getChainTask(REVEALING)); when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.empty()); assertThat(proxyService.canUploadResult(RESULT_MODEL, WALLET_ADDRESS)).isFalse(); @@ -153,8 +132,8 @@ void isNotAbleToUploadSinceNoChainDeal() { // region STD task @Test void isNotAbleToUploadSinceNoChainContribution() { - when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(Optional.of(CHAIN_TASK)); - when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.of(STD_DEAL)); + when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(getChainTask(REVEALING)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(getChainDeal(OrderTag.STANDARD)); when(iexecHubService.getChainContribution(CHAIN_TASK_ID, WALLET_ADDRESS)).thenReturn(Optional.empty()); assertThat(proxyService.canUploadResult(RESULT_MODEL, WALLET_ADDRESS)).isFalse(); @@ -165,8 +144,8 @@ void isNotAbleToUploadSinceNoChainContribution() { @Test void isNotAbleToUploadSinceCannotWriteZip() { - when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(Optional.of(CHAIN_TASK)); - when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.of(STD_DEAL)); + when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(getChainTask(REVEALING)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(getChainDeal(OrderTag.STANDARD)); when(iexecHubService.getChainContribution(CHAIN_TASK_ID, WALLET_ADDRESS)).thenReturn(Optional.of(CHAIN_CONTRIBUTION)); when(proxyService.getResultFolderPath(CHAIN_TASK_ID)).thenReturn("/this/path/does/not/exist"); @@ -178,8 +157,8 @@ void isNotAbleToUploadSinceCannotWriteZip() { @Test void isNotAbleToUploadSinceWrongHash() { - when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(Optional.of(CHAIN_TASK)); - when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.of(STD_DEAL)); + when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(getChainTask(REVEALING)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(getChainDeal(OrderTag.STANDARD)); when(iexecHubService.getChainContribution(CHAIN_TASK_ID, WALLET_ADDRESS)).thenReturn(Optional.of(CHAIN_CONTRIBUTION)); when(proxyService.getResultFolderPath(CHAIN_TASK_ID)).thenReturn(tmpFolder.getAbsolutePath()); @@ -193,8 +172,8 @@ void isNotAbleToUploadSinceWrongHash() { @Test void isNotAbleToUploadSinceChainStatusIsNotRevealedWithIpfs() { ChainContribution chainContribution = ChainContribution.builder().status(CONTRIBUTED).resultHash(RESULT_HASH).build(); - when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(Optional.of(CHAIN_TASK)); - when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.of(STD_DEAL)); + when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(getChainTask(REVEALING)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(getChainDeal(OrderTag.STANDARD)); when(iexecHubService.getChainContribution(CHAIN_TASK_ID, WALLET_ADDRESS)).thenReturn(Optional.of(chainContribution)); when(proxyService.getResultFolderPath(CHAIN_TASK_ID)).thenReturn(tmpFolder.getAbsolutePath()); @@ -206,8 +185,8 @@ void isNotAbleToUploadSinceChainStatusIsNotRevealedWithIpfs() { @Test void isAbleToUploadStandardTaskResult() { - when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(Optional.of(CHAIN_TASK)); - when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.of(STD_DEAL)); + when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(getChainTask(REVEALING)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(getChainDeal(OrderTag.STANDARD)); when(iexecHubService.getChainContribution(CHAIN_TASK_ID, WALLET_ADDRESS)).thenReturn(Optional.of(CHAIN_CONTRIBUTION)); when(proxyService.getResultFolderPath(CHAIN_TASK_ID)).thenReturn(tmpFolder.getAbsolutePath()); @@ -220,11 +199,11 @@ void isAbleToUploadStandardTaskResult() { // endregion // region TEE tasks with enclave signature - @Test - void isNotAbleToUploadSinceEnclaveSignatureIsNotValid() { - final ChainTask activeTask = getChainTask(ACTIVE); - when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(Optional.of(activeTask)); - when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.of(TEE_DEAL)); + @ParameterizedTest + @EnumSource(value = OrderTag.class, names = {"TEE_GRAMINE", "TEE_SCONE", "TEE_TDX"}) + void isNotAbleToUploadSinceEnclaveSignatureIsNotValid(final OrderTag tag) { + when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(getChainTask(ACTIVE)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(getChainDeal(tag)); when(authorizationService.checkEnclaveSignature(RESULT_MODEL_WITH_SIGN, WORKER_ADDRESS)).thenReturn(false); assertThat(proxyService.canUploadResult(RESULT_MODEL_WITH_SIGN, WORKER_ADDRESS)).isFalse(); @@ -232,11 +211,11 @@ void isNotAbleToUploadSinceEnclaveSignatureIsNotValid() { verify(authorizationService).checkEnclaveSignature(RESULT_MODEL_WITH_SIGN, WORKER_ADDRESS); } - @Test - void isAbleToUploadTeeTaskResultWithEnclaveSignature() { - final ChainTask activeTask = getChainTask(ACTIVE); - when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(Optional.of(activeTask)); - when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.of(TEE_DEAL)); + @ParameterizedTest + @EnumSource(value = OrderTag.class, names = {"TEE_GRAMINE", "TEE_SCONE", "TEE_TDX"}) + void isAbleToUploadTeeTaskResultWithEnclaveSignature(final OrderTag tag) { + when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(getChainTask(ACTIVE)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(getChainDeal(tag)); when(authorizationService.checkEnclaveSignature(RESULT_MODEL_WITH_SIGN, WORKER_ADDRESS)).thenReturn(true); assertThat(proxyService.canUploadResult(RESULT_MODEL_WITH_SIGN, WORKER_ADDRESS)).isTrue(); @@ -246,12 +225,11 @@ void isAbleToUploadTeeTaskResultWithEnclaveSignature() { // endregion // region TEE tasks no enclave signature - @Test - void isNotAbleToUploadSinceTaskNotActive() { - final ChainTask chainTask = getChainTask(UNSET); - - when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(Optional.of(chainTask)); - when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.of(TEE_DEAL)); + @ParameterizedTest + @EnumSource(value = OrderTag.class, names = {"TEE_GRAMINE", "TEE_SCONE", "TEE_TDX"}) + void isNotAbleToUploadSinceTaskNotActive(final OrderTag tag) { + when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(getChainTask(UNSET)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(getChainDeal(tag)); assertThat(proxyService.canUploadResult(RESULT_MODEL, WALLET_ADDRESS)).isFalse(); @@ -259,11 +237,11 @@ void isNotAbleToUploadSinceTaskNotActive() { verifyNoInteractions(authorizationService); } - @Test - void isAbleToUploadTeeTaskResultWithoutEnclaveSignature() { - final ChainTask chainTask = getChainTask(ACTIVE); - when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(Optional.of(chainTask)); - when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.of(TEE_DEAL)); + @ParameterizedTest + @EnumSource(value = OrderTag.class, names = {"TEE_GRAMINE", "TEE_SCONE", "TEE_TDX"}) + void isAbleToUploadTeeTaskResultWithoutEnclaveSignature(final OrderTag tag) { + when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(getChainTask(ACTIVE)); + when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(getChainDeal(tag)); assertThat(proxyService.canUploadResult(RESULT_MODEL, WALLET_ADDRESS)).isTrue();