diff options
Diffstat (limited to 'src')
-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 |