Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
HTTP/2.0 201 Created
Content-Length: 208
Content-Length: 29
Content-Type: application/vnd.atlas.2023-01-01+json;charset=utf-8
Date: Mon, 12 May 2025 05:08:20 GMT
Referrer-Policy: strict-origin-when-cross-origin
Expand All @@ -13,4 +13,4 @@ X-Java-Version: 17.0.14+7
X-Mongodb-Service-Version: gitHash=b4fa165bfbcb725abc0816ef770e5f595c0528ce; versionString=master
X-Permitted-Cross-Domain-Policies: none

{"linkToken":"eyJvcmdJZCI6IjVlZmRhNjgyYTNmMmVkMmU3ZGQ2Y2RlNCIsIm9yZ05hbWUiOiJBdGxhcyBDTEkgRTJFIiwicHJpdmF0ZUFwaUtleSI6ImI4Y2QxMDUzLWUxZDYtNGRlZS04MTYxLWViODMwMDA2YTA4YiIsInB1YmxpY0FwaUtleSI6InhrdnNpZ3NuIn0="}
{"linkToken":"redactedToken"}
15 changes: 15 additions & 0 deletions test/internal/atlas_e2e_test_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"os/exec"
"path"
"path/filepath"
"regexp"
"slices"
"strconv"
"strings"
Expand All @@ -43,6 +44,7 @@ import (
)

const updateSnapshotsEnvVarKey = "UPDATE_SNAPSHOTS"
const redactedToken = "redactedToken"

type snapshotMode int

Expand Down Expand Up @@ -524,6 +526,8 @@ func (g *AtlasE2ETestGenerator) maskString(s string) string {
o = strings.ReplaceAll(o, os.Getenv("E2E_FLEX_INSTANCE_NAME"), "test-flex")
o = strings.ReplaceAll(o, os.Getenv("E2E_TEST_BUCKET"), "test-bucket")
o = strings.ReplaceAll(o, g.snapshotTargetURI, "http://localhost:8080/")
o = replaceLinkToken(o)

return o
}

Expand Down Expand Up @@ -661,6 +665,17 @@ func (g *AtlasE2ETestGenerator) prepareSnapshot(r *http.Response) *http.Response
return resp
}

func replaceLinkToken(out string) string {
if !strings.Contains(out, `"linkToken"`) {
return out
}

redactedObject := []byte(`{"linkToken":"` + redactedToken + `"}`)

jsonObjectRe := regexp.MustCompile(`\{[^{]*"linkToken"\s*:\s*"[^"]*"[^}]*\}`)
return string(jsonObjectRe.ReplaceAll([]byte(out), redactedObject))
}

func (g *AtlasE2ETestGenerator) storeSnapshot(r *http.Response) {
g.t.Helper()

Expand Down
Loading