Skip to content

Commit 791b061

Browse files
authored
Merge pull request parallaxsecond#160 from ionut-arm/e2e-tests
Move end to end tests to own crate
2 parents 2fa6056 + 4edc168 commit 791b061

32 files changed

+121
-87
lines changed

.github/workflows/ci.yml

+20-20
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,38 @@ jobs:
77
name: Various tests targeting a Parsec image with all providers included
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v1
11-
- name: Build the container
12-
run: docker build -t all-providers tests/all_providers
13-
- name: Run the container to execute the test script
14-
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec all-providers /tmp/parsec/tests/ci.sh all
10+
- uses: actions/checkout@v1
11+
- name: Build the container
12+
run: docker build -t all-providers e2e_tests/provider_cfg/all
13+
- name: Run the container to execute the test script
14+
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec all-providers /tmp/parsec/tests/ci.sh all
1515

1616
mbed-crypto-provider:
1717
name: Integration tests using Mbed Crypto provider
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v1
21-
- name: Build the container
22-
run: docker build -t mbed-crypto-provider tests/per_provider/provider_cfg/mbed-crypto
23-
- name: Run the container to execute the test script
24-
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec mbed-crypto-provider /tmp/parsec/tests/ci.sh mbed-crypto
20+
- uses: actions/checkout@v1
21+
- name: Build the container
22+
run: docker build -t mbed-crypto-provider e2e_tests/provider_cfg/mbed-crypto
23+
- name: Run the container to execute the test script
24+
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec mbed-crypto-provider /tmp/parsec/tests/ci.sh mbed-crypto
2525

2626
pkcs11-provider:
2727
name: Integration tests using PKCS 11 provider
2828
runs-on: ubuntu-latest
2929
steps:
30-
- uses: actions/checkout@v1
31-
- name: Build the container
32-
run: docker build -t pkcs11-provider tests/per_provider/provider_cfg/pkcs11
33-
- name: Run the container to execute the test script
34-
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec pkcs11-provider /tmp/parsec/tests/ci.sh pkcs11
30+
- uses: actions/checkout@v1
31+
- name: Build the container
32+
run: docker build -t pkcs11-provider e2e_tests/provider_cfg/pkcs11
33+
- name: Run the container to execute the test script
34+
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec pkcs11-provider /tmp/parsec/tests/ci.sh pkcs11
3535

3636
tpm-provider:
3737
name: Integration tests using TPM provider
3838
runs-on: ubuntu-latest
3939
steps:
40-
- uses: actions/checkout@v1
41-
- name: Build the container
42-
run: docker build -t tpm-provider tests/per_provider/provider_cfg/tpm
43-
- name: Run the container to execute the test script
44-
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec tpm-provider /tmp/parsec/tests/ci.sh tpm
40+
- uses: actions/checkout@v1
41+
- name: Build the container
42+
run: docker build -t tpm-provider e2e_tests/provider_cfg/tpm
43+
- name: Run the container to execute the test script
44+
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec tpm-provider /tmp/parsec/tests/ci.sh tpm

