1 /* 2 * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <service/secure_storage/frontend/psa/ps/ps_frontend.h> 8 #include <service/secure_storage/frontend/psa/ps/test/ps_api_tests.h> 9 #include <service/secure_storage/frontend/psa/its/its_frontend.h> 10 #include <service/secure_storage/frontend/psa/its/test/its_api_tests.h> 11 #include <service/secure_storage/backend/secure_storage_client/secure_storage_client.h> 12 #include <protocols/rpc/common/packed-c/encoding.h> 13 #include <service_locator.h> 14 #include <CppUTest/TestHarness.h> 15 16 /* 17 * Service-level tests using the PSA Protected Storage and Internal 18 * Trusted Storage APIs to access the secure storage service with the 19 * 'protected-storage' designation. 20 */ TEST_GROUP(PsServiceTests)21TEST_GROUP(PsServiceTests) 22 { 23 void setup() 24 { 25 m_rpc_session = NULL; 26 m_its_service_context = NULL; 27 28 service_locator_init(); 29 30 m_its_service_context = service_locator_query("sn:trustedfirmware.org:protected-storage:0"); 31 CHECK(m_its_service_context); 32 33 m_rpc_session = service_context_open(m_its_service_context); 34 CHECK(m_rpc_session); 35 36 struct storage_backend *storage_backend = secure_storage_client_init(&m_storage_client, m_rpc_session); 37 38 psa_ps_frontend_init(storage_backend); 39 psa_its_frontend_init(storage_backend); 40 } 41 42 void teardown() 43 { 44 psa_ps_frontend_init(NULL); 45 psa_its_frontend_init(NULL); 46 47 if (m_its_service_context) { 48 if (m_rpc_session) { 49 service_context_close(m_its_service_context, m_rpc_session); 50 m_rpc_session = NULL; 51 } 52 53 service_context_relinquish(m_its_service_context); 54 m_its_service_context = NULL; 55 } 56 57 secure_storage_client_deinit(&m_storage_client); 58 } 59 60 struct rpc_caller_session *m_rpc_session; 61 struct service_context *m_its_service_context; 62 struct secure_storage_client m_storage_client; 63 }; 64 TEST(PsServiceTests,storeNewItem)65TEST(PsServiceTests, storeNewItem) 66 { 67 its_api_tests::storeNewItem(); 68 } 69 TEST(PsServiceTests,createAndSet)70TEST(PsServiceTests, createAndSet) 71 { 72 ps_api_tests::set(); 73 } 74 TEST(PsServiceTests,createAndSetExtended)75TEST(PsServiceTests, createAndSetExtended) 76 { 77 ps_api_tests::createAndSetExtended(); 78 }