Skip to content

Commit

Permalink
add a generic "fake card" support that uses fixed values for card info (
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpaljak authored Sep 16, 2019
1 parent 39df0a5 commit da35ad4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/fidesmo/fdsm/CommandLineInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ abstract class CommandLineInterface {
final static String OPT_VERSION = "version";

final static String OPT_QA = "qa";
final static String OPT_FAKE = "fake";
final static String OPT_TIMEOUT = "timeout";

protected static String appId = null;
Expand Down Expand Up @@ -145,6 +146,7 @@ protected static OptionSet parseArguments(String[] argv) throws IOException {
parser.accepts(OPT_VERBOSE, "Be verbose");

parser.accepts(OPT_QA, "Run a QA support session").withOptionalArg().ofType(Integer.class).describedAs("QA number");
parser.accepts(OPT_FAKE, "Fake Fidesmo metadata");
parser.accepts(OPT_TIMEOUT, "Timeout for services").withRequiredArg().ofType(Integer.class).describedAs("minutes");

parser.acceptsAll(Arrays.asList("V", OPT_VERSION), "Show version and check for updates");
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/fidesmo/fdsm/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ public static void main(String[] argv) {
terminal = LoggingCardTerminal.getInstance(terminal);
}
Card card = terminal.connect("*");

if (args.has(OPT_FAKE) || args.has(OPT_QA)) {
fidesmoCard = FidesmoCard.fakeInstance(card.getBasicChannel());
} else {
fidesmoCard = FidesmoCard.getInstance(card.getBasicChannel());
}
// Allows to run with any card
if (args.has(OPT_QA)) {
String number = Integer.toString(new Random().nextInt(900000) + 100000).substring(0, 6);
Expand All @@ -232,8 +238,6 @@ public static void main(String[] argv) {
} else {
System.out.printf("Your QA number is %s-%s%n", number.substring(0, 3), number.substring(3, 6));
}
fidesmoCard = FidesmoCard.fakeInstance(card.getBasicChannel());

FormHandler formHandler = getCommandLineFormHandler();

ServiceDeliverySession cardSession = ServiceDeliverySession.getInstance(fidesmoCard, client, formHandler);
Expand All @@ -245,7 +249,6 @@ public static void main(String[] argv) {
success();
}
}
fidesmoCard = FidesmoCard.getInstance(card.getBasicChannel());
System.out.println("Using card in " + terminal.getName());

// Can be used always
Expand Down

0 comments on commit da35ad4

Please sign in to comment.