Skip to content

Commit

Permalink
Update azwebpubsub tests for new test proxy (Azure#22892)
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell authored May 13, 2024
1 parent 4fd61cc commit c539d69
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 59 deletions.
2 changes: 1 addition & 1 deletion sdk/messaging/azwebpubsub/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "go",
"TagPrefix": "go/messaging/azwebpubsub",
"Tag": "go/messaging/azwebpubsub_94be93d99b"
"Tag": "go/messaging/azwebpubsub_2540bb848a"
}
51 changes: 3 additions & 48 deletions sdk/messaging/azwebpubsub/client_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type clientWrapper struct {
}

var fakeTestVars = testVars{
ConnectionString: "Endpoint=https://fake.eastus-1.webpubsub.azure.com;AccessKey=ABCDE;",
ConnectionString: "Endpoint=https://fake.webpubsub.azure.com;AccessKey=ABCDE;",
}

type testVars struct {
Expand Down Expand Up @@ -109,7 +109,7 @@ func loadClientOptions(t *testing.T) (testVars, *azcore.ClientOptions) {
}
} else {
options = &azcore.ClientOptions{
Transport: newRecordingTransporter(t, tv),
Transport: newRecordingTransporter(t),
}
}

Expand Down Expand Up @@ -141,61 +141,16 @@ func newClientWrapper(t *testing.T) clientWrapper {
}
}

func newRecordingTransporter(t *testing.T, testVars testVars) policy.Transporter {
func newRecordingTransporter(t *testing.T) policy.Transporter {
transport, err := recording.NewRecordingHTTPClient(t, nil)
require.NoError(t, err)

err = recording.Start(t, "sdk/messaging/azwebpubsub/testdata", nil)
require.NoError(t, err)
err = recording.AddURISanitizer("https://fake_endpoint.com/", testVars.Endpoint, nil)
require.NoError(t, err)

err = recording.AddGeneralRegexSanitizer(`"Date": "Wed, 15 Nov 2023 08:00:00 GMT"`, `"Date":".+?"`, nil)
require.NoError(t, err)

err = recording.AddGeneralRegexSanitizer(
`"id":"00000000-0000-0000-0000-000000000000"`,
`"id":"[^"]+"`, nil)
require.NoError(t, err)

err = recording.AddGeneralRegexSanitizer(
`"lockToken":"fake-lock-token"`,
`"lockToken":\s*"[^"]+"`, nil)
require.NoError(t, err)

err = recording.AddGeneralRegexSanitizer(
`"lockTokens": ["fake-lock-token"]`,
`"lockTokens":\s*\[\s*"[^"]+"\s*\]`, nil)
require.NoError(t, err)

err = recording.AddGeneralRegexSanitizer(
`"succeededLockTokens": ["fake-lock-token"]`,
`"succeededLockTokens":\s*\[\s*"[^"]+"\s*\]`, nil)
require.NoError(t, err)

err = recording.AddGeneralRegexSanitizer(
`"succeededLockTokens": ["fake-lock-token", "fake-lock-token", "fake-lock-token"]`,
`"succeededLockTokens":\s*`+
`\[`+
`(\s*"[^"]+"\s*\,){2}`+
`\s*"[^"]+"\s*`+
`\]`, nil)
require.NoError(t, err)

err = recording.AddGeneralRegexSanitizer(
`"lockTokens": ["fake-lock-token", "fake-lock-token"]`,
`"lockTokens":\s*\[\s*"[^"]+"\s*\,\s*"[^"]+"\s*\]`, nil)
require.NoError(t, err)

err = recording.AddGeneralRegexSanitizer(
`"lockTokens": ["fake-lock-token", "fake-lock-token", "fake-lock-token"]`,
`"lockTokens":\s*`+
`\[`+
`(\s*"[^"]+"\s*\,){2}`+
`\s*"[^"]+"\s*`+
`\]`, nil)
require.NoError(t, err)

t.Cleanup(func() {
err := recording.Stop(t, nil)
require.NoError(t, err)
Expand Down
10 changes: 0 additions & 10 deletions sdk/messaging/azwebpubsub/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ import (
"testing"

"github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming"
"github.com/Azure/azure-sdk-for-go/sdk/internal/recording"
"github.com/Azure/azure-sdk-for-go/sdk/messaging/azwebpubsub"
"github.com/golang-jwt/jwt"
"github.com/stretchr/testify/require"
)

func TestClient_SendToAll(t *testing.T) {
if recording.GetRecordMode() == recording.PlaybackMode {
t.Skip("https://github.com/Azure/azure-sdk-for-go/issues/22869")
}
client := newClientWrapper(t)
hub := "hub1"
_, err := client.SendToAll(context.Background(), hub,
Expand All @@ -44,9 +40,6 @@ func TestClient_SendToAll(t *testing.T) {
}

func TestClient_ManagePermissions(t *testing.T) {
if recording.GetRecordMode() == recording.PlaybackMode {
t.Skip("https://github.com/Azure/azure-sdk-for-go/issues/22869")
}
client := newClientWrapper(t)
const hub = "chat"
const conn1 = "conn1"
Expand All @@ -62,9 +55,6 @@ func TestClient_ManagePermissions(t *testing.T) {
}

func TestClient_CloseConnections(t *testing.T) {
if recording.GetRecordMode() == recording.PlaybackMode {
t.Skip("https://github.com/Azure/azure-sdk-for-go/issues/22869")
}
client := newClientWrapper(t)
const hub = "chat"
const conn1 = "conn1"
Expand Down

0 comments on commit c539d69

Please sign in to comment.