Skip to content

Commit e342f41

Browse files
say-paulmmartinv
andcommitted
test(fsim-upload): validate onboarding process with FSIM upload enabled
Owner is started with --upload-directory and --command-upload. Fdo device onboard is started with upload flag that points to the dir. Matches source and destination file checksum. Signed-off-by: Sayan Paul <paul.sayan@gmail.com> Co-authored-by: Miguel Martin <mmartinv@redhat.com>
1 parent d97c966 commit e342f41

2 files changed

Lines changed: 136 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,39 @@ jobs:
175175
run: |
176176
source test/test-fsim-wget.sh
177177
get_server_logs
178-
178+
179179
- name: Cleanup the environment
180180
if: always()
181181
run: |
182182
source test/test-fsim-wget.sh
183183
cleanup_wget
184+
185+
test-fsim-upload:
186+
name: test fsim upload
187+
runs-on: ubuntu-latest
188+
steps:
189+
- name: Install golang
190+
uses: actions/setup-go@v5
191+
with:
192+
go-version: "1.25"
193+
194+
- name: Check out repository code
195+
uses: actions/checkout@v4
196+
197+
- name: Test FSIM upload
198+
run: |
199+
source test/test-fsim-upload.sh
200+
run_test
201+
202+
- name: Get Manufacturer, Rendezvous and Owner server logs after a failed onboarding
203+
if: failure()
204+
run: |
205+
source test/test-fsim-upload.sh
206+
get_server_logs
207+
208+
- name: Cleanup the environment
209+
if: always()
210+
run: |
211+
source test/test-fsim-upload.sh
212+
fsim_teardown
213+

test/test-fsim-upload.sh

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

0 commit comments

Comments
 (0)