@@ -23,6 +23,7 @@ public class AppletBasicTest {
2323
2424 CardSimulator simulator ;
2525 AID appletAID = AIDUtil .create ("F000000001" );
26+ AID randoAID = AIDUtil .create ("F100900001" );
2627
2728 @ BeforeEach
2829 public void setupApplet () {
@@ -42,15 +43,10 @@ private ResponseAPDU sendCTAP(String hexCommand) {
4243 return sendCTAP (bparams );
4344 }
4445
45- private ResponseAPDU send (int ... params ) {
46- byte [] bparams = new byte [params .length ];
47- for (int i = 0 ; i < params .length ; i ++) {
48- bparams [i ] = (byte ) params [i ];
49- }
46+ private ResponseAPDU send (byte [] bparams ) {
5047 CommandAPDU commandAPDU = new CommandAPDU (bparams );
5148 ResponseAPDU response = simulator .transmitCommand (commandAPDU );
5249
53-
5450 ArrayList <ResponseAPDU > prevResponses = new ArrayList <>();
5551 int totalResponseLen = response .getNr ();
5652 prevResponses .add (response );
@@ -79,6 +75,15 @@ private ResponseAPDU send(int... params) {
7975 return new ResponseAPDU (combinedBB );
8076 }
8177
78+ private ResponseAPDU send (int ... params ) {
79+ byte [] bparams = new byte [params .length ];
80+ for (int i = 0 ; i < params .length ; i ++) {
81+ bparams [i ] = (byte ) params [i ];
82+ }
83+
84+ return send (bparams );
85+ }
86+
8287 private ResponseAPDU sendCTAP (int ... vals ) {
8388 boolean shortLen = vals .length <= 255 ;
8489 int [] framedVals = new int [vals .length + (shortLen ? 6 : 7 )]; // Hmm, why isn't this 8 for extended length?
@@ -150,4 +155,15 @@ public void checkVersionInSelectionResponse() {
150155 assertEquals ("FIDO_2_0" , new String (respWithoutStatus ));
151156 }
152157
158+ @ Test
159+ public void checkIgnoreSelectingIncorrectAID () {
160+ byte [] resp = simulator .selectAppletWithResult (appletAID );
161+ short recvdStatus = (short ) (resp [resp .length - 2 ] * 256 + resp [resp .length - 1 ]);
162+
163+ assertEquals (ISO7816 .SW_NO_ERROR , recvdStatus );
164+
165+ ResponseAPDU responseAPDU = send (AIDUtil .select (randoAID ));
166+ assertEquals (ISO7816 .SW_FILE_NOT_FOUND , responseAPDU .getSW ());
167+ }
168+
153169}
0 commit comments