Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
test(rtc_data_service): add smoke test for save_access_key ECALL
Browse files Browse the repository at this point in the history
  • Loading branch information
PiDelport committed Jun 21, 2021
1 parent c05ba1c commit 7ec1aba
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions rtc_data_service/tests/ecalls/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! ECALL tests
mod local_attestation;
mod save_access_key;
28 changes: 28 additions & 0 deletions rtc_data_service/tests/ecalls/save_access_key.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! Test ECALL: `save_access_key`
use rtc_types::byte_formats::rkyv_format;
use rtc_types::enclave_messages::set_access_key;
use sgx_types::sgx_enclave_id_t;

use crate::helpers;

#[test]
fn save_access_key_smoke_test() {
let auth_enclave = helpers::init_auth_enclave();

let dummy_ciphertext = [123; set_access_key::REQUEST_SIZE];
let dummy_sending_enclave_id: sgx_enclave_id_t = 456;
let encrypted_request = set_access_key::EncryptedRequest {
tag: Default::default(),
ciphertext: dummy_ciphertext,
aad: rkyv_format::write_array(&dummy_sending_enclave_id).unwrap(),
nonce: Default::default(),
};
let result = auth_enclave.save_access_key(encrypted_request).unwrap();
let sealing_error = result.unwrap_err();

assert_eq!(
format!("{}", sealing_error),
"Failed to acquire ProtectedChannel: No active session for enclave ID 456"
)
}

0 comments on commit 7ec1aba

Please sign in to comment.