Add test for NFC smartcard tag reset failure.
This commit is contained in:
Родитель
458742f1e8
Коммит
daf9585fc0
|
@ -148,6 +148,18 @@ const SimSequenceStep TagSequences::Ntag216::DiscoverSelectResponse = SimSequenc
|
|||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep TagSequences::Ntag216::ActivateFailedNotification = SimSequenceStep::NciControlRead(
|
||||
L"CORE_GENERIC_ERROR_NTF (Activation Failed)",
|
||||
{
|
||||
phNciNfc_e_NciCoreMsgTypeCntrlNtf,
|
||||
phNciNfc_e_CoreNciCoreGid,
|
||||
phNciNfc_e_NciCoreGenericErrNtfOid,
|
||||
{
|
||||
PH_NCINFC_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED, // Status
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
// NTAG213/215/216, Rev. 3.2, Section 10.2, Table 29. READ command
|
||||
const SimSequenceStep TagSequences::Ntag216::ReadPage2Command = SimSequenceStep::NciDataWrite(
|
||||
L"[Mifare] READ page 2 command",
|
||||
|
@ -268,6 +280,17 @@ const SimSequenceStep TagSequences::Ntag216::ResetSequence[6]
|
|||
ActivatedNotification,
|
||||
};
|
||||
|
||||
// Sequence when the tag is reset through IOCTL_SMARTCARD_POWER but the tag has disappeared.
|
||||
const SimSequenceStep TagSequences::Ntag216::ResetFailedSequence[6] =
|
||||
{
|
||||
DeactivateCommand,
|
||||
DeactivateResponse,
|
||||
DeactivateNotification,
|
||||
DiscoverSelectCommand,
|
||||
DiscoverSelectResponse,
|
||||
ActivateFailedNotification
|
||||
};
|
||||
|
||||
const SimSequenceStep TagSequences::Ntag216::ReadSequence[18] =
|
||||
{
|
||||
// Driver reads bytes from the tag to verify that the connection is working.
|
||||
|
|
|
@ -24,6 +24,7 @@ struct TagSequences
|
|||
static const SimSequenceStep DeactivateNotification;
|
||||
static const SimSequenceStep DiscoverSelectCommand;
|
||||
static const SimSequenceStep DiscoverSelectResponse;
|
||||
static const SimSequenceStep ActivateFailedNotification;
|
||||
|
||||
static const SimSequenceStep ReadPage2Command;
|
||||
static const SimSequenceStep ReadPage2Response;
|
||||
|
@ -35,6 +36,7 @@ struct TagSequences
|
|||
|
||||
static const SimSequenceStep ActivatedSequence[10];
|
||||
static const SimSequenceStep ResetSequence[6];
|
||||
static const SimSequenceStep ResetFailedSequence[6];
|
||||
|
||||
static const SimSequenceStep ReadSequence[18];
|
||||
static const SimSequenceStep PresenceCheckConnected[2];
|
||||
|
|
|
@ -31,8 +31,16 @@ public:
|
|||
TEST_METHOD_PROPERTY(L"Category", L"GoldenPath")
|
||||
END_TEST_METHOD()
|
||||
|
||||
BEGIN_TEST_METHOD(ResetAndTagDisappearsNci1Test)
|
||||
TEST_METHOD_PROPERTY(L"Category", L"Reliability")
|
||||
END_TEST_METHOD()
|
||||
BEGIN_TEST_METHOD(ResetAndTagDisappearsNci2Test)
|
||||
TEST_METHOD_PROPERTY(L"Category", L"Reliability")
|
||||
END_TEST_METHOD()
|
||||
|
||||
private:
|
||||
void ResetAndGetAtrTest(bool isNci2);
|
||||
void ResetAndTagDisappearsTest(bool isNci2);
|
||||
|
||||
void StartNfcController(NciSimConnector& simConnector, bool isNci2);
|
||||
void StopNfcController(NciSimConnector& simConnector, bool isNci2);
|
||||
|
@ -90,6 +98,54 @@ SmartcardTagTests::ResetAndGetAtrNci2Test()
|
|||
ResetAndGetAtrTest(true);
|
||||
}
|
||||
|
||||
void
|
||||
SmartcardTagTests::ResetAndTagDisappearsTest(bool isNci2)
|
||||
{
|
||||
LOG_COMMENT(L"# Open connection to NCI Simulator Driver.");
|
||||
NciSimConnector simConnector;
|
||||
|
||||
// Start the NFC Controller.
|
||||
StartNfcController(simConnector, isNci2);
|
||||
|
||||
// Try to find the smartcard (NFC) interface and open it.
|
||||
UniqueHandle nfcScInterface = DriverHandleFactory::OpenSmartcardHandle(simConnector.DeviceId().c_str(), SmartCardReaderKind::Nfc);
|
||||
|
||||
// Present an NFC tag in the reader.
|
||||
PresentTag(simConnector, isNci2, nfcScInterface.Get());
|
||||
|
||||
// Issue a smartcard reset and read the ATR.
|
||||
DWORD powerType = SCARD_COLD_RESET;
|
||||
std::shared_ptr<IoOperation> ioReset = IoOperation::DeviceIoControl(nfcScInterface.Get(), IOCTL_SMARTCARD_POWER, &powerType, sizeof(powerType), 0);
|
||||
|
||||
// Tag will be deactivated and reactivated. But fail the reactivation.
|
||||
SimSequenceRunner::Run(simConnector, TagSequences::Ntag216::ResetFailedSequence);
|
||||
|
||||
// Get the result of the reset operation.
|
||||
// Even though the tag reactivation failed, the NFC CX pretends that the reset was successful. But it will eventually
|
||||
// report the tag as absent once the presence check runs again.
|
||||
VERIFY_IS_TRUE(ioReset->Wait(1'000));
|
||||
IoOperationResult ioResetResult = ioReset->Get();
|
||||
VERIFY_WIN32_SUCCEEDED(ioResetResult.ErrorCode);
|
||||
|
||||
// Tag has disconnected due to the reactivation failure.
|
||||
AfterTagDisconnected(simConnector, isNci2, nfcScInterface.Get());
|
||||
|
||||
// Stop the NFC controller.
|
||||
StopNfcController(simConnector, isNci2);
|
||||
}
|
||||
|
||||
void
|
||||
SmartcardTagTests::ResetAndTagDisappearsNci1Test()
|
||||
{
|
||||
ResetAndTagDisappearsTest(false);
|
||||
}
|
||||
|
||||
void
|
||||
SmartcardTagTests::ResetAndTagDisappearsNci2Test()
|
||||
{
|
||||
ResetAndTagDisappearsTest(true);
|
||||
}
|
||||
|
||||
// Starts the NFC Controller.
|
||||
void
|
||||
SmartcardTagTests::StartNfcController(NciSimConnector& simConnector, bool isNci2)
|
||||
|
|
Загрузка…
Ссылка в новой задаче