.travis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ services:
77
jobs:
88
include:
99
- name: "Integration tests using Mbed Crypto provider"
10-
env: DOCKER_IMAGE_NAME=mbed-crypto-provider DOCKER_IMAGE_PATH=tests/per_provider/provider_cfg/mbed-crypto SCRIPT="tests/ci.sh mbed-crypto"
10+
env: DOCKER_IMAGE_NAME=mbed-crypto-provider DOCKER_IMAGE_PATH=e2e_tests/provider_cfg/mbed-crypto SCRIPT="tests/ci.sh mbed-crypto"
1111
- name: "Integration tests using PKCS 11 provider"
12-
env: DOCKER_IMAGE_NAME=pkcs11-provider DOCKER_IMAGE_PATH=tests/per_provider/provider_cfg/pkcs11 SCRIPT="tests/ci.sh pkcs11"
12+
env: DOCKER_IMAGE_NAME=pkcs11-provider DOCKER_IMAGE_PATH=e2e_tests/provider_cfg/pkcs11 SCRIPT="tests/ci.sh pkcs11"
1313
# PKCS11 tests are failing because of unidentified issues.
1414
# See https://github.com/parallaxsecond/parsec/issues/116
1515
allow_failures:
16-
- env: DOCKER_IMAGE_NAME=mbed-crypto-provider DOCKER_IMAGE_PATH=tests/per_provider/provider_cfg/mbed-crypto SCRIPT="tests/ci.sh mbed-crypto"
17-
- env: DOCKER_IMAGE_NAME=pkcs11-provider DOCKER_IMAGE_PATH=tests/per_provider/provider_cfg/pkcs11 SCRIPT="tests/ci.sh pkcs11"
16+
- env: DOCKER_IMAGE_NAME=mbed-crypto-provider DOCKER_IMAGE_PATH=e2e_tests/provider_cfg/mbed-crypto SCRIPT="tests/ci.sh mbed-crypto"
17+
- env: DOCKER_IMAGE_NAME=pkcs11-provider DOCKER_IMAGE_PATH=e2e_tests/provider_cfg/pkcs11 SCRIPT="tests/ci.sh pkcs11"
1818
script:
1919
- docker build -t $DOCKER_IMAGE_NAME $DOCKER_IMAGE_PATH
2020
- docker run -v $(pwd):/tmp/parsec -w /tmp/parsec $DOCKER_IMAGE_NAME /tmp/parsec/$SCRIPT

e2e_tests/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target
2+
Cargo.lock

e2e_tests/Cargo.toml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This crate should NOT be upstreamed to crates.io; it is only intended for
2+
# PARSEC testing purposes (both locally and on CI)
3+
[package]
4+
name = "e2e_tests"
5+
version = "0.1.0"
6+
authors = ["Anton Antonov <[email protected]>",
7+
"Paul Howard <[email protected]>",
8+
"Ionut Mihalcea <[email protected]>",
9+
"Hugues de Valon <[email protected]>"]
10+
description = "End to end testing framework for PARSEC"
11+
license = "Apache-2.0"
12+
edition = "2018"
13+
publish = false
14+
15+
[dependencies]
16+
num_cpus = "1.13.0"
17+
picky-asn1-der = "0.2.2"
18+
picky-asn1 = "0.2.1"
19+
serde = { version = "1.0", features = ["derive"] }
20+
sha2 = "0.8.1"
21+
parsec-client = { version = "0.2.0", features = ["testing"] }
22+
log = "0.4.8"
23+
rand = "0.7.3"
24+
25+
[dev-dependencies]
26+
env_logger = "0.7.1"
27+
uuid = "0.7.4"
File renamed without changes.
File renamed without changes.

tests/test_clients/mod.rs e2e_tests/src/lib.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ pub use parsec_client::error;
1111
use log::error;
1212
use parsec_client::auth::AuthenticationData;
1313
use parsec_client::core::basic_client::BasicClient;
14+
use parsec_client::core::interface::operations::list_providers::ProviderInfo;
15+
use parsec_client::core::interface::operations::psa_algorithm::{
16+
Algorithm, AsymmetricSignature, Hash,
17+
};
18+
use parsec_client::core::interface::operations::psa_key_attributes::{
19+
KeyAttributes, KeyPolicy, KeyType, UsageFlags,
20+
};
21+
use parsec_client::core::interface::requests::{Opcode, ProviderID, ResponseStatus, Result};
1422
use parsec_client::error::Error;
15-
use parsec_interface::operations::list_providers::ProviderInfo;
16-
use parsec_interface::operations::psa_algorithm::{Algorithm, AsymmetricSignature, Hash};
17-
use parsec_interface::operations::psa_key_attributes::*;
18-
use parsec_interface::operations::psa_key_attributes::{KeyAttributes, KeyPolicy, UsageFlags};
19-
use parsec_interface::requests::{Opcode, ProviderID, ResponseStatus, Result};
2023
use std::collections::HashSet;
2124
use std::time::Duration;
2225

tests/test_clients/raw_request.rs e2e_tests/src/raw_request.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2020 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use parsec_interface::requests::request::RawHeader;
4-
use parsec_interface::requests::{Response, Result};
3+
use parsec_client::core::interface::requests::request::RawHeader;
4+
use parsec_client::core::interface::requests::{Response, Result};
55
use std::io::Write;
66
use std::os::unix::net::UnixStream;
77
use std::thread;

