X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=t%2Ffiles%2Fbin%2Fykinfo;h=a8cc0218e0d273ff314e2dc7f47475e0e166e394;hb=1cb0bf6303ca36b5d7e907ee6801c765053c3ab2;hp=8a93cc3b208d2c7cd555b67a0afbdb5141af7fe6;hpb=f63182fc62b25269b1c38588dca2b3535ed1a1a2;p=chaz%2Fp5-File-KDBX diff --git a/t/files/bin/ykinfo b/t/files/bin/ykinfo index 8a93cc3..a8cc021 100755 --- a/t/files/bin/ykinfo +++ b/t/files/bin/ykinfo @@ -1,43 +1,37 @@ -#!/bin/sh +#!/usr/bin/env perl # This is a fake ykinfo program that provides canned responses, for testing. -device= -all= +use warnings; +use strict; -while getopts an: arg -do - case "$arg" in - n) - device="$OPTARG" - ;; - a) - all=1 - ;; - esac -done +use Getopt::Std; -case "$device" in - 0) - printf 'serial: 123 +our ($opt_a, $opt_n); +getopts('an:'); + +my $device = $opt_n // -1; + +if ($device == 0) { + print q{serial: 123 version: 2.0.0 touch_level: 0 vendor_id: 1050 product_id: 113 -' - exit 0 - ;; - 1) - printf 'serial: 456 +}; + exit 0; +} +elsif ($device == 1) { + print q{serial: 456 version: 3.0.1 touch_level: 10 vendor_id: 1050 product_id: 401 -' - exit 0 - ;; - *) - echo "Yubikey core error: no yubikey present" >&2 - exit 1 -esac +}; + exit 0; +} +else { + print STDERR "Yubikey core error: no yubikey present\n"; + exit 1; +}