Skip to content

Commit d05897e

Browse files
committed
2 parents 8b304f7 + 9d4bc89 commit d05897e

File tree

114 files changed

+9531
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+9531
-26
lines changed

.github/workflows/astarte-end-to-end-test-workflow.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ on:
2424
env:
2525
elixir_version: "1.15"
2626
otp_version: "26.1"
27+
CLEA_DEV_BASE: ""
28+
CLEA_DEV_REALM: ""
29+
CLEA_DEV_REALM_TOKEN: ""
30+
BOARD_BASE_URL: ""
2731

2832
jobs:
2933
e2e-build:
3034
uses: ./.github/workflows/astarte-e2e-build-workflow.yaml
35+
3136
astarte-build:
3237
uses: ./.github/workflows/astarte-build-workflow.yaml
3338

@@ -100,3 +105,74 @@ jobs:
100105
run: docker compose logs
101106
- name: Bring down Astarte docker-compose
102107
run: docker compose down
108+
109+
fdo-end-to-end:
110+
needs: [astarte-build]
111+
name: FDO end-to-end Test
112+
runs-on: ubuntu-24.04
113+
steps:
114+
- name: Checkout fdo e2e repo
115+
uses: actions/checkout@v6
116+
with:
117+
repository: astarte-platform/astarte-device-fdo-rust
118+
ref: dev
119+
- uses: ./.github/actions/install-deps
120+
- name: Install astartectl
121+
run: |
122+
wget https://github.com/astarte-platform/astartectl/releases/download/v22.11.02/astartectl_22.11.02_linux_x86_64.tar.gz
123+
tar xf astartectl_22.11.02_linux_x86_64.tar.gz
124+
chmod +x astartectl
125+
mkdir -p ${{ runner.temp }}/bin
126+
mv ./astartectl ${{ runner.temp }}/bin
127+
echo ${{ runner.temp }}/bin >> "$GITHUB_PATH"
128+
- name: Install additional dependencies
129+
run: |
130+
sudo apt-get install -y openssl jq
131+
- uses: actions/checkout@v6
132+
name: checkout astarte
133+
with:
134+
path: .tmp/repos/astarte
135+
- name: Restore astarte images
136+
uses: actions/download-artifact@v4
137+
with:
138+
name: astarte-images
139+
path: ${{ runner.temp }}
140+
- name: Initialize keys
141+
working-directory: .tmp/repos/astarte
142+
run: |
143+
docker run -v $(pwd)/compose:/compose astarte/docker-compose-initializer
144+
astartectl utils gen-keypair test
145+
- name: Load astarte images
146+
run: ls ${{ runner.temp }}/*.tar | xargs --max-args 1 docker load --input
147+
- name: Enable FDO
148+
run: echo "PAIRING_ENABLE_FDO=true" >> .tmp/repos/astarte/.env
149+
- name: Start all Astarte services
150+
working-directory: .tmp/repos/astarte
151+
run: docker compose up -d
152+
- uses: actions-rust-lang/setup-rust-toolchain@v1.15.2
153+
- uses: mozilla-actions/sccache-action@v0.0.9
154+
- name: Cache container build
155+
id: cache-container
156+
uses: actions/cache@v4.3.0
157+
with:
158+
path: .tmp/cache/containers
159+
key: ${{ runner.os }}-${{ hashFiles('justfile', 'scripts/**/*.sh', 'containers/**') }}
160+
- name: Install just
161+
uses: taiki-e/install-action@v2.49.43
162+
with:
163+
tool: just
164+
- run: just go-server-setup
165+
- name: Wait for Astarte to come up
166+
run: |
167+
wget https://github.com/astarte-platform/wait-for-astarte-docker-compose/releases/download/v1.1.0/wait-for-astarte-docker-compose_1.1.0_linux_amd64.tar.gz
168+
tar xf wait-for-astarte-docker-compose_1.1.0_linux_amd64.tar.gz
169+
./wait-for-astarte-docker-compose
170+
- name: Create realm
171+
working-directory: .tmp/repos/astarte
172+
run: |
173+
astartectl housekeeping realms create -y "test" \
174+
--astarte-url "http://api.astarte.localhost" \
175+
--realm-public-key "test_public.pem" \
176+
-k compose/astarte-keys/housekeeping_private.pem
177+
- name: Run FDO
178+
run: just astarte-run

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2626

2727
- Services now receive trigger installation and deletion notifications, which should reduce the delay between installing the trigger and starting to receive messages
2828

29+
## [1.3.0] - Unreleased
30+
- [astarte_pairing] FDO authentication (EXPERIMENTAL feature, disabled by default). New environment variables are needed in order to use FDO:
31+
- `PAIRING_ENABLE_FDO` - whether the FDO feature is enabled or not (default: false)
32+
- `PAIRING_FDO_RENDEZVOUS_URL` - URL of the rendezvous server (default: "http://rendezvous:8041")
33+
- `ASTARTE_BASE_URL_DOMAIN` - domain part of the base URL of astarte, used by devices to connect in TO2 phase (required if FDO enabled)
34+
- `ASTARTE_BASE_URL_PORT` - port of the base URL of astarte (required if FDO enabled)
35+
- `ASTARTE_BASE_URL_PROTOCOL` - protocol of the base URL of astarte (required if FDO enabled)
36+
2937
## [1.3.0-rc.0] - 2025-11-21
3038

3139
### Added

apps/astarte_appengine_api/test/support/helpers/database.ex

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ defmodule Astarte.Helpers.Database do
109109
);
110110
"""
111111

112+
@create_ownership_vouchers_table """
113+
CREATE TABLE #{Realm.keyspace_name(@test_realm)}.ownership_vouchers (
114+
private_key blob,
115+
voucher_data blob,
116+
device_id uuid,
117+
PRIMARY KEY (device_id, voucher_data)
118+
);
119+
"""
120+
112121
@create_devices_table """
113122
CREATE TABLE #{Realm.keyspace_name(@test_realm)}.devices (
114123
device_id uuid,
@@ -435,6 +444,8 @@ defmodule Astarte.Helpers.Database do
435444
{:ok, _} ->
436445
Repo.query!(@create_capabilities_type)
437446

447+
Repo.query!(@create_ownership_vouchers_table)
448+
438449
Repo.query!(@create_devices_table)
439450

440451
Repo.query!(@create_deletion_in_progress_table)

apps/astarte_appengine_api/test/support/helpers/database_v2.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ defmodule Astarte.Helpers.DatabaseV2 do
6969
);
7070
"""
7171

72+
@create_ownership_vouchers_table """
73+
CREATE TABLE :keyspace.ownership_vouchers (
74+
private_key blob,
75+
voucher_data blob,
76+
device_id uuid,
77+
PRIMARY KEY (device_id, voucher_data)
78+
);
79+
"""
80+
7281
@create_devices_table """
7382
CREATE TABLE :keyspace.devices (
7483
device_id uuid,
@@ -249,6 +258,7 @@ defmodule Astarte.Helpers.DatabaseV2 do
249258
realm_keyspace = Realm.keyspace_name(realm_name)
250259
execute!(realm_keyspace, @create_keyspace)
251260
execute!(realm_keyspace, @create_capabilities_type)
261+
execute!(realm_keyspace, @create_ownership_vouchers_table)
252262
execute!(realm_keyspace, @create_devices_table)
253263
execute!(realm_keyspace, @create_groups_table)
254264
execute!(realm_keyspace, @create_names_table)

apps/astarte_data_updater_plant/test/support/database_test_helper.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ defmodule Astarte.DataUpdaterPlant.DatabaseTestHelper do
5353
);
5454
"""
5555

56+
@create_ownership_vouchers_table """
57+
CREATE TABLE :keyspace.ownership_vouchers (
58+
private_key blob,
59+
voucher_data blob,
60+
device_id uuid,
61+
PRIMARY KEY (device_id, voucher_data)
62+
);
63+
"""
64+
5665
@create_devices_table """
5766
CREATE TABLE :keyspace.devices (
5867
device_id uuid,
@@ -369,6 +378,7 @@ defmodule Astarte.DataUpdaterPlant.DatabaseTestHelper do
369378
case execute(keyspace_name, @create_autotestrealm) do
370379
{:ok, _} ->
371380
execute!(keyspace_name, @create_capabilities_type)
381+
execute!(keyspace_name, @create_ownership_vouchers_table)
372382
execute!(keyspace_name, @create_devices_table)
373383
execute!(keyspace_name, @create_endpoints_table)
374384

apps/astarte_data_updater_plant/test/support/helpers/database.ex

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@ defmodule Astarte.Helpers.Database do
7575
);
7676
"""
7777

78+
@create_ownership_vouchers_table """
79+
CREATE TABLE :keyspace.ownership_vouchers (
80+
private_key blob,
81+
voucher_data blob,
82+
device_id uuid,
83+
PRIMARY KEY (device_id, voucher_data)
84+
);
85+
"""
86+
87+
@create_ownership_vouchers_table """
88+
CREATE TABLE :keyspace.ownership_vouchers (
89+
private_key blob,
90+
voucher_data blob,
91+
device_id uuid,
92+
PRIMARY KEY (device_id, voucher_data)
93+
);
94+
"""
95+
7896
@create_devices_table """
7997
CREATE TABLE :keyspace.devices (
8098
device_id uuid,
@@ -101,7 +119,6 @@ defmodule Astarte.Helpers.Database do
101119
last_seen_ip inet,
102120
attributes map<varchar, varchar>,
103121
capabilities capabilities,
104-
105122
groups map<text, timeuuid>,
106123
107124
PRIMARY KEY (device_id)
@@ -309,6 +326,7 @@ defmodule Astarte.Helpers.Database do
309326
realm_keyspace = Realm.keyspace_name(realm_name)
310327
execute!(realm_keyspace, @create_keyspace, [], timeout: 60_000)
311328
execute!(realm_keyspace, @create_capabilities_type, [], timeout: 60_000)
329+
execute!(realm_keyspace, @create_ownership_vouchers_table)
312330
execute!(realm_keyspace, @create_devices_table, [], timeout: 60_000)
313331
execute!(realm_keyspace, @create_groups_table, [], timeout: 60_000)
314332
execute!(realm_keyspace, @create_names_table, [], timeout: 60_000)

apps/astarte_housekeeping/lib/astarte_housekeeping/realms/queries.ex

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ defmodule Astarte.Housekeeping.Realms.Queries do
260260
:ok <- create_simple_triggers_table(keyspace_name),
261261
:ok <- create_grouped_devices_table(keyspace_name),
262262
:ok <- create_deletion_in_progress_table(keyspace_name),
263+
:ok <- create_ownership_vouchers_table(keyspace_name),
264+
:ok <- create_to2_sessions_table(keyspace_name),
263265
:ok <- insert_realm_public_key(keyspace_name, public_key_pem),
264266
:ok <- insert_realm_astarte_schema_version(keyspace_name),
265267
:ok <- insert_realm(realm_name, device_limit),
@@ -599,6 +601,53 @@ defmodule Astarte.Housekeeping.Realms.Queries do
599601
end
600602
end
601603

604+
defp create_ownership_vouchers_table(keyspace_name) do
605+
query = """
606+
CREATE TABLE #{keyspace_name}.ownership_vouchers (
607+
private_key blob,
608+
voucher_data blob,
609+
guid blob,
610+
PRIMARY KEY (guid)
611+
);
612+
"""
613+
614+
with {:ok, %{rows: nil, num_rows: 1}} <- CSystem.execute_schema_change(query) do
615+
:ok
616+
end
617+
end
618+
619+
defp create_to2_sessions_table(keyspace_name) do
620+
query = """
621+
CREATE TABLE #{keyspace_name}.to2_sessions (
622+
guid blob,
623+
device_id uuid,
624+
nonce blob,
625+
sig_type int,
626+
epid_group blob,
627+
device_public_key blob,
628+
prove_dv_nonce blob,
629+
setup_dv_nonce blob,
630+
kex_suite_name ascii,
631+
cipher_suite_name int,
632+
max_owner_service_info_size int,
633+
owner_random blob,
634+
secret blob,
635+
sevk blob,
636+
svk blob,
637+
sek blob,
638+
device_service_info map<tuple<text, text>, blob>,
639+
owner_service_info list<blob>,
640+
last_chunk_sent int,
641+
PRIMARY KEY (guid)
642+
)
643+
WITH default_time_to_live = 7200;
644+
"""
645+
646+
with {:ok, %{rows: nil, num_rows: 1}} <- CSystem.execute_schema_change(query) do
647+
:ok
648+
end
649+
end
650+
602651
defp create_grouped_devices_table(keyspace_name) do
603652
query = """
604653
CREATE TABLE #{keyspace_name}.grouped_devices (
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE TABLE :keyspace.ownership_vouchers (
2+
private_key blob,
3+
voucher_data blob,
4+
guid blob,
5+
PRIMARY KEY (guid)
6+
);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
CREATE TABLE :keyspace.to2_sessions (
2+
guid blob,
3+
device_id uuid,
4+
nonce blob,
5+
sig_type int,
6+
epid_group blob,
7+
device_public_key blob,
8+
prove_dv_nonce blob,
9+
setup_dv_nonce blob,
10+
kex_suite_name ascii,
11+
cipher_suite_name int,
12+
max_owner_service_info_size int,
13+
owner_random blob,
14+
secret blob,
15+
sevk blob,
16+
svk blob,
17+
sek blob,
18+
device_service_info map<tuple<text, text>, blob>,
19+
owner_service_info list<blob>,
20+
last_chunk_sent int,
21+
PRIMARY KEY (guid)
22+
)
23+
WITH default_time_to_live = 7200;

apps/astarte_housekeeping/test/support/helpers/database.ex

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ defmodule Astarte.Housekeeping.Helpers.Database do
6868
);
6969
"""
7070

71+
@create_ownership_vouchers_table """
72+
CREATE TABLE :keyspace.ownership_vouchers (
73+
private_key blob,
74+
voucher_data blob,
75+
guid blob,
76+
PRIMARY KEY (guid)
77+
);
78+
"""
79+
7180
@create_devices_table """
7281
CREATE TABLE :keyspace.devices (
7382
device_id uuid,
@@ -304,7 +313,7 @@ defmodule Astarte.Housekeeping.Helpers.Database do
304313
"""
305314

306315
@drop_capabilities_from_devices """
307-
ALTER TABLE :keyspace.devices DROP capabilities;
316+
ALTER TABLE :keyspace.devices DROP capabilities;
308317
"""
309318

310319
def setup(realm_name) do
@@ -325,6 +334,7 @@ defmodule Astarte.Housekeeping.Helpers.Database do
325334
realm_keyspace = Realm.keyspace_name(realm_name)
326335
execute(realm_keyspace, @create_keyspace)
327336
execute(realm_keyspace, @create_capabilities_type)
337+
execute(realm_keyspace, @create_ownership_vouchers_table)
328338
execute(realm_keyspace, @create_devices_table)
329339
execute(realm_keyspace, @create_groups_table)
330340
execute(realm_keyspace, @create_names_table)

0 commit comments

Comments
 (0)