add keycardGetStatusApplication
This commit is contained in:
parent
e3389d6bfe
commit
13463c8106
|
@ -5,9 +5,9 @@ from base/bookmarks as bookmarks_methods import storeBookmark, updateBookmark, g
|
|||
export storeBookmark, updateBookmark, getBookmarks, deleteBookmark
|
||||
|
||||
from base/keycard as keycard_methods import keycardStart, keycardStop, keycardSelect, keycardPair,
|
||||
keycardOpenSecureChannel, keycardVerifyPin, keycardExportKey
|
||||
keycardOpenSecureChannel, keycardVerifyPin, keycardExportKey, keycardGetStatusApplication
|
||||
export keycardStart, keycardStop, keycardSelect, keycardPair,
|
||||
keycardOpenSecureChannel, keycardVerifyPin, keycardExportKey
|
||||
keycardOpenSecureChannel, keycardVerifyPin, keycardExportKey, keycardGetStatusApplication
|
||||
|
||||
import statusgo/bookmarks as statusgo_bookmarks
|
||||
import mock/bookmarks as mock_bookmarks
|
||||
|
|
|
@ -21,3 +21,6 @@ method keycardVerifyPin*(self: Backend, pin: string) =
|
|||
|
||||
method keycardExportKey*(self: Backend, derive: bool, makeCurrent: bool, onlyPublic: bool, path: string): string =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method keycardGetStatusApplication*(self: Backend): KeycardStatus =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
|
|
@ -17,3 +17,6 @@ method keycardVerifyPin*(self: MockBackend, pin: string) = discard
|
|||
|
||||
method keycardExportKey*(self: MockBackend, derive: bool, makeCurrent: bool, onlyPublic: bool, path: string): string =
|
||||
result = "0x00"
|
||||
|
||||
method keycardGetStatusApplication*(self: MockBackend): KeycardStatus =
|
||||
result = KeycardStatus()
|
||||
|
|
|
@ -80,3 +80,14 @@ method keycardExportKey*(self: StatusGoBackend, derive: bool, makeCurrent: bool,
|
|||
raise KeycardSelectException(error: parsedResponse{"error"}.getStr())
|
||||
|
||||
result = parsedResponse["key"].getStr()
|
||||
|
||||
method keycardGetStatusApplication*(self: StatusGoBackend): KeycardStatus =
|
||||
let response = keycard_go.getStatusApplication()
|
||||
let parsedResponse = parseJson(response)
|
||||
if not parsedResponse{"ok"}.getBool():
|
||||
raise KeycardGetStatusException(error: parsedResponse{"error"}.getStr())
|
||||
result = KeycardStatus(
|
||||
pinRetryCount: parsedResponse["status"]["pinRetryCount"].getInt(),
|
||||
pukRetryCount: parsedResponse["status"]["pukRetryCount"].getInt(),
|
||||
keyInitialized: parsedResponse["status"]["keyInitialized"].getBool()
|
||||
)
|
||||
|
|
|
@ -52,3 +52,9 @@ proc exportKey*(self: KeycardModel, derive: bool, makeCurrent: bool, onlyPublic:
|
|||
result = self.backend.keycardExportKey(derive, makeCurrent, onlyPublic, path)
|
||||
except:
|
||||
raise
|
||||
|
||||
proc getStatusApplication*(self: KeycardModel): KeycardStatus =
|
||||
try:
|
||||
result = self.backend.keycardGetStatusApplication()
|
||||
except:
|
||||
raise
|
||||
|
|
|
@ -49,3 +49,18 @@ suite "#Keycard":
|
|||
except KeycardException as ex:
|
||||
echo "keycard exception"
|
||||
echo repr(ex)
|
||||
|
||||
test "getStatusApplication":
|
||||
try:
|
||||
statuslib_instance.keycard.start()
|
||||
discard statuslib_instance.keycard.select()
|
||||
statuslib_instance.keycard.openSecureChannel(0, "000000")
|
||||
let info = statuslib_instance.keycard.getStatusApplication()
|
||||
# echo repr(info)
|
||||
statuslib_instance.keycard.stop()
|
||||
except KeycardGetStatusException as ex:
|
||||
echo "keycard get status exception"
|
||||
echo repr(ex)
|
||||
except KeycardException as ex:
|
||||
echo "keycard exception"
|
||||
echo repr(ex)
|
||||
|
|
|
@ -11,6 +11,8 @@ type KeycardPairException* = ref object of KeycardException
|
|||
|
||||
type KeycardOpenSecureChannelException* = ref object of KeycardException
|
||||
|
||||
type KeycardGetStatusException* = ref object of KeycardException
|
||||
|
||||
type KeycardVerifyPINException* = ref object of KeycardException
|
||||
pinRetry*: int64
|
||||
|
||||
|
@ -29,3 +31,9 @@ type KeycardApplicationInfo* = ref object
|
|||
type KeycardPairingInfo* = ref object
|
||||
key*: string
|
||||
index*: int64
|
||||
|
||||
type KeycardStatus* = ref object
|
||||
pinRetryCount*: int64
|
||||
pukRetryCount *: int64
|
||||
keyInitialized*: bool
|
||||
path*: string
|
||||
|
|
Loading…
Reference in New Issue