Card Simulation and Testing
The Smart Card Shell provides for a framework to implement card simulations and to develop card tests.
Simulating a card serves a number of purposes:
- The functionality of the card interface can be simulated before the actual implementation is available, thus the viability of the design can be verified beforehand.
- Tests can be developed against a known reference and later used to test the actual implementation
- Exceptional card behaviour can be tested much easier, because the simulation can provide for test functions not available in the actual card implementation
- Personalization processes can be developed and tested without waste of material
Simulating a card
The central entry point into the simulation is provided by the CardSimulationAdapter class. An instance of this class is used to receive APDUs and pass them to a simulation object.
The CardSimulationAdapter can be used for server socket based card communication as well as for hardware based interface simulations. Currently however, only the server socket based card communication using the JCOP simulation protocol is available. The counterpart to the JCOP server socket is implemented as JCOPCardTerminal in the OCF protocol stack.
The scripting bundle includes a number of useful script classes to ease the implementation of card simulations. See the provided documentation for details.
Testing a card
Card tests are short script fragments that execute command APDUs against a card and verify that the card implementation shows the required behaviour.
The test framework provides for
- Test Steps - Individual steps in a test scenario
- Test Procedures - Sequence of test steps that are applied for a certain test
- Test Cases - A test setup that verifies a certain aspect of the component under test
- Test Groups - A collection of related test cases
Test cases are organized as a test group in an XML file. Test steps are organized as a test procedure in an XML file. Test cases can invoke test procedures. Parameter passing between tests and test procedures is done using configuration objects.
The XML files allow a proper documentation of the test elements, combining the code for testing with the test documentation. XML files for testing can be converted to HTML files using provided or self-written style sheets.
The execution of tests is done under control of a test runner. A test runner is a script that organizes the loading of XML files and allows the automatic or manual execution of test cases or groups.
For a test drive you could use the simplecard.js script that creates a simple card simulation using server socket communication. To start the simulation use the following command in the Smart Card Shell:
To run the tests against the simulation, you will need to start a second instance of the Smart Card Shell, select the JCOPSimulation as card reader and enter:
Tests can then be selected and run in the test explorer (Right-Click with the mouse on a node in the test explorer).
© Copyright 2003 - 2013 CardContact Software & System Consulting, Minden, Germany