Skip to content

Commit d670e6a

Browse files
authored
Add Rust client SDK (#455)
1 parent 2ca992e commit d670e6a

14 files changed

Lines changed: 720 additions & 10 deletions

File tree

attestation/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mesalock_sgx = [
1515
"sgx_tse",
1616
"teaclave_types/mesalock_sgx",
1717
"teaclave_config/mesalock_sgx",
18+
"teaclave_config/build_config",
1819
]
1920
enclave_unit_test = ["teaclave_test_utils/mesalock_sgx"]
2021

@@ -40,7 +41,7 @@ webpki-roots = { version = "0.19.0" }
4041
yasna = { version = "0.3.0", features = ["bit-vec", "num-bigint", "chrono"] }
4142

4243
teaclave_types = { path = "../types" }
43-
teaclave_config = { path = "../config", features = ["build_config"] }
44+
teaclave_config = { path = "../config" }
4445
teaclave_test_utils = { path = "../tests/utils", optional = true }
4546

4647
sgx_rand = { version = "1.1.2", optional = true }

cmake/TeaclaveGenVars.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ set(TEACLAVE_COMMON_ENVS
132132
TEACLAVE_BUILD_CFG_DIR=${PROJECT_SOURCE_DIR}
133133
TEACLAVE_EDL_DIR=${TEACLAVE_EDL_DIR}
134134
TEACLAVE_SYMLINKS=${TEACLAVE_SYMLINKS}
135+
RUSTFLAGS=${RUSTFLAGS}
135136
SGX_SDK=${SGX_SDK}
136137
SGX_MODE=${SGX_MODE}
137138
DCAP=${DCAP}

cmake/UtilTargets.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ if(TEST_MODE)
7070
add_custom_target(
7171
run-functional-tests COMMAND ${TEACLAVE_COMMON_ENVS}
7272
${MT_SCRIPT_DIR}/test.sh functional)
73+
add_custom_target(
74+
run-sdk-tests COMMAND ${TEACLAVE_COMMON_ENVS}
75+
${MT_SCRIPT_DIR}/test.sh sdk)
7376
else()
7477
add_custom_target(
7578
run-tests

cmake/scripts/test.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,44 @@ run_functional_tests() {
151151
cleanup
152152
}
153153

154+
run_sdk_tests() {
155+
trap cleanup INT TERM ERR
156+
157+
echo_title "SDK tests"
158+
mkdir -p /tmp/fusion_data
159+
pushd ${TEACLAVE_CLI_INSTALL_DIR}
160+
./teaclave_cli verify \
161+
--enclave-info ../examples/enclave_info.toml \
162+
--public-keys $(find ../examples -name "*.public.pem") \
163+
--signatures $(find ../examples -name "*.sign.sha256")
164+
popd
165+
pushd ${TEACLAVE_SERVICE_INSTALL_DIR}
166+
./teaclave_authentication_service &
167+
./teaclave_storage_service &
168+
sleep 3 # wait for authentication and storage service
169+
./teaclave_management_service &
170+
./teaclave_scheduler_service &
171+
sleep 3 # wait for management service and scheduler_service
172+
./teaclave_access_control_service &
173+
./teaclave_frontend_service &
174+
sleep 3 # wait for other services
175+
176+
start_storage_server
177+
178+
# Run tests of execution service separately
179+
./teaclave_execution_service &
180+
sleep 3 # wait for execution services
181+
popd
182+
183+
pushd ${MT_SGXAPP_TOML_DIR}
184+
RUSTFLAGS=${RUSTFLAGS} cargo test --manifest-path ${TEACLAVE_PROJECT_ROOT}/sdk/rust/Cargo.toml \
185+
--target-dir ${TEACLAVE_TARGET_DIR}/untrusted
186+
popd
187+
188+
# kill all background services
189+
cleanup
190+
}
191+
154192
run_examples() {
155193
trap cleanup INT TERM ERR
156194

@@ -208,13 +246,17 @@ case "$1" in
208246
"functional")
209247
run_functional_tests
210248
;;
249+
"sdk")
250+
run_sdk_tests
251+
;;
211252
"example")
212253
run_examples
213254
;;
214255
*)
215256
run_unit_tests
216257
run_integration_tests
217258
run_functional_tests
259+
run_sdk_tests
218260
run_examples
219261
;;
220262
esac

docs/build-system.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Above targets are automatically generated from the
117117
- `run-tests`: Run all test cases.
118118
- `run-integration-tests`: Run integration tests only.
119119
- `run-funtional-tests`: Run functional tests only.
120+
- `run-sdk-tests`: Run tests of client SDK only.
120121
- `run-examples`: Run all examples.
121122
- `cov`: Aggregate coverage results and generate report, needs to config cmake
122123
with `-DCOV=ON`.

sdk/rust/Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "teaclave-client-sdk"
3+
version = "0.1.0"
4+
authors = ["Teaclave Contributors <dev@teaclave.apache.org>"]
5+
description = "Teaclave Rust Client SDK"
6+
license = "Apache-2.0"
7+
edition = "2018"
8+
9+
[dependencies]
10+
teaclave_types = { path = "../../types", features = ["app"] }
11+
teaclave_attestation = { path = "../../attestation" }
12+
teaclave_rpc = { path = "../../rpc" }
13+
teaclave_proto = { path = "../../services/proto" }
14+
anyhow = { version = "1.0.26" }
15+
url = { version = "2.1.1" }
16+
pem = "0.7.0"

sdk/rust/build.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
fn main() {
19+
println!("cargo:rustc-env=MT_SGXAPP_TOML_DIR=../../");
20+
}

0 commit comments

Comments
 (0)