Skip to content

Commit

Permalink
[Test] downgrade test-credential to v1 for Service Bus tests (#30913)
Browse files Browse the repository at this point in the history
as it hasn't been migrated to vitest yet.
  • Loading branch information
jeremymeng authored Sep 10, 2024
1 parent 9ab1547 commit bc7574e
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 89 deletions.
4 changes: 3 additions & 1 deletion common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sdk/servicebus/service-bus/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.exports = function (config) {
"SERVICEBUS_CONNECTION_STRING_PREMIUM",
"SERVICEBUS_CONNECTION_STRING",
"SERVICEBUS_FQDN",
"TEST_MODE",
],

// test results reporter to use
Expand Down
10 changes: 5 additions & 5 deletions sdk/servicebus/service-bus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"execute:samples": "dev-tool samples run samples-dev",
"extract-api": "tsc -p . && dev-tool run extract-api",
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"samples/**/*.{ts,js}\" \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "karma start --single-run",
"integration-test:browser": "dev-tool run test:browser",
"integration-test:node": "dev-tool run test:node-js-input --no-test-proxy \"dist-esm/test/internal/**/*.spec.js\" \"dist-esm/test/public/**/*.spec.js\"",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint package.json api-extractor.json README.md src test --fix --fix-type [problem,suggestion]",
Expand Down Expand Up @@ -101,8 +101,8 @@
"@azure/abort-controller": "^2.1.2",
"@azure/core-amqp": "^4.2.2",
"@azure/core-auth": "^1.3.0",
"@azure/core-client": "^1.0.0",
"@azure/core-rest-pipeline": "^1.1.0",
"@azure/core-client": "^1.7.0",
"@azure/core-rest-pipeline": "^1.14.0",
"@azure/core-tracing": "^1.0.0",
"@azure/core-paging": "^1.4.0",
"@azure/core-util": "^1.1.1",
Expand All @@ -121,9 +121,9 @@
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/identity": "^4.2.1",
"@azure-tools/test-credential": "^2.0.0",
"@azure-tools/test-credential": "^1.0.0",
"@azure-tools/test-utils": "^1.0.1",
"@azure-tools/test-recorder": "^4.0.0",
"@azure-tools/test-recorder": "^3.0.0",
"@microsoft/api-extractor": "^7.31.1",
"@types/chai": "^4.1.6",
"@types/chai-as-promised": "^7.1.0",
Expand Down
167 changes: 84 additions & 83 deletions sdk/servicebus/service-bus/test/public/atomManagement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,90 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion) => {
{ serviceVersion: serviceVersion as "2021-05" | "2017-04" },
);
});

describe("Atom management - Authentication", function (): void {
if (isNode) {
it("Token credential - DefaultAzureCredential from `@azure/identity`", async () => {
const host = getFullyQualifiedNamespace();
const endpoint = `sb://${host}/`;
const serviceBusAdministrationClient = new ServiceBusAdministrationClient(
host,
new DefaultAzureCredential({
// Work around Msi credential issue in live test pipeline by failing
// its token retrieval
managedIdentityClientId: "fakeMsiClientId",
}),
);

should.equal(
(await serviceBusAdministrationClient.createQueue(managementQueue1)).name,
managementQueue1,
"Unexpected queue name in the createQueue response",
);
const createQueue2Response = await serviceBusAdministrationClient.createQueue(
managementQueue2,
{
forwardTo: managementQueue1,
},
);
should.equal(
createQueue2Response.name,
managementQueue2,
"Unexpected queue name in the createQueue response",
);
should.equal(
createQueue2Response.forwardTo,
endpoint + managementQueue1,
"Unexpected name in the `forwardTo` field of createQueue response",
);
const getQueueResponse = await serviceBusAdministrationClient.getQueue(managementQueue1);
should.equal(
getQueueResponse.name,
managementQueue1,
"Unexpected queue name in the getQueue response",
);
should.equal(
(await serviceBusAdministrationClient.updateQueue(getQueueResponse)).name,
managementQueue1,
"Unexpected queue name in the updateQueue response",
);
should.equal(
(await serviceBusAdministrationClient.getQueueRuntimeProperties(managementQueue1)).name,
managementQueue1,
"Unexpected queue name in the getQueueRuntimeProperties response",
);
should.equal(
(await serviceBusAdministrationClient.getNamespaceProperties()).name,
(host.match("(.*).servicebus.(windows.net|usgovcloudapi.net|chinacloudapi.cn)") ||
[])[1],
"Unexpected namespace name in the getNamespaceProperties response",
);
await serviceBusAdministrationClient.deleteQueue(managementQueue1);
await serviceBusAdministrationClient.deleteQueue(managementQueue2);
});
}

it("AzureNamedKeyCredential from `@azure/core-auth`", async () => {
const connectionStringProperties = parseServiceBusConnectionString(
env[EnvVarNames.SERVICEBUS_CONNECTION_STRING],
);
const host = connectionStringProperties.fullyQualifiedNamespace;
const serviceBusAdministrationClient = new ServiceBusAdministrationClient(
host,
new AzureNamedKeyCredential(
connectionStringProperties.sharedAccessKeyName!,
connectionStringProperties.sharedAccessKey!,
),
);

should.equal(
(await serviceBusAdministrationClient.getNamespaceProperties()).name,
(host.match("(.*).servicebus.(windows.net|usgovcloudapi.net|chinacloudapi.cn)") || [])[1],
"Unexpected namespace name in the getNamespaceProperties response",
);
});
});

