This repository has been archived by the owner on May 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(rtc_data_service): add smoke test for save_access_key ECALL
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
//! ECALL tests | ||
mod local_attestation; | ||
mod save_access_key; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
) | ||
} |