1#!/usr/bin/env bash
2# Copyright 2022 Nordic Semiconductor
3# SPDX-License-Identifier: Apache-2.0
4
5source $(dirname "${BASH_SOURCE[0]}")/../../_mesh_test.sh
6
7# Test Node Composition Refresh procedure with persistence storage:
8# 1. Prepare for Composition Data change.
9#    PB-Remote client (1st device):
10#     - provision the 2nd device over PB-Adv
11#     - provision the 3rd device over PB-Remote
12#    PB-Remote server (2nd device):
13#     - wait for being provisioned
14#     - run PB-Remote bearer
15#    PB-Remote server (3rd device):
16#     - wait for being provisioned
17#     - call bt_mesh_comp_change_prepare() to prepare for Composition Data change
18# 2. Verify Node Composition Refresh procedure.
19#    PB-Remote client (1st device):
20#     - check that Composition Data pages 0 (old comp data) and 128 (new comp data) are different
21#     - check that Composition Data pages 1 (old comp data) and 129 (new comp data) are different
22#     - run Node Composition Refresh procedure on the 3rd device
23#     - verify Composition Data pages 0 (new comp data) and 128 (same as page 0)
24#     - verify Composition Data pages 1 (new comp data) and 129 (same as page 1)
25#    PB-Remote server (3rd device):
26#     - start with a new Composition Data
27# 3. Verify that old settings are removed on the 3rd device after Composition Data change.
28#    PB-Remote client (1st device):
29#     - run Node Composition Refresh procedure again and expect it to fail
30#    PB-Remote server (3rd device):
31#     - verify that the device is not re-provisioned again.
32
33# Step 1
34overlay=overlay_pst_conf
35RunTestFlash mesh_prov_pst_pb_remote_ncrp \
36	prov_provisioner_pb_remote_client_ncrp_provision -flash_erase \
37	prov_device_pb_remote_server_unproved -flash_erase \
38	prov_device_pb_remote_server_ncrp_prepare -flash_erase
39
40# Step 2
41overlay=overlay_pst_conf
42RunTestFlash mesh_prov_pst_pb_remote_ncrp \
43	prov_provisioner_pb_remote_client_ncrp \
44	prov_device_pb_remote_server_proved \
45	prov_device_pb_remote_server_ncrp
46
47# Step 3
48overlay=overlay_pst_conf
49RunTestFlash mesh_prov_pst_pb_remote_ncrp \
50	prov_provisioner_pb_remote_client_ncrp_second_time -flash_rm \
51	prov_device_pb_remote_server_proved -flash_rm \
52	prov_device_pb_remote_server_ncrp_second_time -flash_rm
53
54# The same test but with PSA crypto
55# Step 1
56overlay="overlay_pst_conf_overlay_psa_conf"
57RunTestFlash mesh_prov_pst_pb_remote_ncrp_psa \
58	prov_provisioner_pb_remote_client_ncrp_provision -flash_erase \
59	prov_device_pb_remote_server_unproved -flash_erase \
60	prov_device_pb_remote_server_ncrp_prepare -flash_erase
61
62# Step 2
63overlay="overlay_pst_conf_overlay_psa_conf"
64RunTestFlash mesh_prov_pst_pb_remote_ncrp_psa \
65	prov_provisioner_pb_remote_client_ncrp \
66	prov_device_pb_remote_server_proved \
67	prov_device_pb_remote_server_ncrp
68
69# Step 3
70overlay="overlay_pst_conf_overlay_psa_conf"
71RunTestFlash mesh_prov_pst_pb_remote_ncrp_psa \
72	prov_provisioner_pb_remote_client_ncrp_second_time -flash_rm \
73	prov_device_pb_remote_server_proved -flash_rm \
74	prov_device_pb_remote_server_ncrp_second_time -flash_rm
75