generated from matrix-org/.github
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from matrix-org/andybalaam/test-retrying-device…
…-key-download Test 'If a client cannot query device keys for a user, it retries.'
- Loading branch information
Showing
3 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
js-sdk/node_modules | ||
js-sdk/dist | ||
internal/api/js/chrome/dist | ||
__pycache__ | ||
/internal/api/js/chrome/dist | ||
__pycache__ | ||
/rust-sdk/ | ||
/tests/logs/ | ||
/tests/chromedp/ | ||
/tests/rust_storage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package tests | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
"time" | ||
|
||
"github.com/matrix-org/complement-crypto/internal/api" | ||
) | ||
|
||
// If a client cannot query device keys for a user, it retries. | ||
// | ||
// Block the first few requests to /keys/query so device key download fails. | ||
// Create two users and ensure they can send encrypted messages to each other. | ||
// This proves that device keys download requests get retried. | ||
func TestFailedDeviceKeyDownloadRetries(t *testing.T) { | ||
ForEachClientType(t, func(t *testing.T, clientType api.ClientType) { | ||
tc := CreateTestContext(t, clientType, clientType) | ||
// Given that the first 4 attempts to download device keys will fail | ||
tc.Deployment.WithMITMOptions(t, map[string]interface{}{ | ||
"statuscode": map[string]interface{}{ | ||
"return_status": http.StatusGatewayTimeout, | ||
"block_request": true, | ||
"count": 4, | ||
"filter": "~u .*\\/keys\\/query.* ~m POST", | ||
}, | ||
}, func() { | ||
// And Alice and Bob are in an encrypted room together | ||
roomID := tc.CreateNewEncryptedRoom(t, tc.Alice, "private_chat", []string{tc.Bob.UserID}) | ||
tc.Bob.MustJoinRoom(t, roomID, []string{"hs1"}) | ||
|
||
alice := tc.MustLoginClient(t, tc.Alice, clientType) | ||
defer alice.Close(t) | ||
bob := tc.MustLoginClient(t, tc.Bob, clientType) | ||
defer bob.Close(t) | ||
aliceStopSyncing := alice.MustStartSyncing(t) | ||
defer aliceStopSyncing() | ||
bobStopSyncing := bob.MustStartSyncing(t) | ||
defer bobStopSyncing() | ||
|
||
// When Alice sends a message | ||
alice.SendMessage(t, roomID, "checking whether we can send a message") | ||
|
||
// Then Bob should receive it | ||
bob.WaitUntilEventInRoom( | ||
t, | ||
roomID, | ||
api.CheckEventHasBody("checking whether we can send a message"), | ||
).Wait(t, 5*time.Second) | ||
}) | ||
}) | ||
} |