/**
* These tests are just a sanity check that our updates are actually
* _doing_ something. We've run into some bugs where we've done things like
Expand Down Expand Up @@ -352,89 +436,6 @@ versionsToTest(serviceApiVersions, {}, (serviceVersion) => {
});
});

describe("Atom management - Authentication", function (): void {
if (isNode) {
it("Token credential - DefaultAzureCredential from `@azure/identity`", async () => {
const host = getFullyQualifiedNamespace();
const endpoint = `sb://${host}/`;
const serviceBusAdministrationClient = new ServiceBusAdministrationClient(
host,
new DefaultAzureCredential({
// Work around Msi credential issue in live test pipeline by failing
// its token retrieval
managedIdentityClientId: "fakeMsiClientId",
}),
);

should.equal(
(await serviceBusAdministrationClient.createQueue(managementQueue1)).name,
managementQueue1,
"Unexpected queue name in the createQueue response",
);
const createQueue2Response = await serviceBusAdministrationClient.createQueue(
managementQueue2,
{
forwardTo: managementQueue1,
},
);
should.equal(
createQueue2Response.name,
managementQueue2,
"Unexpected queue name in the createQueue response",
);
should.equal(
createQueue2Response.forwardTo,
endpoint + managementQueue1,
"Unexpected name in the `forwardTo` field of createQueue response",
);
const getQueueResponse = await serviceBusAdministrationClient.getQueue(managementQueue1);
should.equal(
getQueueResponse.name,
managementQueue1,
"Unexpected queue name in the getQueue response",
);
should.equal(
(await serviceBusAdministrationClient.updateQueue(getQueueResponse)).name,
managementQueue1,
"Unexpected queue name in the updateQueue response",
);
should.equal(
(await serviceBusAdministrationClient.getQueueRuntimeProperties(managementQueue1)).name,
managementQueue1,
"Unexpected queue name in the getQueueRuntimeProperties response",
);
should.equal(
(await serviceBusAdministrationClient.getNamespaceProperties()).name,
(host.match("(.*).servicebus.(windows.net|usgovcloudapi.net|chinacloudapi.cn)") ||
[])[1],
"Unexpected namespace name in the getNamespaceProperties response",
);
await serviceBusAdministrationClient.deleteQueue(managementQueue1);
await serviceBusAdministrationClient.deleteQueue(managementQueue2);
});
}

it("AzureNamedKeyCredential from `@azure/core-auth`", async () => {
const connectionStringProperties = parseServiceBusConnectionString(
env[EnvVarNames.SERVICEBUS_CONNECTION_STRING],
);
const host = connectionStringProperties.fullyQualifiedNamespace;
const serviceBusAdministrationClient = new ServiceBusAdministrationClient(
host,
new AzureNamedKeyCredential(
connectionStringProperties.sharedAccessKeyName!,
connectionStringProperties.sharedAccessKey!,
),
);

should.equal(
(await serviceBusAdministrationClient.getNamespaceProperties()).name,
(host.match("(.*).servicebus.(windows.net|usgovcloudapi.net|chinacloudapi.cn)") || [])[1],
"Unexpected namespace name in the getNamespaceProperties response",
);
});
});

[EntityType.QUEUE, EntityType.TOPIC, EntityType.SUBSCRIPTION, EntityType.RULE].forEach(
(entityType) => {
describe(`Atom management - List on "${entityType}" entities`, function (): void {
Expand Down

0 comments on commit bc7574e

Please sign in to comment.