From 4edc16823076c1162b0f5889e692b1c56cea656b Mon Sep 17 00:00:00 2001 From: Ionut Mihalcea Date: Mon, 27 Apr 2020 11:09:04 +0100 Subject: [PATCH] Move end to end tests to own crate This commit moves the PARSEC end-to-end tests into their own crate and refactors the test script along with it. Signed-off-by: Ionut Mihalcea --- .github/workflows/ci.yml | 40 +++++++++---------- .travis.yml | 8 ++-- e2e_tests/.gitignore | 2 + e2e_tests/Cargo.toml | 27 +++++++++++++ .../provider_cfg/all}/Dockerfile | 0 .../provider_cfg/all}/config.toml | 0 .../provider_cfg/mbed-crypto/Dockerfile | 0 .../provider_cfg/mbed-crypto/config.toml | 0 .../provider_cfg/pkcs11/Dockerfile | 0 .../provider_cfg/pkcs11/config.toml | 0 .../provider_cfg/pkcs11/find_slot_number.sh | 0 .../provider_cfg/tpm/Dockerfile | 0 .../provider_cfg/tpm/config.toml | 0 .../mod.rs => e2e_tests/src/lib.rs | 13 +++--- .../src}/raw_request.rs | 4 +- .../test_clients => e2e_tests/src}/stress.rs | 4 +- .../tests}/all_providers/mod.rs | 4 +- {tests => e2e_tests/tests}/mod.rs | 1 - .../tests}/per_provider/mod.rs | 0 .../normal_tests/asym_sign_verify.rs | 10 ++--- .../tests}/per_provider/normal_tests/auth.rs | 6 +-- .../tests}/per_provider/normal_tests/basic.rs | 6 +-- .../normal_tests/create_destroy_key.rs | 12 +++--- .../normal_tests/export_public_key.rs | 10 ++--- .../per_provider/normal_tests/import_key.rs | 10 ++--- .../normal_tests/key_attributes.rs | 10 +++-- .../tests}/per_provider/normal_tests/mod.rs | 0 .../tests}/per_provider/normal_tests/ping.rs | 14 +++---- .../tests}/per_provider/persistent_after.rs | 6 +-- .../tests}/per_provider/persistent_before.rs | 4 +- .../tests}/per_provider/stress_test.rs | 2 +- tests/ci.sh | 15 ++++--- 32 files changed, 121 insertions(+), 87 deletions(-) create mode 100644 e2e_tests/.gitignore create mode 100644 e2e_tests/Cargo.toml rename {tests/all_providers => e2e_tests/provider_cfg/all}/Dockerfile (100%) rename {tests/all_providers => e2e_tests/provider_cfg/all}/config.toml (100%) rename {tests/per_provider => e2e_tests}/provider_cfg/mbed-crypto/Dockerfile (100%) rename {tests/per_provider => e2e_tests}/provider_cfg/mbed-crypto/config.toml (100%) rename {tests/per_provider => e2e_tests}/provider_cfg/pkcs11/Dockerfile (100%) rename {tests/per_provider => e2e_tests}/provider_cfg/pkcs11/config.toml (100%) rename {tests/per_provider => e2e_tests}/provider_cfg/pkcs11/find_slot_number.sh (100%) rename {tests/per_provider => e2e_tests}/provider_cfg/tpm/Dockerfile (100%) rename {tests/per_provider => e2e_tests}/provider_cfg/tpm/config.toml (100%) rename tests/test_clients/mod.rs => e2e_tests/src/lib.rs (96%) rename {tests/test_clients => e2e_tests/src}/raw_request.rs (92%) rename {tests/test_clients => e2e_tests/src}/stress.rs (99%) rename {tests => e2e_tests/tests}/all_providers/mod.rs (96%) rename {tests => e2e_tests/tests}/mod.rs (97%) rename {tests => e2e_tests/tests}/per_provider/mod.rs (100%) rename {tests => e2e_tests/tests}/per_provider/normal_tests/asym_sign_verify.rs (97%) rename {tests => e2e_tests/tests}/per_provider/normal_tests/auth.rs (87%) rename {tests => e2e_tests/tests}/per_provider/normal_tests/basic.rs (93%) rename {tests => e2e_tests/tests}/per_provider/normal_tests/create_destroy_key.rs (92%) rename {tests => e2e_tests/tests}/per_provider/normal_tests/export_public_key.rs (92%) rename {tests => e2e_tests/tests}/per_provider/normal_tests/import_key.rs (96%) rename {tests => e2e_tests/tests}/per_provider/normal_tests/key_attributes.rs (93%) rename {tests => e2e_tests/tests}/per_provider/normal_tests/mod.rs (100%) rename {tests => e2e_tests/tests}/per_provider/normal_tests/ping.rs (67%) rename {tests => e2e_tests/tests}/per_provider/persistent_after.rs (89%) rename {tests => e2e_tests/tests}/per_provider/persistent_before.rs (91%) rename {tests => e2e_tests/tests}/per_provider/stress_test.rs (87%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df46ba57..c1ece402 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,38 +7,38 @@ jobs: name: Various tests targeting a Parsec image with all providers included runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Build the container - run: docker build -t all-providers tests/all_providers - - name: Run the container to execute the test script - run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec all-providers /tmp/parsec/tests/ci.sh all + - uses: actions/checkout@v1 + - name: Build the container + run: docker build -t all-providers e2e_tests/provider_cfg/all + - name: Run the container to execute the test script + run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec all-providers /tmp/parsec/tests/ci.sh all mbed-crypto-provider: name: Integration tests using Mbed Crypto provider runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Build the container - run: docker build -t mbed-crypto-provider tests/per_provider/provider_cfg/mbed-crypto - - name: Run the container to execute the test script - run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec mbed-crypto-provider /tmp/parsec/tests/ci.sh mbed-crypto + - uses: actions/checkout@v1 + - name: Build the container + run: docker build -t mbed-crypto-provider e2e_tests/provider_cfg/mbed-crypto + - name: Run the container to execute the test script + run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec mbed-crypto-provider /tmp/parsec/tests/ci.sh mbed-crypto pkcs11-provider: name: Integration tests using PKCS 11 provider runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Build the container - run: docker build -t pkcs11-provider tests/per_provider/provider_cfg/pkcs11 - - name: Run the container to execute the test script - run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec pkcs11-provider /tmp/parsec/tests/ci.sh pkcs11 + - uses: actions/checkout@v1 + - name: Build the container + run: docker build -t pkcs11-provider e2e_tests/provider_cfg/pkcs11 + - name: Run the container to execute the test script + run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec pkcs11-provider /tmp/parsec/tests/ci.sh pkcs11 tpm-provider: name: Integration tests using TPM provider runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Build the container - run: docker build -t tpm-provider tests/per_provider/provider_cfg/tpm - - name: Run the container to execute the test script - run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec tpm-provider /tmp/parsec/tests/ci.sh tpm + - uses: actions/checkout@v1 + - name: Build the container + run: docker build -t tpm-provider e2e_tests/provider_cfg/tpm + - name: Run the container to execute the test script + run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec tpm-provider /tmp/parsec/tests/ci.sh tpm diff --git a/.travis.yml b/.travis.yml index 591f6e97..6e24c709 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,14 +7,14 @@ services: jobs: include: - name: "Integration tests using Mbed Crypto provider" - env: DOCKER_IMAGE_NAME=mbed-crypto-provider DOCKER_IMAGE_PATH=tests/per_provider/provider_cfg/mbed-crypto SCRIPT="tests/ci.sh mbed-crypto" + env: DOCKER_IMAGE_NAME=mbed-crypto-provider DOCKER_IMAGE_PATH=e2e_tests/provider_cfg/mbed-crypto SCRIPT="tests/ci.sh mbed-crypto" - name: "Integration tests using PKCS 11 provider" - env: DOCKER_IMAGE_NAME=pkcs11-provider DOCKER_IMAGE_PATH=tests/per_provider/provider_cfg/pkcs11 SCRIPT="tests/ci.sh pkcs11" + env: DOCKER_IMAGE_NAME=pkcs11-provider DOCKER_IMAGE_PATH=e2e_tests/provider_cfg/pkcs11 SCRIPT="tests/ci.sh pkcs11" # PKCS11 tests are failing because of unidentified issues. # See https://github.com/parallaxsecond/parsec/issues/116 allow_failures: - - env: DOCKER_IMAGE_NAME=mbed-crypto-provider DOCKER_IMAGE_PATH=tests/per_provider/provider_cfg/mbed-crypto SCRIPT="tests/ci.sh mbed-crypto" - - env: DOCKER_IMAGE_NAME=pkcs11-provider DOCKER_IMAGE_PATH=tests/per_provider/provider_cfg/pkcs11 SCRIPT="tests/ci.sh pkcs11" + - env: DOCKER_IMAGE_NAME=mbed-crypto-provider DOCKER_IMAGE_PATH=e2e_tests/provider_cfg/mbed-crypto SCRIPT="tests/ci.sh mbed-crypto" + - env: DOCKER_IMAGE_NAME=pkcs11-provider DOCKER_IMAGE_PATH=e2e_tests/provider_cfg/pkcs11 SCRIPT="tests/ci.sh pkcs11" script: - docker build -t $DOCKER_IMAGE_NAME $DOCKER_IMAGE_PATH - docker run -v $(pwd):/tmp/parsec -w /tmp/parsec $DOCKER_IMAGE_NAME /tmp/parsec/$SCRIPT diff --git a/e2e_tests/.gitignore b/e2e_tests/.gitignore new file mode 100644 index 00000000..f2f9e58e --- /dev/null +++ b/e2e_tests/.gitignore @@ -0,0 +1,2 @@ +target +Cargo.lock \ No newline at end of file diff --git a/e2e_tests/Cargo.toml b/e2e_tests/Cargo.toml new file mode 100644 index 00000000..8d5ecd90 --- /dev/null +++ b/e2e_tests/Cargo.toml @@ -0,0 +1,27 @@ +# This crate should NOT be upstreamed to crates.io; it is only intended for +# PARSEC testing purposes (both locally and on CI) +[package] +name = "e2e_tests" +version = "0.1.0" +authors = ["Anton Antonov ", + "Paul Howard ", + "Ionut Mihalcea ", + "Hugues de Valon "] +description = "End to end testing framework for PARSEC" +license = "Apache-2.0" +edition = "2018" +publish = false + +[dependencies] +num_cpus = "1.13.0" +picky-asn1-der = "0.2.2" +picky-asn1 = "0.2.1" +serde = { version = "1.0", features = ["derive"] } +sha2 = "0.8.1" +parsec-client = { version = "0.2.0", features = ["testing"] } +log = "0.4.8" +rand = "0.7.3" + +[dev-dependencies] +env_logger = "0.7.1" +uuid = "0.7.4" diff --git a/tests/all_providers/Dockerfile b/e2e_tests/provider_cfg/all/Dockerfile similarity index 100% rename from tests/all_providers/Dockerfile rename to e2e_tests/provider_cfg/all/Dockerfile diff --git a/tests/all_providers/config.toml b/e2e_tests/provider_cfg/all/config.toml similarity index 100% rename from tests/all_providers/config.toml rename to e2e_tests/provider_cfg/all/config.toml diff --git a/tests/per_provider/provider_cfg/mbed-crypto/Dockerfile b/e2e_tests/provider_cfg/mbed-crypto/Dockerfile similarity index 100% rename from tests/per_provider/provider_cfg/mbed-crypto/Dockerfile rename to e2e_tests/provider_cfg/mbed-crypto/Dockerfile diff --git a/tests/per_provider/provider_cfg/mbed-crypto/config.toml b/e2e_tests/provider_cfg/mbed-crypto/config.toml similarity index 100% rename from tests/per_provider/provider_cfg/mbed-crypto/config.toml rename to e2e_tests/provider_cfg/mbed-crypto/config.toml diff --git a/tests/per_provider/provider_cfg/pkcs11/Dockerfile b/e2e_tests/provider_cfg/pkcs11/Dockerfile similarity index 100% rename from tests/per_provider/provider_cfg/pkcs11/Dockerfile rename to e2e_tests/provider_cfg/pkcs11/Dockerfile diff --git a/tests/per_provider/provider_cfg/pkcs11/config.toml b/e2e_tests/provider_cfg/pkcs11/config.toml similarity index 100% rename from tests/per_provider/provider_cfg/pkcs11/config.toml rename to e2e_tests/provider_cfg/pkcs11/config.toml diff --git a/tests/per_provider/provider_cfg/pkcs11/find_slot_number.sh b/e2e_tests/provider_cfg/pkcs11/find_slot_number.sh similarity index 100% rename from tests/per_provider/provider_cfg/pkcs11/find_slot_number.sh rename to e2e_tests/provider_cfg/pkcs11/find_slot_number.sh diff --git a/tests/per_provider/provider_cfg/tpm/Dockerfile b/e2e_tests/provider_cfg/tpm/Dockerfile similarity index 100% rename from tests/per_provider/provider_cfg/tpm/Dockerfile rename to e2e_tests/provider_cfg/tpm/Dockerfile diff --git a/tests/per_provider/provider_cfg/tpm/config.toml b/e2e_tests/provider_cfg/tpm/config.toml similarity index 100% rename from tests/per_provider/provider_cfg/tpm/config.toml rename to e2e_tests/provider_cfg/tpm/config.toml diff --git a/tests/test_clients/mod.rs b/e2e_tests/src/lib.rs similarity index 96% rename from tests/test_clients/mod.rs rename to e2e_tests/src/lib.rs index 46b3e947..6b0d64c1 100644 --- a/tests/test_clients/mod.rs +++ b/e2e_tests/src/lib.rs @@ -11,12 +11,15 @@ pub use parsec_client::error; use log::error; use parsec_client::auth::AuthenticationData; use parsec_client::core::basic_client::BasicClient; +use parsec_client::core::interface::operations::list_providers::ProviderInfo; +use parsec_client::core::interface::operations::psa_algorithm::{ + Algorithm, AsymmetricSignature, Hash, +}; +use parsec_client::core::interface::operations::psa_key_attributes::{ + KeyAttributes, KeyPolicy, KeyType, UsageFlags, +}; +use parsec_client::core::interface::requests::{Opcode, ProviderID, ResponseStatus, Result}; use parsec_client::error::Error; -use parsec_interface::operations::list_providers::ProviderInfo; -use parsec_interface::operations::psa_algorithm::{Algorithm, AsymmetricSignature, Hash}; -use parsec_interface::operations::psa_key_attributes::*; -use parsec_interface::operations::psa_key_attributes::{KeyAttributes, KeyPolicy, UsageFlags}; -use parsec_interface::requests::{Opcode, ProviderID, ResponseStatus, Result}; use std::collections::HashSet; use std::time::Duration; diff --git a/tests/test_clients/raw_request.rs b/e2e_tests/src/raw_request.rs similarity index 92% rename from tests/test_clients/raw_request.rs rename to e2e_tests/src/raw_request.rs index 40ccdd0a..1642a926 100644 --- a/tests/test_clients/raw_request.rs +++ b/e2e_tests/src/raw_request.rs @@ -1,7 +1,7 @@ // Copyright 2020 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use parsec_interface::requests::request::RawHeader; -use parsec_interface::requests::{Response, Result}; +use parsec_client::core::interface::requests::request::RawHeader; +use parsec_client::core::interface::requests::{Response, Result}; use std::io::Write; use std::os::unix::net::UnixStream; use std::thread; diff --git a/tests/test_clients/stress.rs b/e2e_tests/src/stress.rs similarity index 99% rename from tests/test_clients/stress.rs rename to e2e_tests/src/stress.rs index ec485efa..c26c7aea 100644 --- a/tests/test_clients/stress.rs +++ b/e2e_tests/src/stress.rs @@ -1,8 +1,8 @@ // Copyright 2020 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use crate::test_clients::TestClient; +use super::TestClient; use log::info; -use parsec_interface::requests::ResponseStatus; +use parsec_client::core::interface::requests::ResponseStatus; use rand::Rng; use rand::{ distributions::{Alphanumeric, Distribution, Standard}, diff --git a/tests/all_providers/mod.rs b/e2e_tests/tests/all_providers/mod.rs similarity index 96% rename from tests/all_providers/mod.rs rename to e2e_tests/tests/all_providers/mod.rs index 4e51dde4..f2778196 100644 --- a/tests/all_providers/mod.rs +++ b/e2e_tests/tests/all_providers/mod.rs @@ -1,7 +1,7 @@ // Copyright 2019 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use crate::test_clients::TestClient; -use parsec_interface::requests::{Opcode, ProviderID, Result}; +use e2e_tests::TestClient; +use parsec_client::core::interface::requests::{Opcode, ProviderID, Result}; use std::collections::HashSet; use uuid::Uuid; diff --git a/tests/mod.rs b/e2e_tests/tests/mod.rs similarity index 97% rename from tests/mod.rs rename to e2e_tests/tests/mod.rs index cda85d60..8295d961 100644 --- a/tests/mod.rs +++ b/e2e_tests/tests/mod.rs @@ -32,4 +32,3 @@ mod all_providers; mod per_provider; -mod test_clients; diff --git a/tests/per_provider/mod.rs b/e2e_tests/tests/per_provider/mod.rs similarity index 100% rename from tests/per_provider/mod.rs rename to e2e_tests/tests/per_provider/mod.rs diff --git a/tests/per_provider/normal_tests/asym_sign_verify.rs b/e2e_tests/tests/per_provider/normal_tests/asym_sign_verify.rs similarity index 97% rename from tests/per_provider/normal_tests/asym_sign_verify.rs rename to e2e_tests/tests/per_provider/normal_tests/asym_sign_verify.rs index cdbc0531..4ecaf4fc 100644 --- a/tests/per_provider/normal_tests/asym_sign_verify.rs +++ b/e2e_tests/tests/per_provider/normal_tests/asym_sign_verify.rs @@ -1,10 +1,10 @@ // Copyright 2019 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use crate::test_clients::TestClient; -use parsec_interface::operations::psa_algorithm::*; -use parsec_interface::operations::psa_key_attributes::*; -use parsec_interface::requests::ResponseStatus; -use parsec_interface::requests::Result; +use e2e_tests::TestClient; +use parsec_client::core::interface::operations::psa_algorithm::*; +use parsec_client::core::interface::operations::psa_key_attributes::*; +use parsec_client::core::interface::requests::ResponseStatus; +use parsec_client::core::interface::requests::Result; use sha2::{Digest, Sha256}; const HASH: [u8; 32] = [ diff --git a/tests/per_provider/normal_tests/auth.rs b/e2e_tests/tests/per_provider/normal_tests/auth.rs similarity index 87% rename from tests/per_provider/normal_tests/auth.rs rename to e2e_tests/tests/per_provider/normal_tests/auth.rs index cc3c1bd7..fbbffd25 100644 --- a/tests/per_provider/normal_tests/auth.rs +++ b/e2e_tests/tests/per_provider/normal_tests/auth.rs @@ -1,8 +1,8 @@ // Copyright 2019 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use crate::test_clients::TestClient; -use parsec_interface::requests::ResponseStatus; -use parsec_interface::requests::Result; +use e2e_tests::TestClient; +use parsec_client::core::interface::requests::ResponseStatus; +use parsec_client::core::interface::requests::Result; #[test] fn two_auths_same_key_name() -> Result<()> { diff --git a/tests/per_provider/normal_tests/basic.rs b/e2e_tests/tests/per_provider/normal_tests/basic.rs similarity index 93% rename from tests/per_provider/normal_tests/basic.rs rename to e2e_tests/tests/per_provider/normal_tests/basic.rs index 9aae052f..056a137b 100644 --- a/tests/per_provider/normal_tests/basic.rs +++ b/e2e_tests/tests/per_provider/normal_tests/basic.rs @@ -1,8 +1,8 @@ // Copyright 2019 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use crate::test_clients::RawRequestClient; -use parsec_interface::requests::request::RawHeader; -use parsec_interface::requests::{Opcode, ProviderID, ResponseStatus}; +use e2e_tests::RawRequestClient; +use parsec_client::core::interface::requests::request::RawHeader; +use parsec_client::core::interface::requests::{Opcode, ProviderID, ResponseStatus}; #[test] fn invalid_provider() { diff --git a/tests/per_provider/normal_tests/create_destroy_key.rs b/e2e_tests/tests/per_provider/normal_tests/create_destroy_key.rs similarity index 92% rename from tests/per_provider/normal_tests/create_destroy_key.rs rename to e2e_tests/tests/per_provider/normal_tests/create_destroy_key.rs index 5871ac7e..7f39a9e6 100644 --- a/tests/per_provider/normal_tests/create_destroy_key.rs +++ b/e2e_tests/tests/per_provider/normal_tests/create_destroy_key.rs @@ -1,12 +1,14 @@ // Copyright 2019 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use crate::test_clients::TestClient; -use parsec_interface::operations::psa_algorithm::{Algorithm, AsymmetricSignature, Hash}; -use parsec_interface::operations::psa_key_attributes::{ +use e2e_tests::TestClient; +use parsec_client::core::interface::operations::psa_algorithm::{ + Algorithm, AsymmetricSignature, Hash, +}; +use parsec_client::core::interface::operations::psa_key_attributes::{ KeyAttributes, KeyPolicy, KeyType, UsageFlags, }; -use parsec_interface::requests::ResponseStatus; -use parsec_interface::requests::Result; +use parsec_client::core::interface::requests::ResponseStatus; +use parsec_client::core::interface::requests::Result; use picky_asn1::wrapper::IntegerAsn1; use serde::{Deserialize, Serialize}; diff --git a/tests/per_provider/normal_tests/export_public_key.rs b/e2e_tests/tests/per_provider/normal_tests/export_public_key.rs similarity index 92% rename from tests/per_provider/normal_tests/export_public_key.rs rename to e2e_tests/tests/per_provider/normal_tests/export_public_key.rs index 68546077..19a7696a 100644 --- a/tests/per_provider/normal_tests/export_public_key.rs +++ b/e2e_tests/tests/per_provider/normal_tests/export_public_key.rs @@ -1,10 +1,10 @@ // Copyright 2019 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use crate::test_clients::TestClient; -use parsec_interface::operations::psa_algorithm::*; -use parsec_interface::operations::psa_key_attributes::*; -use parsec_interface::requests::ResponseStatus; -use parsec_interface::requests::Result; +use e2e_tests::TestClient; +use parsec_client::core::interface::operations::psa_algorithm::*; +use parsec_client::core::interface::operations::psa_key_attributes::*; +use parsec_client::core::interface::requests::ResponseStatus; +use parsec_client::core::interface::requests::Result; use picky_asn1::wrapper::IntegerAsn1; use serde::{Deserialize, Serialize}; diff --git a/tests/per_provider/normal_tests/import_key.rs b/e2e_tests/tests/per_provider/normal_tests/import_key.rs similarity index 96% rename from tests/per_provider/normal_tests/import_key.rs rename to e2e_tests/tests/per_provider/normal_tests/import_key.rs index c784e6a1..bdec2cc2 100644 --- a/tests/per_provider/normal_tests/import_key.rs +++ b/e2e_tests/tests/per_provider/normal_tests/import_key.rs @@ -1,10 +1,10 @@ // Copyright 2019 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use crate::test_clients::TestClient; -use parsec_interface::operations::psa_algorithm::*; -use parsec_interface::operations::psa_key_attributes::*; -use parsec_interface::requests::ResponseStatus; -use parsec_interface::requests::Result; +use e2e_tests::TestClient; +use parsec_client::core::interface::operations::psa_algorithm::*; +use parsec_client::core::interface::operations::psa_key_attributes::*; +use parsec_client::core::interface::requests::ResponseStatus; +use parsec_client::core::interface::requests::Result; use picky_asn1::wrapper::IntegerAsn1; use serde::{Deserialize, Serialize}; diff --git a/tests/per_provider/normal_tests/key_attributes.rs b/e2e_tests/tests/per_provider/normal_tests/key_attributes.rs similarity index 93% rename from tests/per_provider/normal_tests/key_attributes.rs rename to e2e_tests/tests/per_provider/normal_tests/key_attributes.rs index f57431d7..bfcf1c12 100644 --- a/tests/per_provider/normal_tests/key_attributes.rs +++ b/e2e_tests/tests/per_provider/normal_tests/key_attributes.rs @@ -1,11 +1,13 @@ // Copyright 2020 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use crate::test_clients::TestClient; -use parsec_interface::operations::psa_algorithm::{Algorithm, AsymmetricSignature, Cipher, Hash}; -use parsec_interface::operations::psa_key_attributes::{ +use e2e_tests::TestClient; +use parsec_client::core::interface::operations::psa_algorithm::{ + Algorithm, AsymmetricSignature, Cipher, Hash, +}; +use parsec_client::core::interface::operations::psa_key_attributes::{ KeyAttributes, KeyPolicy, KeyType, UsageFlags, }; -use parsec_interface::requests::{ProviderID, ResponseStatus}; +use parsec_client::core::interface::requests::{ProviderID, ResponseStatus}; // Ignored as only RSA key types are supported for now. #[ignore] diff --git a/tests/per_provider/normal_tests/mod.rs b/e2e_tests/tests/per_provider/normal_tests/mod.rs similarity index 100% rename from tests/per_provider/normal_tests/mod.rs rename to e2e_tests/tests/per_provider/normal_tests/mod.rs diff --git a/tests/per_provider/normal_tests/ping.rs b/e2e_tests/tests/per_provider/normal_tests/ping.rs similarity index 67% rename from tests/per_provider/normal_tests/ping.rs rename to e2e_tests/tests/per_provider/normal_tests/ping.rs index b4e7d385..531e9e54 100644 --- a/tests/per_provider/normal_tests/ping.rs +++ b/e2e_tests/tests/per_provider/normal_tests/ping.rs @@ -1,12 +1,12 @@ // Copyright 2019 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use crate::test_clients::RequestClient; -use crate::test_clients::TestClient; -use parsec_interface::requests::request::{Request, RequestAuth, RequestBody}; -use parsec_interface::requests::Opcode; -use parsec_interface::requests::ProviderID; -use parsec_interface::requests::ResponseStatus; -use parsec_interface::requests::Result; +use e2e_tests::RequestClient; +use e2e_tests::TestClient; +use parsec_client::core::interface::requests::request::{Request, RequestAuth, RequestBody}; +use parsec_client::core::interface::requests::Opcode; +use parsec_client::core::interface::requests::ProviderID; +use parsec_client::core::interface::requests::ResponseStatus; +use parsec_client::core::interface::requests::Result; #[test] fn test_ping() -> Result<()> { diff --git a/tests/per_provider/persistent_after.rs b/e2e_tests/tests/per_provider/persistent_after.rs similarity index 89% rename from tests/per_provider/persistent_after.rs rename to e2e_tests/tests/per_provider/persistent_after.rs index ac5be036..2ddc9e09 100644 --- a/tests/per_provider/persistent_after.rs +++ b/e2e_tests/tests/per_provider/persistent_after.rs @@ -3,9 +3,9 @@ // These functions test for the service persistency to shutdown. They will be executed after the // service is shutdown, after the persistent_before tests are executed. -use crate::test_clients::TestClient; -use parsec_interface::requests::Result; -use parsec_interface::requests::{ProviderID, ResponseStatus}; +use e2e_tests::TestClient; +use parsec_client::core::interface::requests::Result; +use parsec_client::core::interface::requests::{ProviderID, ResponseStatus}; const HASH: [u8; 32] = [ 0x69, 0x3E, 0xDB, 0x1B, 0x22, 0x79, 0x03, 0xF4, 0xC0, 0xBF, 0xD6, 0x91, 0x76, 0x37, 0x84, 0xA2, diff --git a/tests/per_provider/persistent_before.rs b/e2e_tests/tests/per_provider/persistent_before.rs similarity index 91% rename from tests/per_provider/persistent_before.rs rename to e2e_tests/tests/per_provider/persistent_before.rs index 615a14b4..88ccd092 100644 --- a/tests/per_provider/persistent_before.rs +++ b/e2e_tests/tests/per_provider/persistent_before.rs @@ -3,8 +3,8 @@ // These functions test for the service persistency to shutdown. They will be executed before the // service is shutdown and before the persistent_after tests are executed. -use crate::test_clients::TestClient; -use parsec_interface::requests::Result; +use e2e_tests::TestClient; +use parsec_client::core::interface::requests::Result; const HASH: [u8; 32] = [ 0x69, 0x3E, 0xDB, 0x1B, 0x22, 0x79, 0x03, 0xF4, 0xC0, 0xBF, 0xD6, 0x91, 0x76, 0x37, 0x84, 0xA2, diff --git a/tests/per_provider/stress_test.rs b/e2e_tests/tests/per_provider/stress_test.rs similarity index 87% rename from tests/per_provider/stress_test.rs rename to e2e_tests/tests/per_provider/stress_test.rs index db2792d4..68a5f119 100644 --- a/tests/per_provider/stress_test.rs +++ b/e2e_tests/tests/per_provider/stress_test.rs @@ -1,6 +1,6 @@ // Copyright 2019 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use crate::test_clients::stress::{StressClient, StressTestConfig}; +use e2e_tests::stress::{StressClient, StressTestConfig}; use std::time::Duration; #[test] diff --git a/tests/ci.sh b/tests/ci.sh index 9b412fe6..7d48c542 100755 --- a/tests/ci.sh +++ b/tests/ci.sh @@ -63,12 +63,11 @@ while [ "$#" -gt 0 ]; do error_msg "Only one provider name must be given" fi PROVIDER_NAME=$1 + CONFIG_PATH="e2e_tests/provider_cfg/$1/config.toml" if [ "$PROVIDER_NAME" = "all" ]; then FEATURES="--features=all-providers" - CONFIG_PATH="tests/all_providers/config.toml" else FEATURES="--features=$1-provider" - CONFIG_PATH="tests/per_provider/provider_cfg/$1/config.toml" fi ;; *) @@ -96,7 +95,7 @@ fi if [ "$PROVIDER_NAME" = "pkcs11" ] || [ "$PROVIDER_NAME" = "all" ]; then # Find and append the slot number at the end of the configuration file. - tests/per_provider/provider_cfg/pkcs11/find_slot_number.sh $CONFIG_PATH + e2e_tests/provider_cfg/pkcs11/find_slot_number.sh $CONFIG_PATH fi echo "Build test" @@ -127,14 +126,14 @@ pgrep -f target/debug/parsec >/dev/null if [ "$PROVIDER_NAME" = "all" ]; then echo "Execute all-providers tests" - RUST_BACKTRACE=1 cargo test $FEATURES all_providers + RUST_BACKTRACE=1 cargo test --manifest-path ./e2e_tests/Cargo.toml all_providers else # Per provider tests echo "Execute normal tests" - RUST_BACKTRACE=1 cargo test $FEATURES normal_tests + RUST_BACKTRACE=1 cargo test --manifest-path ./e2e_tests/Cargo.toml normal_tests echo "Execute persistent test, before the reload" - RUST_BACKTRACE=1 cargo test $FEATURES persistent_before + RUST_BACKTRACE=1 cargo test --manifest-path ./e2e_tests/Cargo.toml persistent_before # Create a fake mapping file for the root application, the provider and a # key name of "Test Key". It contains a valid KeyInfo structure. @@ -160,7 +159,7 @@ else sleep 5 echo "Execute persistent test, after the reload" - RUST_BACKTRACE=1 cargo test $FEATURES persistent_after + RUST_BACKTRACE=1 cargo test --manifest-path ./e2e_tests/Cargo.toml persistent_after if [ -z "$NO_STRESS_TEST" ]; then echo "Shutdown Parsec" @@ -176,6 +175,6 @@ else sleep 5 echo "Execute stress tests" - RUST_BACKTRACE=1 cargo test $FEATURES stress_test + RUST_BACKTRACE=1 cargo test --manifest-path ./e2e_tests/Cargo.toml stress_test fi fi