Skip to content

Commit 9db258f

Browse files
committed
test(fsim-upload): validate onboarding process with FSIM upload enabled
Owner is started with --upload-directory and --command-upload. Fdo device onboard is tarted with upload flag that points to the dir. Matches source and destination file checksum. Signed-off-by: Sayan Paul <paul.sayan@gmail.com>
1 parent 66ba425 commit 9db258f

3 files changed

Lines changed: 141 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,33 @@ jobs:
152152
153153
- name: Fail if the source code has changes after build
154154
uses: NathanielHill/fail-if-changes@master
155+
156+
test-fsim-upload:
157+
name: test fsim upload
158+
runs-on: ubuntu-latest
159+
steps:
160+
- name: Install golang
161+
uses: actions/setup-go@v5
162+
with:
163+
go-version: "1.25"
164+
165+
- name: Check out repository code
166+
uses: actions/checkout@v4
167+
168+
- name: Test FSIM upload
169+
run: |
170+
source test/test-fsim-upload.sh
171+
test_fsim-upload
172+
173+
- name: Get Manufacturer, Rendezvous and Owner server logs after a failed onboarding
174+
if: failure() && steps.setup_env.outcome == 'success'
175+
run: |
176+
source test/test-makefile.sh
177+
get_server_logs
178+
179+
- name: Cleanup the environment
180+
if: always()
181+
run: |
182+
source test/test-makefile.sh
183+
cleanup
184+

test/test-fsim-upload.sh

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#! /bin/bash
2+
3+
set -xeuo pipefail
4+
5+
source "$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/test-makefile.sh"
6+
7+
BASE_DIR=/tmp/go-fdo
8+
UPLOADS_DIR=${BASE_DIR}/uploads
9+
CREDS_DIR=${BASE_DIR}/device-credentials
10+
ONBOARD_LOG=${BASE_DIR}/onboarding-owner.log
11+
12+
trap 'fsim_teardown' EXIT
13+
14+
fsim_teardown() {
15+
echo "======================== Cleaning up FSIM upload environment =========================="
16+
# Delegate to standard cleanup from test-makefile.sh
17+
cleanup
18+
}
19+
20+
setup_dirs() {
21+
echo "======================== Setting up directories =========================="
22+
mkdir -p "${UPLOADS_DIR}" "${CREDS_DIR}" "${BASE_DIR}/tmp"
23+
chmod -R 777 "${BASE_DIR}" 2>/dev/null || true
24+
}
25+
26+
# Start services with owner configured for upload FSIM
27+
run_services_upload() {
28+
run_service manufacturing ${manufacturer_service} manufacturer ${manufacturer_log} \
29+
--manufacturing-key="${manufacturer_key}" \
30+
--owner-cert="${owner_crt}" \
31+
--device-ca-cert="${device_ca_crt}" \
32+
--device-ca-key="${device_ca_key}"
33+
run_service rendezvous ${rendezvous_service} rendezvous ${rendezvous_log}
34+
run_service owner ${owner_service} owner ${owner_log} \
35+
--owner-key="${owner_key}" \
36+
--device-ca-cert="${device_ca_crt}" \
37+
--upload-directory="${UPLOADS_DIR}" \
38+
--command-upload uploaded.bin
39+
}
40+
41+
start_services() {
42+
echo "======================== Starting services (local binaries) =========================="
43+
generate_certs
44+
install_client
45+
install_server
46+
setup_hostnames
47+
run_services_upload
48+
wait_for_service "${manufacturer_service}"
49+
wait_for_service "${rendezvous_service}"
50+
wait_for_service "${owner_service}"
51+
set_rendezvous_info ${manufacturer_service} ${rendezvous_dns} ${rendezvous_ip} ${rendezvous_port} || \
52+
update_rendezvous_info ${manufacturer_service} ${rendezvous_dns} ${rendezvous_ip} ${rendezvous_port}
53+
}
54+
55+
prepare_upload_payload() {
56+
echo "======================== Creating binary upload payload in creds dir =========================="
57+
mkdir -p "${CREDS_DIR}"
58+
dd if=/dev/urandom of="${CREDS_DIR}/uploaded.bin" bs=1M count=2 2>/dev/null
59+
echo "Created test file: ${CREDS_DIR}/uploaded.bin ($(stat -c%s "${CREDS_DIR}/uploaded.bin") bytes)"
60+
}
61+
62+
run_upload_flow() {
63+
echo "======================== Running FDO onboarding with FSIM upload =========================="
64+
# Perform full onboarding steps and pass upload dir to client
65+
update_ips
66+
update_rendezvous_info ${manufacturer_service} ${rendezvous_dns} ${rendezvous_ip} ${rendezvous_port}
67+
run_device_initialization
68+
guid=$(get_device_guid ${device_credentials})
69+
get_ov_from_manufacturer ${manufacturer_service} "${guid}" ${owner_ov}
70+
set_owner_redirect_info ${owner_service} ${owner_ip} ${owner_port}
71+
send_ov_to_owner ${owner_service} ${owner_ov}
72+
run_to0 ${owner_service} "${guid}"
73+
run_fido_device_onboard ${owner_onboard_log} --upload '/'
74+
}
75+
76+
verify_upload() {
77+
echo "======================== Verifying FSIM upload (checksum only) =========================="
78+
local src_file="${CREDS_DIR}/uploaded.bin"
79+
local dst_file="${UPLOADS_DIR}/uploaded.bin"
80+
81+
[ -f "${dst_file}" ] || { echo "✗ FSIM upload file not found: ${dst_file}"; return 1; }
82+
83+
local src_sha dst_sha
84+
src_sha=$(sha256sum "${src_file}" | awk '{print $1}')
85+
dst_sha=$(sha256sum "${dst_file}" | awk '{print $1}')
86+
if [ "${src_sha}" != "${dst_sha}" ]; then
87+
echo "✗ Checksum mismatch: src=${src_sha} dst=${dst_sha}"
88+
return 1
89+
fi
90+
91+
echo "✓ FSIM upload verified at ${dst_file} (sha256=${dst_sha})"
92+
}
93+
94+
# Public entrypoint used by CI
95+
test_fsim_upload() {
96+
echo "=============== Running FDO FSIM Upload Tests ====================="
97+
trap fsim_teardown EXIT
98+
setup_dirs
99+
start_services
100+
prepare_upload_payload
101+
run_upload_flow
102+
verify_upload
103+
echo "======================== SUCCESS: FSIM upload test passed! =========================="
104+
}
105+
106+
# Allow running directly
107+
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
108+
test_fsim_upload
109+
fi

test/test-makefile.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ get_device_guid () {
137137

138138
run_fido_device_onboard () {
139139
local log=$1
140+
local extra_args=("${@:2}")
140141
cd ${creds_dir}
141-
go-fdo-client --blob "${device_credentials}" --debug onboard --key ec256 --kex ECDH256 | tee "${log}"
142+
go-fdo-client --blob "${device_credentials}" --debug onboard --key ec256 --kex ECDH256 "${extra_args[@]}" | tee "${log}"
142143
cd -
143144
grep 'FIDO Device Onboard Complete' "${log}"
144145
}

0 commit comments

Comments
 (0)