tests/test_clients/stress.rs e2e_tests/src/stress.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2020 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use crate::test_clients::TestClient;
3+
use super::TestClient;
44
use log::info;
5-
use parsec_interface::requests::ResponseStatus;
5+
use parsec_client::core::interface::requests::ResponseStatus;
66
use rand::Rng;
77
use rand::{
88
distributions::{Alphanumeric, Distribution, Standard},

tests/all_providers/mod.rs e2e_tests/tests/all_providers/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2019 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use crate::test_clients::TestClient;
4-
use parsec_interface::requests::{Opcode, ProviderID, Result};
3+
use e2e_tests::TestClient;
4+
use parsec_client::core::interface::requests::{Opcode, ProviderID, Result};
55
use std::collections::HashSet;
66
use uuid::Uuid;
77

tests/mod.rs e2e_tests/tests/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@
3232

3333
mod all_providers;
3434
mod per_provider;
35-
mod test_clients;
File renamed without changes.

tests/per_provider/normal_tests/asym_sign_verify.rs e2e_tests/tests/per_provider/normal_tests/asym_sign_verify.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright 2019 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use crate::test_clients::TestClient;
4-
use parsec_interface::operations::psa_algorithm::*;
5-
use parsec_interface::operations::psa_key_attributes::*;
6-
use parsec_interface::requests::ResponseStatus;
7-
use parsec_interface::requests::Result;
3+
use e2e_tests::TestClient;
4+
use parsec_client::core::interface::operations::psa_algorithm::*;
5+
use parsec_client::core::interface::operations::psa_key_attributes::*;
6+
use parsec_client::core::interface::requests::ResponseStatus;
7+
use parsec_client::core::interface::requests::Result;
88
use sha2::{Digest, Sha256};
99

1010
const HASH: [u8; 32] = [

tests/per_provider/normal_tests/auth.rs e2e_tests/tests/per_provider/normal_tests/auth.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2019 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use crate::test_clients::TestClient;
4-
use parsec_interface::requests::ResponseStatus;
5-
use parsec_interface::requests::Result;
3+
use e2e_tests::TestClient;
4+
use parsec_client::core::interface::requests::ResponseStatus;
5+
use parsec_client::core::interface::requests::Result;
66

77
#[test]
88
fn two_auths_same_key_name() -> Result<()> {

tests/per_provider/normal_tests/basic.rs e2e_tests/tests/per_provider/normal_tests/basic.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2019 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use crate::test_clients::RawRequestClient;
4-
use parsec_interface::requests::request::RawHeader;
5-
use parsec_interface::requests::{Opcode, ProviderID, ResponseStatus};
3+
use e2e_tests::RawRequestClient;
4+
use parsec_client::core::interface::requests::request::RawHeader;
5+
use parsec_client::core::interface::requests::{Opcode, ProviderID, ResponseStatus};
66

77
#[test]
88
fn invalid_provider() {

tests/per_provider/normal_tests/create_destroy_key.rs e2e_tests/tests/per_provider/normal_tests/create_destroy_key.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// Copyright 2019 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use crate::test_clients::TestClient;
4-
use parsec_interface::operations::psa_algorithm::{Algorithm, AsymmetricSignature, Hash};
5-
use parsec_interface::operations::psa_key_attributes::{
3+
use e2e_tests::TestClient;
4+
use parsec_client::core::interface::operations::psa_algorithm::{
5+
Algorithm, AsymmetricSignature, Hash,
6+
};
7+
use parsec_client::core::interface::operations::psa_key_attributes::{
68
KeyAttributes, KeyPolicy, KeyType, UsageFlags,
79
};
8-
use parsec_interface::requests::ResponseStatus;
9-
use parsec_interface::requests::Result;
10+
use parsec_client::core::interface::requests::ResponseStatus;
11+
use parsec_client::core::interface::requests::Result;
1012
use picky_asn1::wrapper::IntegerAsn1;
1113
use serde::{Deserialize, Serialize};
1214

tests/per_provider/normal_tests/export_public_key.rs e2e_tests/tests/per_provider/normal_tests/export_public_key.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright 2019 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use crate::test_clients::TestClient;
4-
use parsec_interface::operations::psa_algorithm::*;
5-
use parsec_interface::operations::psa_key_attributes::*;
6-
use parsec_interface::requests::ResponseStatus;
7-
use parsec_interface::requests::Result;
3+
use e2e_tests::TestClient;
4+
use parsec_client::core::interface::operations::psa_algorithm::*;
5+
use parsec_client::core::interface::operations::psa_key_attributes::*;
6+
use parsec_client::core::interface::requests::ResponseStatus;
7+
use parsec_client::core::interface::requests::Result;
88
use picky_asn1::wrapper::IntegerAsn1;
99
use serde::{Deserialize, Serialize};
1010

tests/per_provider/normal_tests/import_key.rs e2e_tests/tests/per_provider/normal_tests/import_key.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright 2019 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use crate::test_clients::TestClient;
4-
use parsec_interface::operations::psa_algorithm::*;
5-
use parsec_interface::operations::psa_key_attributes::*;
6-
use parsec_interface::requests::ResponseStatus;
7-
use parsec_interface::requests::Result;
3+
use e2e_tests::TestClient;
4+
use parsec_client::core::interface::operations::psa_algorithm::*;
5+
use parsec_client::core::interface::operations::psa_key_attributes::*;
6+
use parsec_client::core::interface::requests::ResponseStatus;
7+
use parsec_client::core::interface::requests::Result;
88
use picky_asn1::wrapper::IntegerAsn1;
99
use serde::{Deserialize, Serialize};
1010

tests/per_provider/normal_tests/key_attributes.rs e2e_tests/tests/per_provider/normal_tests/key_attributes.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Copyright 2020 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use crate::test_clients::TestClient;
4-
use parsec_interface::operations::psa_algorithm::{Algorithm, AsymmetricSignature, Cipher, Hash};
5-
use parsec_interface::operations::psa_key_attributes::{
3+
use e2e_tests::TestClient;
4+
use parsec_client::core::interface::operations::psa_algorithm::{
5+
Algorithm, AsymmetricSignature, Cipher, Hash,
6+
};
7+
use parsec_client::core::interface::operations::psa_key_attributes::{
68
KeyAttributes, KeyPolicy, KeyType, UsageFlags,
79
};
8-
use parsec_interface::requests::{ProviderID, ResponseStatus};
10+
use parsec_client::core::interface::requests::{ProviderID, ResponseStatus};
911

1012
// Ignored as only RSA key types are supported for now.
1113
#[ignore]

tests/per_provider/normal_tests/ping.rs e2e_tests/tests/per_provider/normal_tests/ping.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Copyright 2019 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use crate::test_clients::RequestClient;
4-
use crate::test_clients::TestClient;
5-
use parsec_interface::requests::request::{Request, RequestAuth, RequestBody};
6-
use parsec_interface::requests::Opcode;
7-
use parsec_interface::requests::ProviderID;
8-
use parsec_interface::requests::ResponseStatus;
9-
use parsec_interface::requests::Result;
3+
use e2e_tests::RequestClient;
4+
use e2e_tests::TestClient;
5+
use parsec_client::core::interface::requests::request::{Request, RequestAuth, RequestBody};
6+
use parsec_client::core::interface::requests::Opcode;
7+
use parsec_client::core::interface::requests::ProviderID;
8+
use parsec_client::core::interface::requests::ResponseStatus;
9+
use parsec_client::core::interface::requests::Result;
1010

1111
#[test]
1212
fn test_ping() -> Result<()> {

tests/per_provider/persistent_after.rs e2e_tests/tests/per_provider/persistent_after.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
// These functions test for the service persistency to shutdown. They will be executed after the
55
// service is shutdown, after the persistent_before tests are executed.
6-
use crate::test_clients::TestClient;
7-
use parsec_interface::requests::Result;
8-
use parsec_interface::requests::{ProviderID, ResponseStatus};
6+
use e2e_tests::TestClient;
7+
use parsec_client::core::interface::requests::Result;
8+
use parsec_client::core::interface::requests::{ProviderID, ResponseStatus};
99

1010
const HASH: [u8; 32] = [
1111
0x69, 0x3E, 0xDB, 0x1B, 0x22, 0x79, 0x03, 0xF4, 0xC0, 0xBF, 0xD6, 0x91, 0x76, 0x37, 0x84, 0xA2,

tests/per_provider/persistent_before.rs e2e_tests/tests/per_provider/persistent_before.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
// These functions test for the service persistency to shutdown. They will be executed before the
55
// service is shutdown and before the persistent_after tests are executed.
6-
use crate::test_clients::TestClient;
7-
use parsec_interface::requests::Result;
6+
use e2e_tests::TestClient;
7+
use parsec_client::core::interface::requests::Result;
88

99
const HASH: [u8; 32] = [
1010
0x69, 0x3E, 0xDB, 0x1B, 0x22, 0x79, 0x03, 0xF4, 0xC0, 0xBF, 0xD6, 0x91, 0x76, 0x37, 0x84, 0xA2,

tests/per_provider/stress_test.rs e2e_tests/tests/per_provider/stress_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright 2019 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use crate::test_clients::stress::{StressClient, StressTestConfig};
3+
use e2e_tests::stress::{StressClient, StressTestConfig};
44
use std::time::Duration;
55

66
#[test]

tests/ci.sh

+7-8
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,11 @@ while [ "$#" -gt 0 ]; do
6363
error_msg "Only one provider name must be given"
6464
fi
6565
PROVIDER_NAME=$1
66+
CONFIG_PATH="e2e_tests/provider_cfg/$1/config.toml"
6667
if [ "$PROVIDER_NAME" = "all" ]; then
6768
FEATURES="--features=all-providers"
68-
CONFIG_PATH="tests/all_providers/config.toml"
6969
else
7070
FEATURES="--features=$1-provider"
71-
CONFIG_PATH="tests/per_provider/provider_cfg/$1/config.toml"
7271
fi
7372
;;
7473
*)
@@ -96,7 +95,7 @@ fi
9695

9796
if [ "$PROVIDER_NAME" = "pkcs11" ] || [ "$PROVIDER_NAME" = "all" ]; then
9897
# Find and append the slot number at the end of the configuration file.
99-
tests/per_provider/provider_cfg/pkcs11/find_slot_number.sh $CONFIG_PATH
98+
e2e_tests/provider_cfg/pkcs11/find_slot_number.sh $CONFIG_PATH
10099
fi
101100

102101
echo "Build test"
@@ -127,14 +126,14 @@ pgrep -f target/debug/parsec >/dev/null
127126

128127
if [ "$PROVIDER_NAME" = "all" ]; then
129128
echo "Execute all-providers tests"
130-
RUST_BACKTRACE=1 cargo test $FEATURES all_providers
129+
RUST_BACKTRACE=1 cargo test --manifest-path ./e2e_tests/Cargo.toml all_providers
131130
else
132131
# Per provider tests
133132
echo "Execute normal tests"
134-
RUST_BACKTRACE=1 cargo test $FEATURES normal_tests
133+
RUST_BACKTRACE=1 cargo test --manifest-path ./e2e_tests/Cargo.toml normal_tests
135134

136135
echo "Execute persistent test, before the reload"
137-
RUST_BACKTRACE=1 cargo test $FEATURES persistent_before
136+
RUST_BACKTRACE=1 cargo test --manifest-path ./e2e_tests/Cargo.toml persistent_before
138137

139138
# Create a fake mapping file for the root application, the provider and a
140139
# key name of "Test Key". It contains a valid KeyInfo structure.
@@ -160,7 +159,7 @@ else
160159
sleep 5
161160

162161
echo "Execute persistent test, after the reload"
163-
RUST_BACKTRACE=1 cargo test $FEATURES persistent_after
162+
RUST_BACKTRACE=1 cargo test --manifest-path ./e2e_tests/Cargo.toml persistent_after
164163

165164
if [ -z "$NO_STRESS_TEST" ]; then
166165
echo "Shutdown Parsec"
@@ -176,6 +175,6 @@ else
176175
sleep 5
177176

178177
echo "Execute stress tests"
179-
RUST_BACKTRACE=1 cargo test $FEATURES stress_test
178+
RUST_BACKTRACE=1 cargo test --manifest-path ./e2e_tests/Cargo.toml stress_test
180179
fi
181180
fi

0 commit comments

Comments
 (0)