Skip to content

Commit

Permalink
Added E2E tests for SQLiteKIM
Browse files Browse the repository at this point in the history
This version includes the normal E2E tests as well as multi-tenancy.

Closes parallaxsecond#516

Signed-off-by: Matt Davis <matt.davis@arm.com>
  • Loading branch information
MattDavis00 committed Sep 20, 2021
1 parent c5d5e4f commit 5f0bcd5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
18 changes: 1 addition & 17 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -241,22 +241,6 @@ if [ "$PROVIDER_NAME" = "all" ] || [ "$PROVIDER_NAME" = "sqlite-kim" ]; then
popd
fi

# Test the SQLite KIM
if [ "$PROVIDER_NAME" = "sqlite-kim" ]; then
echo "Start Parsec for end-to-end tests with sqlite-kim"
RUST_LOG=info RUST_BACKTRACE=1 cargo run --release $FEATURES -- --config $CONFIG_PATH &
# Sleep time needed to make sure Parsec is ready before launching the tests.
wait_for_service

echo "Execute all-providers sqlite-kim normal tests"
RUST_BACKTRACE=1 cargo test $TEST_FEATURES --manifest-path ./e2e_tests/Cargo.toml all_providers::normal

echo "Shutdown Parsec"
stop_service

exit 0
fi

echo "Build test"

if [ "$PROVIDER_NAME" = "cargo-check" ]; then
Expand Down Expand Up @@ -333,7 +317,7 @@ RUST_LOG=info RUST_BACKTRACE=1 cargo run --release $FEATURES -- --config $CONFIG
# Sleep time needed to make sure Parsec is ready before launching the tests.
wait_for_service

if [ "$PROVIDER_NAME" = "all" ]; then
if [ "$PROVIDER_NAME" = "all" ] || [ "$PROVIDER_NAME" = "sqlite-kim" ]; then
echo "Execute all-providers normal tests"
RUST_BACKTRACE=1 cargo test $TEST_FEATURES --manifest-path ./e2e_tests/Cargo.toml all_providers::normal

Expand Down
14 changes: 6 additions & 8 deletions e2e_tests/tests/all_providers/multitenancy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ fn client1_before() {
client.do_not_destroy_keys();
client.set_default_auth(Some("client1".to_string()));

let key = String::from("multitenant");

for provider in [ProviderId::MbedCrypto, ProviderId::Pkcs11, ProviderId::Tpm].iter() {
let key = format!("{}-multitenant", provider.id);
client.set_provider(*provider);
client.generate_rsa_sign_key(key.clone()).unwrap();
client.generate_rsa_sign_key(key).unwrap();
}

let clients = client.list_clients().unwrap();
Expand All @@ -37,13 +36,12 @@ fn client2() {
client.do_not_destroy_keys();
client.set_default_auth(Some("client2".to_string()));

let key = String::from("multitenant");

// Try to list those keys
let keys = client.list_keys().unwrap();
assert!(keys.is_empty());

for provider in [ProviderId::MbedCrypto, ProviderId::Pkcs11, ProviderId::Tpm].iter() {
let key = format!("{}-multitenant", provider.id);
client.set_provider(*provider);
assert_eq!(
client.export_public_key(key.clone()).unwrap_err(),
Expand All @@ -54,7 +52,7 @@ fn client2() {
ResponseStatus::PsaErrorDoesNotExist
);
client.generate_rsa_sign_key(key.clone()).unwrap();
client.destroy_key(key.clone()).unwrap();
client.destroy_key(key).unwrap();
}

assert_eq!(
Expand All @@ -81,10 +79,10 @@ fn client1_after() {
assert_eq!(keys.len(), 3);

// Destroy the keys
let key = String::from("multitenant");
for provider in [ProviderId::MbedCrypto, ProviderId::Pkcs11, ProviderId::Tpm].iter() {
let key = format!("{}-multitenant", provider.id);
client.set_provider(*provider);
client.destroy_key(key.clone()).unwrap();
client.destroy_key(key).unwrap();
}

client
Expand Down

0 comments on commit 5f0bcd5

Please sign in to comment.