mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-24 06:13:39 +00:00
api to rotate keys, option to show full links in CLI
This commit is contained in:
1 parent
effea1c471
commit
f58d00437c
13 files changed
+101
-45
No files matched your search
@@ -117,6 +117,7 @@ testOpts =
|
||||
optFilesFolder = Nothing,
|
||||
optTempDirectory = Nothing,
|
||||
showReactions = True,
|
||||
showFullLinks = True,
|
||||
allowInstantFiles = True,
|
||||
autoAcceptFileSize = 0,
|
||||
muteNotifications = True,
|
||||
@@ -168,6 +169,12 @@ testCoreOpts =
|
||||
relayTestOpts :: ChatOpts
|
||||
relayTestOpts = testOpts {coreOptions = testCoreOpts {chatRelay = True}}
|
||||
|
||||
testOptsNoFullLinks :: ChatOpts
|
||||
testOptsNoFullLinks = testOpts {showFullLinks = False}
|
||||
|
||||
relayTestOptsNoFullLinks :: ChatOpts
|
||||
relayTestOptsNoFullLinks = relayTestOpts {showFullLinks = False}
|
||||
|
||||
relayWebTestOpts :: Text -> FilePath -> Maybe FilePath -> ChatOpts
|
||||
relayWebTestOpts webDomain webDir webCorsFile = testOpts {coreOptions = testCoreOpts {chatRelay = True, webPreviewConfig = Just WebPreviewConfig {webDomain, webJsonDir = webDir, webCorsFile, webUpdateInterval = 300, webPreviewItemCount = 50}}}
|
||||
|
||||
|
||||
@@ -2707,7 +2707,7 @@ testPlanGroupLinkLeaveRejoin =
|
||||
|
||||
testGroupLink :: HasCallStack => TestParams -> IO ()
|
||||
testGroupLink =
|
||||
testChat3 aliceProfile bobProfile cathProfile $
|
||||
testChatOpts3 testOptsNoFullLinks aliceProfile bobProfile cathProfile $
|
||||
\alice bob cath -> do
|
||||
threadDelay 100000
|
||||
alice ##> "/g team"
|
||||
@@ -2719,7 +2719,8 @@ testGroupLink =
|
||||
alice <## "Recent history: off"
|
||||
|
||||
alice ##> "/create link #team"
|
||||
gLink <- getGroupLink alice "team" GRMember True
|
||||
gLink <- getGroupLink_ alice "team" GRMember True
|
||||
alice <// 100000 -- the "group link for old clients" line is dropped when showFullLinks is off
|
||||
bob ##> ("/c " <> gLink)
|
||||
bob <## "connection request sent!"
|
||||
alice <## "bob (Bob): accepting request to join group #team..."
|
||||
@@ -2745,7 +2746,8 @@ testGroupLink =
|
||||
|
||||
-- user address doesn't interfere
|
||||
alice ##> "/ad"
|
||||
cLink <- getContactLink alice True
|
||||
cLink <- getContactLink_ alice True
|
||||
alice <// 100000 -- the "contact link for old clients" line is dropped when showFullLinks is off
|
||||
cath ##> ("/c " <> cLink)
|
||||
alice <#? cath
|
||||
alice ##> "/ac cath"
|
||||
@@ -8673,11 +8675,12 @@ testSupportPreferenceChannel ps =
|
||||
|
||||
testConnectChannelCLI :: HasCallStack => TestParams -> IO ()
|
||||
testConnectChannelCLI ps =
|
||||
withNewTestChat ps "alice" aliceProfile $ \alice ->
|
||||
withNewTestChatOpts ps relayTestOpts "bob" bobProfile $ \bob ->
|
||||
withNewTestChatOpts ps relayTestOpts "cath" cathProfile $ \cath ->
|
||||
withNewTestChat ps "dan" danProfile $ \dan -> do
|
||||
(shortLink, _fullLink) <- prepareChannel2Relays "team" alice bob cath
|
||||
withNewTestChatOpts ps testOptsNoFullLinks "alice" aliceProfile $ \alice ->
|
||||
withNewTestChatOpts ps relayTestOptsNoFullLinks "bob" bobProfile $ \bob ->
|
||||
withNewTestChatOpts ps relayTestOptsNoFullLinks "cath" cathProfile $ \cath ->
|
||||
withNewTestChatOpts ps testOptsNoFullLinks "dan" danProfile $ \dan -> do
|
||||
(shortLink, fullLink) <- prepareChannel2Relays "team" alice bob cath
|
||||
fullLink `shouldBe` "" -- public group link "for old clients" is dropped when showFullLinks is off
|
||||
relayNames <- mapM userName [bob, cath]
|
||||
mName <- userName dan
|
||||
mFullName <- showName dan
|
||||
|
||||
@@ -61,6 +61,7 @@ chatProfileTests = do
|
||||
it "supporter badge sent to contact connecting via address" testUserBadgeContactAddress
|
||||
describe "user contact link" $ do
|
||||
it "create and connect via contact link" testUserContactLink
|
||||
it "rotate address ratchet keys" testRotateAddressRatchetKeys
|
||||
it "create address on specified server" testCreateAddressOnServer
|
||||
it "retry connecting via contact link" testRetryConnectingViaContactLink
|
||||
it "add contact link to profile" testProfileLink
|
||||
@@ -616,10 +617,11 @@ testMultiWordProfileNames =
|
||||
|
||||
testUserContactLink :: HasCallStack => TestParams -> IO ()
|
||||
testUserContactLink =
|
||||
testChat3 aliceProfile bobProfile cathProfile $
|
||||
testChatOpts3 testOptsNoFullLinks aliceProfile bobProfile cathProfile $
|
||||
\alice bob cath -> do
|
||||
alice ##> "/ad"
|
||||
cLink <- getContactLink alice True
|
||||
cLink <- getContactLink_ alice True
|
||||
alice <// 100000 -- the "contact link for old clients" line is dropped when showFullLinks is off
|
||||
bob ##> ("/c " <> cLink)
|
||||
alice <#? bob
|
||||
alice @@@ [("@bob", "Audio/video calls: enabled")]
|
||||
@@ -644,6 +646,29 @@ testUserContactLink =
|
||||
alice @@@ [("@cath", lastChatFeature), ("@bob", "hey")]
|
||||
alice <##> cath
|
||||
|
||||
testRotateAddressRatchetKeys :: HasCallStack => TestParams -> IO ()
|
||||
testRotateAddressRatchetKeys =
|
||||
testChatOpts2 testOptsNoFullLinks aliceProfile bobProfile $ \alice bob -> do
|
||||
alice ##> "/ad"
|
||||
sLink1 <- getContactLink_ alice True
|
||||
alice ##> ("/_connect plan 1 " <> sLink1)
|
||||
alice <## "contact address: own address"
|
||||
alice ##> "/_rotate_address_keys 1"
|
||||
sLink2 <- getContactLink_ alice False
|
||||
alice <## "auto_accept off"
|
||||
-- rotated address keeps the same identity (still recognized as own address)
|
||||
alice ##> ("/_connect plan 1 " <> sLink2)
|
||||
alice <## "contact address: own address"
|
||||
-- and it still works for connecting
|
||||
bob ##> ("/c " <> sLink2)
|
||||
alice <#? bob
|
||||
alice ##> "/ac bob"
|
||||
alice <## "bob (Bob): accepting contact request, you can send messages to contact"
|
||||
concurrently_
|
||||
(bob <## "alice (Alice): contact is connected")
|
||||
(alice <## "bob (Bob): contact is connected")
|
||||
alice <##> bob
|
||||
|
||||
testCreateAddressOnServer :: HasCallStack => TestParams -> IO ()
|
||||
testCreateAddressOnServer ps = testChat aliceProfile test ps
|
||||
where
|
||||
@@ -3047,9 +3072,10 @@ testSetUITheme =
|
||||
|
||||
testShortLinkInvitation :: HasCallStack => TestParams -> IO ()
|
||||
testShortLinkInvitation =
|
||||
testChat2 aliceProfile bobProfile $ \alice bob -> do
|
||||
testChatOpts2 testOptsNoFullLinks aliceProfile bobProfile $ \alice bob -> do
|
||||
alice ##> "/c"
|
||||
(inv, _) <- getInvitations alice
|
||||
inv <- getInvitation_ alice
|
||||
alice <// 100000 -- the "invitation link for old clients" line is dropped when showFullLinks is off
|
||||
bob ##> ("/c " <> inv)
|
||||
bob <## "confirmation sent!"
|
||||
concurrently_
|
||||
|
||||
@@ -560,6 +560,12 @@ dropPartialReceipt_ msg = case splitAt 2 msg of
|
||||
("% ", text) -> Just text
|
||||
_ -> Nothing
|
||||
|
||||
getForOldClientsLine :: HasCallStack => TestCC -> String -> IO String
|
||||
getForOldClientsLine cc prefix =
|
||||
timeout 500000 (getTermLine cc) >>= \case
|
||||
Just line -> dropLinePrefix prefix line
|
||||
Nothing -> pure ""
|
||||
|
||||
getInvitation :: HasCallStack => TestCC -> IO String
|
||||
getInvitation cc = do
|
||||
(_, fullInv) <- getInvitations cc
|
||||
@@ -592,8 +598,7 @@ getContactLink cc created = do
|
||||
getContactLinks :: HasCallStack => TestCC -> Bool -> IO (String, String)
|
||||
getContactLinks cc created = do
|
||||
shortLink <- getContactLink_ cc created
|
||||
line <- getTermLine' (Just "full contact link line") cc
|
||||
fullLink <- dropLinePrefix "The contact link for old clients: " line
|
||||
fullLink <- getForOldClientsLine cc "The contact link for old clients: "
|
||||
pure (shortLink, fullLink)
|
||||
|
||||
getContactLinkNoShortLink :: HasCallStack => TestCC -> Bool -> IO String
|
||||
@@ -624,8 +629,7 @@ getGroupLink cc gName mRole created = do
|
||||
getGroupLinks :: HasCallStack => TestCC -> String -> GroupMemberRole -> Bool -> IO (String, String)
|
||||
getGroupLinks cc gName mRole created = do
|
||||
shortLink <- getGroupLink_ cc gName mRole created
|
||||
line <- getTermLine' (Just "full group link line") cc
|
||||
fullLink <- dropLinePrefix "The group link for old clients: " line
|
||||
fullLink <- getForOldClientsLine cc "The group link for old clients: "
|
||||
pure (shortLink, fullLink)
|
||||
|
||||
getGroupLinkNoShortLink :: HasCallStack => TestCC -> String -> GroupMemberRole -> Bool -> IO String
|
||||
|
||||
Reference in new issue
Block a user