From 6b85d78561803274d45226bd3d063b1b2a04aaa8 Mon Sep 17 00:00:00 2001 From: Kegan Dougal <7190048+kegsay@users.noreply.github.com> Date: Fri, 1 Dec 2023 13:54:26 +0000 Subject: [PATCH] Check mitm from the host --- .github/workflows/tests.yaml | 2 +- internal/deploy/deploy.go | 2 ++ tests/client_connectivity_test.go | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d05bc18..5581ded 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -102,7 +102,7 @@ jobs: export LD_LIBRARY_PATH="$(pwd)/rust-sdk/target/debug" env set -o pipefail && - go test -v -json -timeout 5m ./tests | gotestfmt + go test -v -json -timeout 5m -run '^TestClientRetriesSendToDevice$' ./tests | gotestfmt shell: bash # required for pipefail to be A Thing. pipefail is required to stop gotestfmt swallowing non-zero exit codes name: Run Complement Crypto Tests env: diff --git a/internal/deploy/deploy.go b/internal/deploy/deploy.go index ba1b62a..721a051 100644 --- a/internal/deploy/deploy.go +++ b/internal/deploy/deploy.go @@ -33,6 +33,7 @@ type SlidingSyncDeployment struct { reverseProxy testcontainers.Container slidingSyncURL string mitmClient *http.Client + ControllerURL string proxyURLToHS map[string]string mu sync.RWMutex tcpdump *exec.Cmd @@ -280,6 +281,7 @@ func RunNewDeployment(t *testing.T, shouldTCPDump bool) *SlidingSyncDeployment { reverseProxy: mitmproxyContainer, slidingSyncURL: ssURL, tcpdump: cmd, + ControllerURL: controllerURL, mitmClient: &http.Client{ Timeout: 5 * time.Second, Transport: &http.Transport{ diff --git a/tests/client_connectivity_test.go b/tests/client_connectivity_test.go index 1378b56..2f0640d 100644 --- a/tests/client_connectivity_test.go +++ b/tests/client_connectivity_test.go @@ -1,7 +1,9 @@ package tests import ( + "fmt" "net/http" + "os/exec" "testing" "time" @@ -12,6 +14,11 @@ import ( func TestClientRetriesSendToDevice(t *testing.T) { ClientTypeMatrix(t, func(t *testing.T, clientTypeA, clientTypeB api.ClientType) { tc := CreateTestContext(t, clientTypeA, clientTypeB) + t.Logf("checking mitm") + cmd := exec.Command("curl", "-v", "-X", "POST", "-d", "{}", "-x", tc.Deployment.ControllerURL, "http://mitm.code/options/unlock") + output, cerr := cmd.CombinedOutput() + fmt.Println(cerr) + fmt.Println(string(output)) roomID := tc.CreateNewEncryptedRoom(t, tc.Alice, "public_chat", nil) tc.Bob.MustJoinRoom(t, roomID, []string{clientTypeA.HS}) alice := tc.MustLoginClient(t, tc.Alice, clientTypeA)