diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ae8b638..8ca8856f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ All notable changes to this project will be documented in this file. +## [[8.1.0]](https://github.com/iExecBlockchainComputing/iexec-sms/releases/tag/v8.1.0) 2023-06-07 + +### New Features +- Enable Prometheus actuator. (#166) +### Bug Fixes +- Remove unused dependencies. (#168) +- Use DatasetAddress in `IEXEC_DATASET_FILENAME` environment variable. (#172) +### Dependency Upgrades +- Upgrade to `feign` 11.10. (#167) +- Upgrade to `iexec-common` 8.2.0. (#169 #170 #171 #173) +- Add new `iexec-commons-poco` 3.0.2 dependency. (#169 #170 #171 #173) + ## [[8.0.0]](https://github.com/iExecBlockchainComputing/iexec-sms/releases/tag/v8.0.0) 2023-03-06 ### New Features diff --git a/README.md b/README.md index 772fcba5..859250eb 100644 --- a/README.md +++ b/README.md @@ -52,12 +52,13 @@ To support: | `IEXEC_SMS_H2_URL` | JDBC URL of the database. | URL | `jdbc:h2:file:/tmp/h2/sms-h2` | `jdbc:h2:file:/tmp/h2/sms-h2` | | `IEXEC_SMS_H2_CONSOLE` | Whether to enable the H2 console. | Boolean | `false` | `false` | | `IEXEC_SMS_STORAGE_ENCRYPTION_AES_KEY_PATH` | Path to the key created and used to encrypt secrets. | String | `src/main/resources/iexec-sms-aes.key` | `src/main/resources/iexec-sms-aes.key` | -| `IEXEC_CHAIN_ID` | Chain ID of the blockchain network to connect. | Positive integer | `17` | `17` | -| `IEXEC_SMS_BLOCKCHAIN_NODE_ADDRESS` | URL to connect to the blockchain node. | URL | `http://localhost:8545` | `http://localhost:8545` | -| `IEXEC_HUB_ADDRESS` | Proxy contract address to interact with the iExec on-chain protocol. | String | `0xBF6B2B07e47326B7c8bfCb4A5460bef9f0Fd2002` | `0xBF6B2B07e47326B7c8bfCb4A5460bef9f0Fd2002` | +| `IEXEC_CHAIN_ID` | Chain ID of the blockchain network to connect. | Positive integer | `134` | `134` | +| `IEXEC_IS_SIDECHAIN` | Define whether iExec on-chain protocol is built on top of token (`false`) or native currency (`true`). | Boolean | `true` | `true` | +| `IEXEC_SMS_BLOCKCHAIN_NODE_ADDRESS` | URL to connect to the blockchain node. | URL | `https://bellecour.iex.ec` | `https://bellecour.iex.ec` | +| `IEXEC_HUB_ADDRESS` | Proxy contract address to interact with the iExec on-chain protocol. | String | `0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f` | `0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f` | +| `IEXEC_BLOCK_TIME` | Duration between consecutive blocks on the blockchain network. | String | `PT5S` | `PT5S` | | `IEXEC_GAS_PRICE_MULTIPLIER` | Transactions will be sent with `networkGasPrice * IEXEC_GAS_PRICE_MULTIPLIER`. | Float | `1.0` | `1.0` | | `IEXEC_GAS_PRICE_CAP` | In Wei, will be used for transactions if `networkGasPrice * IEXEC_GAS_PRICE_MULTIPLIER > IEXEC_GAS_PRICE_CAP`. | Integer | `22000000000` | `22000000000` | -| `IEXEC_IS_SIDECHAIN` | Define if iExec on-chain protocol is built on top of token (`false`) or native currency (`true`). | Boolean | `false` | `false` | | `IEXEC_SMS_DISPLAY_DEBUG_SESSION` | Whether to display TEE enclaves sessions configuration in SMS logs. | Boolean | `false` | `false` | | `IEXEC_SECRET_PROVISIONER_WEB_HOSTNAME` | Secret provisioner server host for session management. Used to post sessions of secrets. | String | `localhost` | `localhost` | | `IEXEC_SECRET_PROVISIONER_WEB_PORT` | Secret provisioner server port for session management. | Positive integer | `8081` | `8080` | @@ -89,3 +90,7 @@ To support: A health endpoint (`/actuator/health`) is enabled by default and can be accessed on the `IEXEC_SMS_PORT`. This endpoint allows to define health checks in an orchestrator or a [compose file](https://github.com/compose-spec/compose-spec/blob/master/spec.md#healthcheck). No default strategy has been implemented in the [Dockerfile](Dockerfile) at the moment. + +## License + +This repository code is released under the [Apache License 2.0](LICENSE). diff --git a/build.gradle b/build.gradle index da654a1f..e15dedd3 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ plugins { } ext { - openFeignVersion = '11.7' + openFeignVersion = '11.10' } if (!project.hasProperty('gitBranch')) { @@ -52,6 +52,7 @@ configurations { dependencies { // iexec + implementation "com.iexec.commons:iexec-commons-poco:$iexecCommonsPocoVersion" implementation "com.iexec.common:iexec-common:$iexecCommonVersion" implementation project(':iexec-sms-library') @@ -76,28 +77,15 @@ dependencies { // It is required to define the dependency version required by web3j until migration to at least Spring Boot 2.7.X implementation 'com.squareup.okhttp3:okhttp:4.9.0' // Web3j issue: https://github.com/web3j/web3j/issues/1180 - // velocity for templating - implementation 'org.apache.velocity:velocity-engine-core:2.0' - - // MongoDB - //implementation "org.springframework.boot:spring-boot-starter-data-mongodb" - //implementation 'org.springframework.boot:spring-boot-starter' - //testImplementation 'org.springframework.boot:spring-boot-starter-test' + // observability + runtimeOnly 'io.micrometer:micrometer-registry-prometheus' // test testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } - testImplementation 'org.springframework.security:spring-security-test' - // testImplementation 'org.mockito:mockito-inline:2.13.0' // activates mocking final classes/methods - - // test containers - testImplementation 'org.testcontainers:junit-jupiter:1.16.0' - testImplementation 'org.testcontainers:testcontainers:1.16.0' - testImplementation 'org.testcontainers:mongodb:1.16.0' // feign - implementation "io.github.openfeign:feign-core:$openFeignVersion" implementation "io.github.openfeign:feign-jackson:$openFeignVersion" implementation "io.github.openfeign:feign-slf4j:$openFeignVersion" } diff --git a/gradle.properties b/gradle.properties index e15dd102..3fa90f8b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,6 @@ -version=8.0.0 -iexecCommonVersion=7.0.0 +version=8.1.0 +iexecCommonVersion=8.2.0 +iexecCommonsPocoVersion=3.0.2 nexusUser nexusPassword diff --git a/iexec-sms-library/build.gradle b/iexec-sms-library/build.gradle index 00f55e4d..84130723 100644 --- a/iexec-sms-library/build.gradle +++ b/iexec-sms-library/build.gradle @@ -6,6 +6,7 @@ plugins { } dependencies { + implementation "com.iexec.commons:iexec-commons-poco:$iexecCommonsPocoVersion" implementation "com.iexec.common:iexec-common:$iexecCommonVersion" testImplementation "org.assertj:assertj-core:3.22.0" testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2' diff --git a/iexec-sms-library/src/main/java/com/iexec/sms/api/SmsClient.java b/iexec-sms-library/src/main/java/com/iexec/sms/api/SmsClient.java index 11d8341a..4b63ba8f 100644 --- a/iexec-sms-library/src/main/java/com/iexec/sms/api/SmsClient.java +++ b/iexec-sms-library/src/main/java/com/iexec/sms/api/SmsClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2023 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. @@ -16,9 +16,9 @@ package com.iexec.sms.api; -import com.iexec.common.chain.WorkerpoolAuthorization; -import com.iexec.common.tee.TeeFramework; import com.iexec.common.web.ApiResponseBody; +import com.iexec.commons.poco.chain.WorkerpoolAuthorization; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.api.config.TeeServicesProperties; import feign.Headers; import feign.Param; diff --git a/iexec-sms-library/src/main/java/com/iexec/sms/api/config/GramineServicesProperties.java b/iexec-sms-library/src/main/java/com/iexec/sms/api/config/GramineServicesProperties.java index 85e17089..5ce0bb19 100644 --- a/iexec-sms-library/src/main/java/com/iexec/sms/api/config/GramineServicesProperties.java +++ b/iexec-sms-library/src/main/java/com/iexec/sms/api/config/GramineServicesProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2023 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,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import lombok.Getter; @Getter diff --git a/iexec-sms-library/src/main/java/com/iexec/sms/api/config/SconeServicesProperties.java b/iexec-sms-library/src/main/java/com/iexec/sms/api/config/SconeServicesProperties.java index 887e0e1d..72019609 100644 --- a/iexec-sms-library/src/main/java/com/iexec/sms/api/config/SconeServicesProperties.java +++ b/iexec-sms-library/src/main/java/com/iexec/sms/api/config/SconeServicesProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2023 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,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import lombok.Getter; @Getter diff --git a/iexec-sms-library/src/main/java/com/iexec/sms/api/config/TeeServicesProperties.java b/iexec-sms-library/src/main/java/com/iexec/sms/api/config/TeeServicesProperties.java index 9c50746d..1ca3cc56 100644 --- a/iexec-sms-library/src/main/java/com/iexec/sms/api/config/TeeServicesProperties.java +++ b/iexec-sms-library/src/main/java/com/iexec/sms/api/config/TeeServicesProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2023 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,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/itest/java/com/iexec/sms/secret/compute/TeeTaskComputeSecretIntegrationTests.java b/src/itest/java/com/iexec/sms/secret/compute/TeeTaskComputeSecretIntegrationTests.java index 92372783..eb27ae79 100644 --- a/src/itest/java/com/iexec/sms/secret/compute/TeeTaskComputeSecretIntegrationTests.java +++ b/src/itest/java/com/iexec/sms/secret/compute/TeeTaskComputeSecretIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 IEXEC BLOCKCHAIN TECH + * Copyright 2021-2023 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. @@ -16,8 +16,8 @@ package com.iexec.sms.secret.compute; -import com.iexec.common.contract.generated.Ownable; -import com.iexec.common.utils.HashUtils; +import com.iexec.commons.poco.contract.generated.Ownable; +import com.iexec.commons.poco.utils.HashUtils; import com.iexec.sms.CommonTestSetup; import com.iexec.sms.api.SmsClient; import com.iexec.sms.api.SmsClientBuilder; @@ -45,7 +45,7 @@ import java.util.Random; import java.util.stream.Collectors; -import static com.iexec.common.utils.SignatureUtils.signMessageHashAndGetSignature; +import static com.iexec.commons.poco.utils.SignatureUtils.signMessageHashAndGetSignature; import static com.iexec.sms.MockChainConfiguration.MOCK_CHAIN_PROFILE; import static com.iexec.sms.MockTeeConfiguration.MOCK_TEE_PROFILE; import static org.mockito.Mockito.mock; diff --git a/src/itest/java/com/iexec/sms/tee/TeeBeansLoadingTests.java b/src/itest/java/com/iexec/sms/tee/TeeBeansLoadingTests.java index 5322bd53..73bdcec9 100644 --- a/src/itest/java/com/iexec/sms/tee/TeeBeansLoadingTests.java +++ b/src/itest/java/com/iexec/sms/tee/TeeBeansLoadingTests.java @@ -1,6 +1,22 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.CommonTestSetup; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; diff --git a/src/main/java/com/iexec/sms/authorization/AuthorizationService.java b/src/main/java/com/iexec/sms/authorization/AuthorizationService.java index b3e96c17..1a267f77 100644 --- a/src/main/java/com/iexec/sms/authorization/AuthorizationService.java +++ b/src/main/java/com/iexec/sms/authorization/AuthorizationService.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -17,14 +17,14 @@ package com.iexec.sms.authorization; -import com.iexec.common.chain.ChainDeal; -import com.iexec.common.chain.ChainTask; -import com.iexec.common.chain.ChainTaskStatus; -import com.iexec.common.chain.WorkerpoolAuthorization; -import com.iexec.common.security.Signature; -import com.iexec.common.utils.BytesUtils; -import com.iexec.common.utils.HashUtils; -import com.iexec.common.utils.SignatureUtils; +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.chain.WorkerpoolAuthorization; +import com.iexec.commons.poco.security.Signature; +import com.iexec.commons.poco.utils.BytesUtils; +import com.iexec.commons.poco.utils.HashUtils; +import com.iexec.commons.poco.utils.SignatureUtils; import com.iexec.sms.blockchain.IexecHubService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/iexec/sms/blockchain/BlockchainConfig.java b/src/main/java/com/iexec/sms/blockchain/BlockchainConfig.java index 70a06f09..c6988930 100644 --- a/src/main/java/com/iexec/sms/blockchain/BlockchainConfig.java +++ b/src/main/java/com/iexec/sms/blockchain/BlockchainConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -16,34 +16,21 @@ package com.iexec.sms.blockchain; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; +import lombok.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.ConstructorBinding; -@Component -@Getter -@AllArgsConstructor -@NoArgsConstructor -public class BlockchainConfig { - - @Value("${blockchain.id}") - private Integer chainId; - - @Value("${blockchain.node-address}") - private String nodeAddress; - - @Value("${blockchain.hub-address}") - private String hubAddress; - - @Value("${blockchain.gas-price-multiplier}") - private float gasPriceMultiplier; - - @Value("${blockchain.gas-price-cap}") - private long gasPriceCap; - - @Value("${blockchain.is-sidechain}") - private boolean isSidechain; +import java.time.Duration; +@Value +@ConstructorBinding +@ConfigurationProperties(prefix = "blockchain") +public class BlockchainConfig { + int id; + boolean isSidechain; + String nodeAddress; + String hubAddress; + Duration blockTime; + float gasPriceMultiplier; + long gasPriceCap; } diff --git a/src/main/java/com/iexec/sms/blockchain/IexecHubService.java b/src/main/java/com/iexec/sms/blockchain/IexecHubService.java index e7cb778f..73b4df6e 100644 --- a/src/main/java/com/iexec/sms/blockchain/IexecHubService.java +++ b/src/main/java/com/iexec/sms/blockchain/IexecHubService.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -17,7 +17,7 @@ package com.iexec.sms.blockchain; -import com.iexec.common.chain.IexecHubAbstractService; +import com.iexec.commons.poco.chain.IexecHubAbstractService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/iexec/sms/blockchain/Web3jService.java b/src/main/java/com/iexec/sms/blockchain/Web3jService.java index f1d1efa5..d4dd4ba5 100644 --- a/src/main/java/com/iexec/sms/blockchain/Web3jService.java +++ b/src/main/java/com/iexec/sms/blockchain/Web3jService.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.blockchain; -import com.iexec.common.chain.Web3jAbstractService; +import com.iexec.commons.poco.chain.Web3jAbstractService; import org.springframework.stereotype.Service; @Service @@ -24,7 +24,9 @@ public class Web3jService extends Web3jAbstractService { public Web3jService(BlockchainConfig blockchainConfig) { super( + blockchainConfig.getId(), blockchainConfig.getNodeAddress(), + blockchainConfig.getBlockTime(), blockchainConfig.getGasPriceMultiplier(), blockchainConfig.getGasPriceCap(), blockchainConfig.isSidechain() diff --git a/src/main/java/com/iexec/sms/encryption/EncryptionService.java b/src/main/java/com/iexec/sms/encryption/EncryptionService.java index deef1559..62d69e41 100644 --- a/src/main/java/com/iexec/sms/encryption/EncryptionService.java +++ b/src/main/java/com/iexec/sms/encryption/EncryptionService.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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,8 +18,8 @@ import com.iexec.common.security.CipherHelper; -import com.iexec.common.utils.BytesUtils; import com.iexec.common.utils.FileHelper; +import com.iexec.commons.poco.utils.BytesUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.web3j.crypto.Hash; diff --git a/src/main/java/com/iexec/sms/ssl/SslConfig.java b/src/main/java/com/iexec/sms/ssl/SslConfig.java index 9f8a0ffd..d189ff3d 100644 --- a/src/main/java/com/iexec/sms/ssl/SslConfig.java +++ b/src/main/java/com/iexec/sms/ssl/SslConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.ssl; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.tee.ConditionalOnTeeFramework; import lombok.extern.slf4j.Slf4j; import org.apache.http.ssl.SSLContexts; diff --git a/src/main/java/com/iexec/sms/ssl/TwoWaySslClient.java b/src/main/java/com/iexec/sms/ssl/TwoWaySslClient.java index c6b0aad5..3bb98c5a 100644 --- a/src/main/java/com/iexec/sms/ssl/TwoWaySslClient.java +++ b/src/main/java/com/iexec/sms/ssl/TwoWaySslClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.ssl; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.tee.ConditionalOnTeeFramework; import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.impl.client.HttpClientBuilder; diff --git a/src/main/java/com/iexec/sms/tee/ConditionalOnTeeFramework.java b/src/main/java/com/iexec/sms/tee/ConditionalOnTeeFramework.java index 8f83b789..ac4143fb 100644 --- a/src/main/java/com/iexec/sms/tee/ConditionalOnTeeFramework.java +++ b/src/main/java/com/iexec/sms/tee/ConditionalOnTeeFramework.java @@ -1,6 +1,22 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import org.springframework.context.annotation.Conditional; import java.lang.annotation.ElementType; diff --git a/src/main/java/com/iexec/sms/tee/OnTeeFrameworkCondition.java b/src/main/java/com/iexec/sms/tee/OnTeeFrameworkCondition.java index 741215b6..b2f5be60 100644 --- a/src/main/java/com/iexec/sms/tee/OnTeeFrameworkCondition.java +++ b/src/main/java/com/iexec/sms/tee/OnTeeFrameworkCondition.java @@ -1,6 +1,22 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.condition.ConditionMessage; import org.springframework.boot.autoconfigure.condition.ConditionOutcome; diff --git a/src/main/java/com/iexec/sms/tee/TeeController.java b/src/main/java/com/iexec/sms/tee/TeeController.java index d52a468c..eb0be72f 100644 --- a/src/main/java/com/iexec/sms/tee/TeeController.java +++ b/src/main/java/com/iexec/sms/tee/TeeController.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -17,9 +17,9 @@ package com.iexec.sms.tee; -import com.iexec.common.chain.WorkerpoolAuthorization; -import com.iexec.common.tee.TeeFramework; import com.iexec.common.web.ApiResponseBody; +import com.iexec.commons.poco.chain.WorkerpoolAuthorization; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.api.TeeSessionGenerationError; import com.iexec.sms.api.TeeSessionGenerationResponse; import com.iexec.sms.api.config.TeeServicesProperties; diff --git a/src/main/java/com/iexec/sms/tee/TeeFrameworkConverter.java b/src/main/java/com/iexec/sms/tee/TeeFrameworkConverter.java index 78ccd54e..b120a629 100644 --- a/src/main/java/com/iexec/sms/tee/TeeFrameworkConverter.java +++ b/src/main/java/com/iexec/sms/tee/TeeFrameworkConverter.java @@ -1,6 +1,22 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import org.springframework.core.convert.converter.Converter; import org.springframework.stereotype.Component; diff --git a/src/main/java/com/iexec/sms/tee/config/TeeWorkerInternalConfiguration.java b/src/main/java/com/iexec/sms/tee/config/TeeWorkerInternalConfiguration.java index e907ba26..7d3e750f 100644 --- a/src/main/java/com/iexec/sms/tee/config/TeeWorkerInternalConfiguration.java +++ b/src/main/java/com/iexec/sms/tee/config/TeeWorkerInternalConfiguration.java @@ -1,6 +1,22 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee.config; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.api.config.GramineServicesProperties; import com.iexec.sms.api.config.SconeServicesProperties; import com.iexec.sms.api.config.TeeAppProperties; diff --git a/src/main/java/com/iexec/sms/tee/session/TeeSessionService.java b/src/main/java/com/iexec/sms/tee/session/TeeSessionService.java index b2b26390..5efcaf61 100644 --- a/src/main/java/com/iexec/sms/tee/session/TeeSessionService.java +++ b/src/main/java/com/iexec/sms/tee/session/TeeSessionService.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -16,8 +16,8 @@ package com.iexec.sms.tee.session; -import com.iexec.common.task.TaskDescription; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.task.TaskDescription; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.api.TeeSessionGenerationResponse; import com.iexec.sms.blockchain.IexecHubService; import com.iexec.sms.tee.session.generic.TeeSessionGenerationException; diff --git a/src/main/java/com/iexec/sms/tee/session/base/SecretSessionBaseService.java b/src/main/java/com/iexec/sms/tee/session/base/SecretSessionBaseService.java index c6d561d1..a6509661 100644 --- a/src/main/java/com/iexec/sms/tee/session/base/SecretSessionBaseService.java +++ b/src/main/java/com/iexec/sms/tee/session/base/SecretSessionBaseService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2023 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. @@ -16,10 +16,10 @@ package com.iexec.sms.tee.session.base; -import com.iexec.common.task.TaskDescription; -import com.iexec.common.tee.TeeEnclaveConfiguration; import com.iexec.common.utils.IexecEnvUtils; import com.iexec.common.utils.IexecFileHelper; +import com.iexec.commons.poco.task.TaskDescription; +import com.iexec.commons.poco.tee.TeeEnclaveConfiguration; import com.iexec.sms.api.config.TeeServicesProperties; import com.iexec.sms.secret.compute.OnChainObjectType; import com.iexec.sms.secret.compute.SecretOwnerRole; @@ -40,10 +40,10 @@ import java.util.*; -import static com.iexec.common.chain.DealParams.DROPBOX_RESULT_STORAGE_PROVIDER; import static com.iexec.common.precompute.PreComputeUtils.IS_DATASET_REQUIRED; -import static com.iexec.common.tee.TeeUtils.booleanToYesNo; import static com.iexec.common.worker.result.ResultUtils.*; +import static com.iexec.commons.poco.chain.DealParams.DROPBOX_RESULT_STORAGE_PROVIDER; +import static com.iexec.commons.poco.tee.TeeUtils.booleanToYesNo; import static com.iexec.sms.api.TeeSessionGenerationError.*; import static com.iexec.sms.secret.ReservedSecretKeyName.*; diff --git a/src/main/java/com/iexec/sms/tee/session/generic/TeeSessionRequest.java b/src/main/java/com/iexec/sms/tee/session/generic/TeeSessionRequest.java index 117d62ef..8f5541cf 100644 --- a/src/main/java/com/iexec/sms/tee/session/generic/TeeSessionRequest.java +++ b/src/main/java/com/iexec/sms/tee/session/generic/TeeSessionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.tee.session.generic; -import com.iexec.common.task.TaskDescription; +import com.iexec.commons.poco.task.TaskDescription; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/src/main/java/com/iexec/sms/tee/session/gramine/GramineSessionHandlerService.java b/src/main/java/com/iexec/sms/tee/session/gramine/GramineSessionHandlerService.java index 862899be..d0f171df 100644 --- a/src/main/java/com/iexec/sms/tee/session/gramine/GramineSessionHandlerService.java +++ b/src/main/java/com/iexec/sms/tee/session/gramine/GramineSessionHandlerService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.tee.session.gramine; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.api.TeeSessionGenerationError; import com.iexec.sms.tee.ConditionalOnTeeFramework; import com.iexec.sms.tee.session.TeeSessionLogConfiguration; diff --git a/src/main/java/com/iexec/sms/tee/session/gramine/GramineSessionMakerService.java b/src/main/java/com/iexec/sms/tee/session/gramine/GramineSessionMakerService.java index 86de236e..253683ad 100644 --- a/src/main/java/com/iexec/sms/tee/session/gramine/GramineSessionMakerService.java +++ b/src/main/java/com/iexec/sms/tee/session/gramine/GramineSessionMakerService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.tee.session.gramine; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.tee.ConditionalOnTeeFramework; import com.iexec.sms.tee.session.base.SecretEnclaveBase; import com.iexec.sms.tee.session.base.SecretSessionBase; diff --git a/src/main/java/com/iexec/sms/tee/session/gramine/sps/SpsConfiguration.java b/src/main/java/com/iexec/sms/tee/session/gramine/sps/SpsConfiguration.java index bb2e628a..c9d6dbb8 100644 --- a/src/main/java/com/iexec/sms/tee/session/gramine/sps/SpsConfiguration.java +++ b/src/main/java/com/iexec/sms/tee/session/gramine/sps/SpsConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2023 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. @@ -16,8 +16,8 @@ package com.iexec.sms.tee.session.gramine.sps; -import com.iexec.common.tee.TeeFramework; import com.iexec.common.utils.FeignBuilder; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.tee.ConditionalOnTeeFramework; import feign.Logger.Level; import lombok.Getter; diff --git a/src/main/java/com/iexec/sms/tee/session/scone/SconeSessionHandlerService.java b/src/main/java/com/iexec/sms/tee/session/scone/SconeSessionHandlerService.java index a77e31c0..3c9f60f7 100644 --- a/src/main/java/com/iexec/sms/tee/session/scone/SconeSessionHandlerService.java +++ b/src/main/java/com/iexec/sms/tee/session/scone/SconeSessionHandlerService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.tee.session.scone; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.api.TeeSessionGenerationError; import com.iexec.sms.tee.ConditionalOnTeeFramework; import com.iexec.sms.tee.session.TeeSessionLogConfiguration; diff --git a/src/main/java/com/iexec/sms/tee/session/scone/SconeSessionMakerService.java b/src/main/java/com/iexec/sms/tee/session/scone/SconeSessionMakerService.java index 52b48cf1..7ff2f9a6 100644 --- a/src/main/java/com/iexec/sms/tee/session/scone/SconeSessionMakerService.java +++ b/src/main/java/com/iexec/sms/tee/session/scone/SconeSessionMakerService.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.tee.session.scone; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.api.config.TeeServicesProperties; import com.iexec.sms.tee.ConditionalOnTeeFramework; import com.iexec.sms.tee.session.base.SecretEnclaveBase; diff --git a/src/main/java/com/iexec/sms/tee/session/scone/SconeSessionSecurityConfig.java b/src/main/java/com/iexec/sms/tee/session/scone/SconeSessionSecurityConfig.java index 1124f157..8acd071e 100644 --- a/src/main/java/com/iexec/sms/tee/session/scone/SconeSessionSecurityConfig.java +++ b/src/main/java/com/iexec/sms/tee/session/scone/SconeSessionSecurityConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.tee.session.scone; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.tee.ConditionalOnTeeFramework; import lombok.Getter; import org.springframework.beans.factory.annotation.Value; diff --git a/src/main/java/com/iexec/sms/tee/session/scone/cas/CasClient.java b/src/main/java/com/iexec/sms/tee/session/scone/cas/CasClient.java index 0ed6f964..e9b2edf7 100644 --- a/src/main/java/com/iexec/sms/tee/session/scone/cas/CasClient.java +++ b/src/main/java/com/iexec/sms/tee/session/scone/cas/CasClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.tee.session.scone.cas; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.ssl.TwoWaySslClient; import com.iexec.sms.tee.ConditionalOnTeeFramework; import org.springframework.http.HttpEntity; diff --git a/src/main/java/com/iexec/sms/tee/session/scone/cas/CasConfiguration.java b/src/main/java/com/iexec/sms/tee/session/scone/cas/CasConfiguration.java index eeb96ac0..776ac570 100644 --- a/src/main/java/com/iexec/sms/tee/session/scone/cas/CasConfiguration.java +++ b/src/main/java/com/iexec/sms/tee/session/scone/cas/CasConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 IEXEC BLOCKCHAIN TECH + * Copyright 2021-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.tee.session.scone.cas; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.tee.ConditionalOnTeeFramework; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/iexec/sms/utils/EthereumCredentials.java b/src/main/java/com/iexec/sms/utils/EthereumCredentials.java index 8c16a909..90e8a50a 100644 --- a/src/main/java/com/iexec/sms/utils/EthereumCredentials.java +++ b/src/main/java/com/iexec/sms/utils/EthereumCredentials.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.utils; -import com.iexec.common.utils.CredentialsUtils; +import com.iexec.commons.poco.utils.CredentialsUtils; import lombok.AllArgsConstructor; import lombok.Data; import lombok.Getter; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 63c00e9c..3a0b92f2 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -35,12 +35,13 @@ encryption: aesKeyPath: ${IEXEC_SMS_STORAGE_ENCRYPTION_AES_KEY_PATH:/data/iexec-sms-aes.key} blockchain: - id: ${IEXEC_CHAIN_ID:17} - node-address: ${IEXEC_SMS_BLOCKCHAIN_NODE_ADDRESS:http://localhost:8545} - hub-address: ${IEXEC_HUB_ADDRESS:0xBF6B2B07e47326B7c8bfCb4A5460bef9f0Fd2002} + id: ${IEXEC_CHAIN_ID:134} + is-sidechain: ${IEXEC_IS_SIDECHAIN:true} + node-address: ${IEXEC_SMS_BLOCKCHAIN_NODE_ADDRESS:https://bellecour.iex.ec} + hub-address: ${IEXEC_HUB_ADDRESS:0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f} + block-time: ${IEXEC_BLOCK_TIME:PT5S} gas-price-multiplier: ${IEXEC_GAS_PRICE_MULTIPLIER:1.0} # txs will be sent with networkGasPrice*gasPriceMultiplier, 4.0 means superfast gas-price-cap: ${IEXEC_GAS_PRICE_CAP:22000000000} #in Wei, will be used for txs if networkGasPrice*gasPriceMultiplier > gasPriceCap - is-sidechain: ${IEXEC_IS_SIDECHAIN:false} logging: tee.display-debug-session: ${IEXEC_SMS_DISPLAY_DEBUG_SESSION:false} diff --git a/src/test/java/com/iexec/sms/authorization/AuthorizationServiceTests.java b/src/test/java/com/iexec/sms/authorization/AuthorizationServiceTests.java index 0ff228b8..183a1ed8 100644 --- a/src/test/java/com/iexec/sms/authorization/AuthorizationServiceTests.java +++ b/src/test/java/com/iexec/sms/authorization/AuthorizationServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -16,11 +16,11 @@ package com.iexec.sms.authorization; -import com.iexec.common.chain.ChainDeal; -import com.iexec.common.chain.ChainTask; -import com.iexec.common.chain.WorkerpoolAuthorization; -import com.iexec.common.security.Signature; -import com.iexec.common.utils.TestUtils; +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.security.Signature; +import com.iexec.commons.poco.utils.TestUtils; import com.iexec.sms.blockchain.IexecHubService; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -31,8 +31,8 @@ import java.util.Optional; -import static com.iexec.common.chain.ChainTaskStatus.ACTIVE; -import static com.iexec.common.chain.ChainTaskStatus.UNSET; +import static com.iexec.commons.poco.chain.ChainTaskStatus.ACTIVE; +import static com.iexec.commons.poco.chain.ChainTaskStatus.UNSET; import static com.iexec.sms.authorization.AuthorizationError.*; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; diff --git a/src/test/java/com/iexec/sms/blockchain/Web3jServiceTests.java b/src/test/java/com/iexec/sms/blockchain/Web3jServiceTests.java new file mode 100644 index 00000000..51dc255f --- /dev/null +++ b/src/test/java/com/iexec/sms/blockchain/Web3jServiceTests.java @@ -0,0 +1,57 @@ +/* + * Copyright 2023-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.iexec.sms.blockchain; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +import java.time.Duration; + +import static org.assertj.core.api.Assertions.assertThat; + +@ExtendWith(SpringExtension.class) +@EnableConfigurationProperties(value = BlockchainConfig.class) +@TestPropertySource(properties = { + "blockchain.id=134", + "blockchain.is-sidechain=true", + "blockchain.node-address=https://bellecour.iex.ec", + "blockchain.hub-address=0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f", + "blockchain.block-time=PT5S", + "blockchain.gas-price-multiplier=1.0", + "blockchain.gas-price-cap=22000000000" }) +class Web3jServiceTests { + @Autowired + private BlockchainConfig blockchainConfig; + + @Test + void checkBlockchainConfig() { + BlockchainConfig expectedConfig = new BlockchainConfig( + 134, true, "https://bellecour.iex.ec", + "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f", Duration.ofSeconds(5), + 1.0f, 22_000_000_000L + ); + assertThat(blockchainConfig).isEqualTo(expectedConfig); + } + @Test + void shouldCreateInstance() { + assertThat(new Web3jService(blockchainConfig)).isNotNull(); + } +} diff --git a/src/test/java/com/iexec/sms/tee/ConditionalOnTeeFrameworkTests.java b/src/test/java/com/iexec/sms/tee/ConditionalOnTeeFrameworkTests.java index be828dba..44218afa 100644 --- a/src/test/java/com/iexec/sms/tee/ConditionalOnTeeFrameworkTests.java +++ b/src/test/java/com/iexec/sms/tee/ConditionalOnTeeFrameworkTests.java @@ -1,6 +1,22 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.tee.session.generic.TeeSessionHandler; import com.iexec.sms.tee.session.gramine.GramineSessionHandlerService; import com.iexec.sms.tee.session.gramine.GramineSessionMakerService; diff --git a/src/test/java/com/iexec/sms/tee/TeeControllerTests.java b/src/test/java/com/iexec/sms/tee/TeeControllerTests.java index 252efb71..64acfee3 100644 --- a/src/test/java/com/iexec/sms/tee/TeeControllerTests.java +++ b/src/test/java/com/iexec/sms/tee/TeeControllerTests.java @@ -1,8 +1,24 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee; -import com.iexec.common.chain.WorkerpoolAuthorization; -import com.iexec.common.tee.TeeFramework; import com.iexec.common.web.ApiResponseBody; +import com.iexec.commons.poco.chain.WorkerpoolAuthorization; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.api.TeeSessionGenerationError; import com.iexec.sms.api.TeeSessionGenerationResponse; import com.iexec.sms.api.config.GramineServicesProperties; diff --git a/src/test/java/com/iexec/sms/tee/TeeFrameworkConverterTests.java b/src/test/java/com/iexec/sms/tee/TeeFrameworkConverterTests.java index 02697da5..ffd02474 100644 --- a/src/test/java/com/iexec/sms/tee/TeeFrameworkConverterTests.java +++ b/src/test/java/com/iexec/sms/tee/TeeFrameworkConverterTests.java @@ -1,11 +1,27 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import static com.iexec.common.tee.TeeFramework.GRAMINE; -import static com.iexec.common.tee.TeeFramework.SCONE; +import static com.iexec.commons.poco.tee.TeeFramework.GRAMINE; +import static com.iexec.commons.poco.tee.TeeFramework.SCONE; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/com/iexec/sms/tee/config/TeeWorkerInternalConfigurationTests.java b/src/test/java/com/iexec/sms/tee/config/TeeWorkerInternalConfigurationTests.java index 28554630..920bb40f 100644 --- a/src/test/java/com/iexec/sms/tee/config/TeeWorkerInternalConfigurationTests.java +++ b/src/test/java/com/iexec/sms/tee/config/TeeWorkerInternalConfigurationTests.java @@ -1,6 +1,22 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee.config; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.api.config.GramineServicesProperties; import com.iexec.sms.api.config.SconeServicesProperties; import com.iexec.sms.api.config.TeeAppProperties; diff --git a/src/test/java/com/iexec/sms/tee/session/TeeSessionServiceTests.java b/src/test/java/com/iexec/sms/tee/session/TeeSessionServiceTests.java index 4acc4227..c60a7524 100644 --- a/src/test/java/com/iexec/sms/tee/session/TeeSessionServiceTests.java +++ b/src/test/java/com/iexec/sms/tee/session/TeeSessionServiceTests.java @@ -1,7 +1,23 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee.session; -import com.iexec.common.task.TaskDescription; -import com.iexec.common.tee.TeeFramework; +import com.iexec.commons.poco.task.TaskDescription; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.api.TeeSessionGenerationError; import com.iexec.sms.api.TeeSessionGenerationResponse; import com.iexec.sms.blockchain.IexecHubService; diff --git a/src/test/java/com/iexec/sms/tee/session/TeeSessionTestUtils.java b/src/test/java/com/iexec/sms/tee/session/TeeSessionTestUtils.java index ad3cfdf2..3a866195 100644 --- a/src/test/java/com/iexec/sms/tee/session/TeeSessionTestUtils.java +++ b/src/test/java/com/iexec/sms/tee/session/TeeSessionTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2023 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. @@ -17,9 +17,9 @@ package com.iexec.sms.tee.session; import com.iexec.common.precompute.PreComputeUtils; -import com.iexec.common.task.TaskDescription; -import com.iexec.common.tee.TeeEnclaveConfiguration; import com.iexec.common.utils.IexecEnvUtils; +import com.iexec.commons.poco.task.TaskDescription; +import com.iexec.commons.poco.tee.TeeEnclaveConfiguration; import com.iexec.sms.secret.compute.OnChainObjectType; import com.iexec.sms.secret.compute.SecretOwnerRole; import com.iexec.sms.secret.compute.TeeTaskComputeSecret; @@ -110,7 +110,7 @@ public static TeeSessionRequest createSessionRequest(TaskDescription taskDescrip .build(); } - public static TaskDescription createTaskDescription(TeeEnclaveConfiguration enclaveConfig) { + public static TaskDescription.TaskDescriptionBuilder createTaskDescription(TeeEnclaveConfiguration enclaveConfig) { String appAddress = createEthereumAddress(); String requesterAddress = createEthereumAddress(); String beneficiaryAddress = createEthereumAddress(); @@ -133,8 +133,7 @@ public static TaskDescription createTaskDescription(TeeEnclaveConfiguration encl .secrets(Map.of("1", REQUESTER_SECRET_KEY_1, "2", REQUESTER_SECRET_KEY_2)) .botSize(1) .botFirstIndex(0) - .botIndex(0) - .build(); + .botIndex(0); } public static Map getPreComputeTokens() { diff --git a/src/test/java/com/iexec/sms/tee/session/base/SecretSessionBaseServiceTests.java b/src/test/java/com/iexec/sms/tee/session/base/SecretSessionBaseServiceTests.java index 9030e295..754cef9d 100644 --- a/src/test/java/com/iexec/sms/tee/session/base/SecretSessionBaseServiceTests.java +++ b/src/test/java/com/iexec/sms/tee/session/base/SecretSessionBaseServiceTests.java @@ -1,10 +1,26 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee.session.base; -import com.iexec.common.chain.DealParams; -import com.iexec.common.task.TaskDescription; -import com.iexec.common.tee.TeeEnclaveConfiguration; -import com.iexec.common.tee.TeeFramework; import com.iexec.common.utils.IexecEnvUtils; +import com.iexec.commons.poco.chain.DealParams; +import com.iexec.commons.poco.task.TaskDescription; +import com.iexec.commons.poco.tee.TeeEnclaveConfiguration; +import com.iexec.commons.poco.tee.TeeFramework; import com.iexec.sms.api.TeeSessionGenerationError; import com.iexec.sms.api.config.TeeAppProperties; import com.iexec.sms.api.config.TeeServicesProperties; @@ -38,9 +54,7 @@ import static com.iexec.sms.tee.session.TeeSessionTestUtils.*; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertThrows; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; @@ -82,7 +96,7 @@ void beforeEach() { // region getSecretsTokens @Test void shouldGetSecretsTokens() throws Exception { - TaskDescription taskDescription = createTaskDescription(enclaveConfig); + TaskDescription taskDescription = createTaskDescription(enclaveConfig).build(); TeeSessionRequest request = createSessionRequest(taskDescription); String beneficiary = request.getTaskDescription().getBeneficiary(); @@ -155,7 +169,7 @@ void shouldNotGetSecretsTokensSinceTaskDescriptionIsMissing() { // region getPreComputeTokens @Test void shouldGetPreComputeTokens() throws Exception { - TaskDescription taskDescription = createTaskDescription(enclaveConfig); + TaskDescription taskDescription = createTaskDescription(enclaveConfig).build(); TeeSessionRequest request = createSessionRequest(taskDescription); when(preComputeProperties.getFingerprint()) .thenReturn(PRE_COMPUTE_FINGERPRINT); @@ -171,7 +185,7 @@ void shouldGetPreComputeTokens() throws Exception { expectedTokens.put("IS_DATASET_REQUIRED", true); expectedTokens.put("IEXEC_DATASET_KEY", DATASET_KEY); expectedTokens.put("IEXEC_DATASET_URL", DATASET_URL); - expectedTokens.put("IEXEC_DATASET_FILENAME", DATASET_NAME); + expectedTokens.put("IEXEC_DATASET_FILENAME", DATASET_ADDRESS); expectedTokens.put("IEXEC_DATASET_CHECKSUM", DATASET_CHECKSUM); expectedTokens.put("IEXEC_INPUT_FILES_FOLDER", "/iexec_in"); expectedTokens.put("IEXEC_INPUT_FILES_NUMBER", "2"); @@ -212,7 +226,7 @@ void shouldGetPreComputeTokensWithoutDataset() throws Exception { // region getAppTokens @Test void shouldGetAppTokensForAdvancedTaskDescription() throws TeeSessionGenerationException { - TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig)); + TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig).build()); String appAddress = request.getTaskDescription().getAppAddress(); String requesterAddress = request.getTaskDescription().getRequester(); @@ -229,7 +243,7 @@ void shouldGetAppTokensForAdvancedTaskDescription() throws TeeSessionGenerationE expectedTokens.put("IEXEC_IN", "/iexec_in"); expectedTokens.put("IEXEC_OUT", "/iexec_out"); expectedTokens.put("IEXEC_DATASET_ADDRESS", DATASET_ADDRESS); - expectedTokens.put("IEXEC_DATASET_FILENAME", DATASET_NAME); + expectedTokens.put("IEXEC_DATASET_FILENAME", DATASET_ADDRESS); expectedTokens.put("IEXEC_BOT_SIZE", "1"); expectedTokens.put("IEXEC_BOT_FIRST_INDEX", "0"); expectedTokens.put("IEXEC_BOT_TASK_INDEX", "0"); @@ -292,7 +306,7 @@ void shouldGetTokensWithEmptyAppComputeSecretWhenSecretsDoNotExist() throws TeeS expectedTokens.put("IEXEC_IN", "/iexec_in"); expectedTokens.put("IEXEC_OUT", "/iexec_out"); expectedTokens.put("IEXEC_DATASET_ADDRESS", DATASET_ADDRESS); - expectedTokens.put("IEXEC_DATASET_FILENAME", DATASET_NAME); + expectedTokens.put("IEXEC_DATASET_FILENAME", DATASET_ADDRESS); expectedTokens.put("IEXEC_BOT_SIZE", "1"); expectedTokens.put("IEXEC_BOT_FIRST_INDEX", "0"); expectedTokens.put("IEXEC_BOT_TASK_INDEX", "0"); @@ -335,7 +349,8 @@ void shouldFailToGetAppTokensSinceNoEnclaveConfig() { @Test void shouldFailToGetAppTokensInvalidEnclaveConfig() { // invalid enclave config - TeeSessionRequest request = createSessionRequest(createTaskDescription(TeeEnclaveConfiguration.builder().build())); + final TaskDescription taskDescription = createTaskDescription(TeeEnclaveConfiguration.builder().build()).build(); + TeeSessionRequest request = createSessionRequest(taskDescription); TeeSessionGenerationException exception = assertThrows(TeeSessionGenerationException.class, () -> teeSecretsService.getAppTokens(request)); @@ -344,7 +359,7 @@ void shouldFailToGetAppTokensInvalidEnclaveConfig() { @Test void shouldAddMultipleRequesterSecrets() { - TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig)); + TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig).build()); String requesterAddress = request.getTaskDescription().getRequester(); addRequesterSecret(requesterAddress, REQUESTER_SECRET_KEY_1, REQUESTER_SECRET_VALUE_1); @@ -364,11 +379,12 @@ void shouldAddMultipleRequesterSecrets() { @Test void shouldFilterRequesterSecretIndexLowerThanZero() { - TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig)); + final TaskDescription taskDescription = createTaskDescription(enclaveConfig) + .secrets(Map.of("1", REQUESTER_SECRET_KEY_1, "-1", "out-of-bound-requester-secret")) + .build(); + TeeSessionRequest request = createSessionRequest(taskDescription); String requesterAddress = request.getTaskDescription().getRequester(); - request.getTaskDescription() - .setSecrets(Map.of("1", REQUESTER_SECRET_KEY_1, "-1", "out-of-bound-requester-secret")); addRequesterSecret(requesterAddress, REQUESTER_SECRET_KEY_1, REQUESTER_SECRET_VALUE_1); SecretEnclaveBase enclaveBase = assertDoesNotThrow(() -> teeSecretsService.getAppTokens(request)); verify(teeTaskComputeSecretService).getSecret(eq(OnChainObjectType.APPLICATION), eq(""), @@ -381,7 +397,7 @@ void shouldFilterRequesterSecretIndexLowerThanZero() { // region getPostComputeTokens @Test void shouldGetPostComputeTokens() throws Exception { - TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig)); + TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig).build()); String requesterAddress = request.getTaskDescription().getRequester(); @@ -437,8 +453,10 @@ void shouldNotGetPostComputeTokensSinceTaskDescriptionMissing() { // region getPostComputeEncryptionTokens @Test void shouldGetPostComputeStorageTokensWithCallback() { - final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig)); - sessionRequest.getTaskDescription().setCallback("callback"); + final TaskDescription taskDescription = createTaskDescription(enclaveConfig) + .callback("callback") + .build(); + final TeeSessionRequest sessionRequest = createSessionRequest(taskDescription); final Map tokens = assertDoesNotThrow( () -> teeSecretsService.getPostComputeStorageTokens(sessionRequest)); @@ -454,7 +472,7 @@ void shouldGetPostComputeStorageTokensWithCallback() { @Test void shouldGetPostComputeStorageTokensOnIpfs() { - final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig)); + final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig).build()); final TaskDescription taskDescription = sessionRequest.getTaskDescription(); final String secretValue = "Secret value"; @@ -476,9 +494,10 @@ void shouldGetPostComputeStorageTokensOnIpfs() { @Test void shouldGetPostComputeStorageTokensOnDropbox() { - final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig)); - final TaskDescription taskDescription = sessionRequest.getTaskDescription(); - taskDescription.setResultStorageProvider(DealParams.DROPBOX_RESULT_STORAGE_PROVIDER); + final TaskDescription taskDescription = createTaskDescription(enclaveConfig) + .resultStorageProvider(DealParams.DROPBOX_RESULT_STORAGE_PROVIDER) + .build(); + final TeeSessionRequest sessionRequest = createSessionRequest(taskDescription); final String secretValue = "Secret value"; when(web2SecretService.getDecryptedValue(taskDescription.getRequester(), @@ -499,7 +518,7 @@ void shouldGetPostComputeStorageTokensOnDropbox() { @Test void shouldNotGetPostComputeStorageTokensSinceNoSecret() { - final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig)); + final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig).build()); final TaskDescription taskDescription = sessionRequest.getTaskDescription(); when(web2SecretService.getDecryptedValue(taskDescription.getRequester(), @@ -517,8 +536,8 @@ void shouldNotGetPostComputeStorageTokensSinceNoSecret() { @Test void shouldGetPostComputeSignTokens() throws GeneralSecurityException { - final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig)); - final TaskDescription taskDescription = sessionRequest.getTaskDescription(); + final TaskDescription taskDescription = createTaskDescription(enclaveConfig).build(); + final TeeSessionRequest sessionRequest = createSessionRequest(taskDescription); final String taskId = taskDescription.getChainTaskId(); final EthereumCredentials credentials = EthereumCredentials.generate(); @@ -540,7 +559,7 @@ void shouldGetPostComputeSignTokens() throws GeneralSecurityException { @NullSource @ValueSource(strings = { "" }) void shouldNotGetPostComputeSignTokensSinceNoWorkerAddress(String emptyWorkerAddress) { - final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig)); + final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig).build()); final String taskId = sessionRequest.getTaskDescription().getChainTaskId(); sessionRequest.setWorkerAddress(emptyWorkerAddress); @@ -557,7 +576,7 @@ void shouldNotGetPostComputeSignTokensSinceNoWorkerAddress(String emptyWorkerAdd @NullSource @ValueSource(strings = { "" }) void shouldNotGetPostComputeSignTokensSinceNoEnclaveChallenge(String emptyEnclaveChallenge) { - final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig)); + final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig).build()); final String taskId = sessionRequest.getTaskDescription().getChainTaskId(); sessionRequest.setEnclaveChallenge(emptyEnclaveChallenge); @@ -572,7 +591,7 @@ void shouldNotGetPostComputeSignTokensSinceNoEnclaveChallenge(String emptyEnclav @Test void shouldNotGetPostComputeSignTokensSinceNoTeeChallenge() { - final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig)); + final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig).build()); final String taskId = sessionRequest.getTaskDescription().getChainTaskId(); when(teeChallengeService.getOrCreate(taskId, true)) @@ -589,7 +608,7 @@ void shouldNotGetPostComputeSignTokensSinceNoTeeChallenge() { @Test void shouldNotGetPostComputeSignTokensSinceNoEnclaveCredentials() { - final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig)); + final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig).build()); final String taskId = sessionRequest.getTaskDescription().getChainTaskId(); when(teeChallengeService.getOrCreate(taskId, true)) @@ -606,7 +625,7 @@ void shouldNotGetPostComputeSignTokensSinceNoEnclaveCredentials() { @Test void shouldNotGetPostComputeSignTokensSinceNoEnclaveCredentialsPrivateKey() { - final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig)); + final TeeSessionRequest sessionRequest = createSessionRequest(createTaskDescription(enclaveConfig).build()); final String taskId = sessionRequest.getTaskDescription().getChainTaskId(); when(teeChallengeService.getOrCreate(taskId, true)) @@ -624,7 +643,7 @@ void shouldNotGetPostComputeSignTokensSinceNoEnclaveCredentialsPrivateKey() { @Test void shouldGetPostComputeEncryptionTokensWithEncryption() { - TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig)); + TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig).build()); String beneficiary = request.getTaskDescription().getBeneficiary(); when(web2SecretService.getDecryptedValue( @@ -643,8 +662,10 @@ void shouldGetPostComputeEncryptionTokensWithEncryption() { @Test void shouldGetPostComputeEncryptionTokensWithoutEncryption() { - TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig)); - request.getTaskDescription().setResultEncryption(false); + final TaskDescription taskDescription = createTaskDescription(enclaveConfig) + .isResultEncryption(false) + .build(); + TeeSessionRequest request = createSessionRequest(taskDescription); final Map encryptionTokens = assertDoesNotThrow( () -> teeSecretsService.getPostComputeEncryptionTokens(request)); @@ -657,7 +678,7 @@ void shouldGetPostComputeEncryptionTokensWithoutEncryption() { @Test void shouldNotGetPostComputeEncryptionTokensSinceEmptyBeneficiaryKey() { - TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig)); + TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig).build()); when(web2SecretService.getDecryptedValue( request.getTaskDescription().getBeneficiary(), diff --git a/src/test/java/com/iexec/sms/tee/session/gramine/GramineSessionHandlerServiceTests.java b/src/test/java/com/iexec/sms/tee/session/gramine/GramineSessionHandlerServiceTests.java index 6d9a8a9f..caeb5a40 100644 --- a/src/test/java/com/iexec/sms/tee/session/gramine/GramineSessionHandlerServiceTests.java +++ b/src/test/java/com/iexec/sms/tee/session/gramine/GramineSessionHandlerServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2023 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. @@ -16,7 +16,7 @@ package com.iexec.sms.tee.session.gramine; -import com.iexec.common.task.TaskDescription; +import com.iexec.commons.poco.task.TaskDescription; import com.iexec.sms.api.TeeSessionGenerationError; import com.iexec.sms.tee.session.TeeSessionLogConfiguration; import com.iexec.sms.tee.session.generic.TeeSessionGenerationException; @@ -34,9 +34,7 @@ import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; -import static org.junit.Assert.assertThrows; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -62,7 +60,7 @@ void beforeEach() { @Test void shouldBuildAndPostSession(CapturedOutput output) throws TeeSessionGenerationException { TeeSessionRequest request = mock(TeeSessionRequest.class); - TaskDescription taskDescription = mock(TaskDescription.class); + TaskDescription taskDescription = TaskDescription.builder().build(); when(request.getTaskDescription()).thenReturn(taskDescription); GramineSession spsSession = mock(GramineSession.class); when(spsSession.toString()).thenReturn("sessionContent"); @@ -94,7 +92,7 @@ void shouldNotBuildAndPostSessionSinceBuildSessionFailed() void shouldNotBuildAndPostSessionSincePostSessionFailed() throws TeeSessionGenerationException { TeeSessionRequest request = mock(TeeSessionRequest.class); - TaskDescription taskDescription = mock(TaskDescription.class); + TaskDescription taskDescription = TaskDescription.builder().build(); when(request.getTaskDescription()).thenReturn(taskDescription); GramineSession spsSession = mock(GramineSession.class); when(spsSession.toString()).thenReturn("sessionContent"); diff --git a/src/test/java/com/iexec/sms/tee/session/gramine/GramineSessionMakerServiceTests.java b/src/test/java/com/iexec/sms/tee/session/gramine/GramineSessionMakerServiceTests.java index 9fedc989..e3d58463 100644 --- a/src/test/java/com/iexec/sms/tee/session/gramine/GramineSessionMakerServiceTests.java +++ b/src/test/java/com/iexec/sms/tee/session/gramine/GramineSessionMakerServiceTests.java @@ -1,7 +1,23 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee.session.gramine; -import com.iexec.common.tee.TeeEnclaveConfiguration; import com.iexec.common.utils.FileHelper; +import com.iexec.commons.poco.tee.TeeEnclaveConfiguration; import com.iexec.sms.api.config.GramineServicesProperties; import com.iexec.sms.api.config.TeeAppProperties; import com.iexec.sms.tee.session.base.SecretEnclaveBase; @@ -15,7 +31,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.testcontainers.shaded.org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.Yaml; import java.util.Map; @@ -48,7 +64,7 @@ void shouldGetSessionJson() throws Exception { TeeEnclaveConfiguration enclaveConfig = TeeEnclaveConfiguration.builder() .fingerprint(APP_FINGERPRINT) .build(); - TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig)); + TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig).build()); when(postComputeProperties.getFingerprint()).thenReturn(POST_COMPUTE_FINGERPRINT); when(postComputeProperties.getEntrypoint()).thenReturn(POST_COMPUTE_ENTRYPOINT); diff --git a/src/test/java/com/iexec/sms/tee/session/scone/SconeSessionHandlerServiceTests.java b/src/test/java/com/iexec/sms/tee/session/scone/SconeSessionHandlerServiceTests.java index a726ec46..694c6e22 100644 --- a/src/test/java/com/iexec/sms/tee/session/scone/SconeSessionHandlerServiceTests.java +++ b/src/test/java/com/iexec/sms/tee/session/scone/SconeSessionHandlerServiceTests.java @@ -1,6 +1,22 @@ +/* + * Copyright 2022-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.iexec.sms.tee.session.scone; -import com.iexec.common.task.TaskDescription; +import com.iexec.commons.poco.task.TaskDescription; import com.iexec.sms.api.TeeSessionGenerationError; import com.iexec.sms.tee.session.TeeSessionLogConfiguration; import com.iexec.sms.tee.session.generic.TeeSessionGenerationException; @@ -18,9 +34,7 @@ import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.http.ResponseEntity; -import static org.junit.Assert.assertThrows; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -49,7 +63,7 @@ void beforeEach() { void shouldBuildAndPostSessionWithLogs(CapturedOutput output) throws TeeSessionGenerationException { TeeSessionRequest request = mock(TeeSessionRequest.class); - TaskDescription taskDescription = mock(TaskDescription.class); + TaskDescription taskDescription = TaskDescription.builder().build(); when(request.getTaskDescription()).thenReturn(taskDescription); SconeSession casSession = mock(SconeSession.class); when(casSession.toString()).thenReturn("sessionContent"); @@ -72,7 +86,7 @@ void shouldBuildAndPostSessionWithLogs(CapturedOutput output) void shouldBuildAndPostSessionWithoutLogs(CapturedOutput output) throws TeeSessionGenerationException { TeeSessionRequest request = mock(TeeSessionRequest.class); - TaskDescription taskDescription = mock(TaskDescription.class); + TaskDescription taskDescription = TaskDescription.builder().build(); when(request.getTaskDescription()).thenReturn(taskDescription); SconeSession casSession = mock(SconeSession.class); when(casSession.toString()).thenReturn("sessionContent"); @@ -108,7 +122,7 @@ void shouldNotBuildAndPostSessionSinceBuildSessionFailed() void shouldNotBuildAndPostSessionSincePostSessionFailed() throws TeeSessionGenerationException { TeeSessionRequest request = mock(TeeSessionRequest.class); - TaskDescription taskDescription = mock(TaskDescription.class); + TaskDescription taskDescription = TaskDescription.builder().build(); when(request.getTaskDescription()).thenReturn(taskDescription); SconeSession casSession = mock(SconeSession.class); when(sessionService.generateSession(request)).thenReturn(casSession); @@ -125,7 +139,7 @@ void shouldNotBuildAndPostSessionSincePostSessionFailed() void shouldNotBuildAndPostSessionSinceNoResponse() throws TeeSessionGenerationException { TeeSessionRequest request = mock(TeeSessionRequest.class); - TaskDescription taskDescription = mock(TaskDescription.class); + TaskDescription taskDescription = TaskDescription.builder().build(); when(request.getTaskDescription()).thenReturn(taskDescription); SconeSession casSession = mock(SconeSession.class); when(sessionService.generateSession(request)).thenReturn(casSession); diff --git a/src/test/java/com/iexec/sms/tee/session/scone/SconeSessionMakerServiceTests.java b/src/test/java/com/iexec/sms/tee/session/scone/SconeSessionMakerServiceTests.java index 1f7e77df..be8ce610 100644 --- a/src/test/java/com/iexec/sms/tee/session/scone/SconeSessionMakerServiceTests.java +++ b/src/test/java/com/iexec/sms/tee/session/scone/SconeSessionMakerServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2023 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. @@ -16,8 +16,8 @@ package com.iexec.sms.tee.session.scone; -import com.iexec.common.tee.TeeEnclaveConfiguration; import com.iexec.common.utils.FileHelper; +import com.iexec.commons.poco.tee.TeeEnclaveConfiguration; import com.iexec.sms.api.config.SconeServicesProperties; import com.iexec.sms.api.config.TeeAppProperties; import com.iexec.sms.tee.session.base.SecretEnclaveBase; @@ -73,7 +73,7 @@ void shouldGetSessionYml() throws Exception { .fingerprint(APP_FINGERPRINT) .entrypoint(APP_ENTRYPOINT) .build(); - TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig)); + TeeSessionRequest request = createSessionRequest(createTaskDescription(enclaveConfig).build()); when(preComputeProperties.getEntrypoint()).thenReturn(PRE_COMPUTE_ENTRYPOINT); when(postComputeProperties.getEntrypoint()).thenReturn(POST_COMPUTE_ENTRYPOINT); diff --git a/src/test/java/com/iexec/sms/utils/EthereumCredentialsTest.java b/src/test/java/com/iexec/sms/utils/EthereumCredentialsTest.java index 97847712..880b8629 100644 --- a/src/test/java/com/iexec/sms/utils/EthereumCredentialsTest.java +++ b/src/test/java/com/iexec/sms/utils/EthereumCredentialsTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 IEXEC BLOCKCHAIN TECH + * Copyright 2021-2023 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. @@ -16,8 +16,8 @@ package com.iexec.sms.utils; -import com.iexec.common.utils.BytesUtils; import com.iexec.common.utils.EthAddress; +import com.iexec.commons.poco.utils.BytesUtils; import org.junit.jupiter.api.Test; import org.web3j.crypto.Credentials;