diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2022-02-18 20:57:26 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2022-02-18 20:57:26 +0100 |
commit | 2e5ae152ac1489e5944418020f68287d53a02237 (patch) | |
tree | 179655beb0e6d8611e651fe50546b47a0b1d59be | |
parent | 1b9ab11b4bebd73c2419fcf7b430d8be5e6ef14d (diff) |
Test: update-local-identity command
-rw-r--r-- | src/Test.hs | 17 |
1 files changed, 17 insertions, 0 deletions
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 |