From 4b780ebe462f45933e3671894f896df466074fb6 Mon Sep 17 00:00:00 2001 From: Henri Chataing Date: Tue, 31 Jan 2023 18:22:57 +0000 Subject: [PATCH] secure_element: Fix the expectation for closeChannel in VTS tests The AIDL interface states that closeChannel must return FAILED if the channel is not opened. The default AIDL implementation did not respect this requirement either. Bug: 266384111 Test: m VtsHalSecureElementTargetTest Change-Id: I3e7142e6bbeb9d79cea2c109689da59c0615167a --- secure_element/aidl/default/main.cpp | 2 +- .../aidl/vts/VtsHalSecureElementTargetTest.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/secure_element/aidl/default/main.cpp b/secure_element/aidl/default/main.cpp index 6149eae387..0822402a87 100644 --- a/secure_element/aidl/default/main.cpp +++ b/secure_element/aidl/default/main.cpp @@ -586,7 +586,7 @@ class EmulatedSecureElement : public BnSecureElement { // The selected basic or logical channel is not opened. if (channel_number >= channels_.size() || !channels_[channel_number].opened) { - return ScopedAStatus::ok(); + return ScopedAStatus::fromServiceSpecificError(FAILED); } // TODO(b/123254068) - this is not an implementation of the OMAPI protocol diff --git a/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp b/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp index c2655793ba..37ff1b207a 100644 --- a/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp +++ b/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp @@ -109,6 +109,7 @@ class SecureElementAidl : public ::testing::TestWithParam { } void TearDown() override { + EXPECT_OK(secure_element_->reset()); secure_element_ = nullptr; secure_element_callback_ = nullptr; } @@ -232,10 +233,10 @@ TEST_P(SecureElementAidl, closeChannel) { std::vector basic_channel_response; LogicalChannelResponse logical_channel_response; - // closeChannel called on non-existing basic or logical channel is a no-op - // and shall succeed. - EXPECT_OK(secure_element_->closeChannel(0)); - EXPECT_OK(secure_element_->closeChannel(1)); + // closeChannel called on non-existing basic or logical channel + // shall fail. + EXPECT_ERR(secure_element_->closeChannel(0)); + EXPECT_ERR(secure_element_->closeChannel(1)); // closeChannel called on basic channel closes the basic channel. EXPECT_OK(secure_element_->openBasicChannel(kSelectableAid, 0x00, &basic_channel_response));