From 2e5ae152ac1489e5944418020f68287d53a02237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Fri, 18 Feb 2022 20:57:26 +0100 Subject: Test: update-local-identity command --- src/Test.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Test.hs b/src/Test.hs index 994f543..8155bdb 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -163,6 +163,7 @@ commands = map (T.pack *** id) , ("start-server", cmdStartServer) , ("watch-local-identity", cmdWatchLocalIdentity) , ("watch-shared-identity", cmdWatchSharedIdentity) + , ("update-local-identity", cmdUpdateLocalIdentity) , ("update-shared-identity", cmdUpdateSharedIdentity) , ("attach-to", cmdAttachTo) , ("attach-accept", cmdAttachAccept) @@ -245,6 +246,22 @@ cmdWatchSharedIdentity = do outLine out $ "shared-identity-failed" modify $ \s -> s { tsWatchedSharedIdentity = Just w } +cmdUpdateLocalIdentity :: Command +cmdUpdateLocalIdentity = do + [name] <- asks tiParams + updateLocalState_ $ \ls -> do + let Just identity = validateIdentity $ lsIdentity $ fromStored ls + st = storedStorage ls + public = idKeyIdentity identity + + Just secret <- loadKey public + nidata <- maybe (error "created invalid identity") (return . idData) . validateIdentity =<< + wrappedStore st =<< sign secret =<< wrappedStore st (emptyIdentityData public) + { iddPrev = toList $ idDataF identity + , iddName = Just name + } + wrappedStore st $ (fromStored ls) { lsIdentity = nidata } + cmdUpdateSharedIdentity :: Command cmdUpdateSharedIdentity = do [name] <- asks tiParams -- cgit v1.2.3