core: fix api for encryption (#1025)

This commit is contained in:
Evgeny Poberezkin
2022-09-06 21:25:07 +01:00
committed by GitHub
parent 039f810f4f
commit 7072dd4f7e
2 changed files with 5 additions and 3 deletions

View File

@@ -2544,7 +2544,7 @@ chatCommandP =
"/_db export " *> (APIExportArchive <$> jsonP),
"/_db import " *> (APIImportArchive <$> jsonP),
"/_db delete" $> APIDeleteStorage,
"/_db encryption" *> (APIStorageEncryption <$> jsonP),
"/_db encryption " *> (APIStorageEncryption <$> jsonP),
"/db encrypt " *> (APIStorageEncryption . DBEncryptionConfig "" <$> dbKeyP),
"/db password " *> (APIStorageEncryption <$> (DBEncryptionConfig <$> dbKeyP <* A.space <*> dbKeyP)),
"/db decrypt " *> (APIStorageEncryption . (`DBEncryptionConfig` "") <$> dbKeyP),

View File

@@ -2790,13 +2790,15 @@ testDatabaseEncryption = withTmpFiles $ do
alice <## "chat stopped"
alice ##> "/db password mykey nextkey"
alice <## "ok"
withTestChatOpts testOpts {maintenance = True, dbKey = "nextkey"} "alice" $ \alice -> do
alice ##> "/_db encryption {\"currentKey\":\"nextkey\",\"newKey\":\"anotherkey\"}"
alice <## "ok"
withTestChatOpts testOpts {maintenance = True, dbKey = "anotherkey"} "alice" $ \alice -> do
alice ##> "/_start"
alice <## "chat started"
testChatWorking alice bob
alice ##> "/_stop"
alice <## "chat stopped"
alice ##> "/db decrypt nextkey"
alice ##> "/db decrypt anotherkey"
alice <## "ok"
withTestChat "alice" $ \alice -> testChatWorking alice bob