Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Batch] Fix missing SharedKeyCredentials export #19736

Merged
merged 3 commits into from
Jan 10, 2022
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
6 changes: 4 additions & 2 deletions sdk/batch/batch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@azure/batch",
"author": "Microsoft Corporation",
"description": "BatchServiceClient Library with typescript type definitions for node.js and browser.",
"version": "10.0.2",
"version": "10.0.3",
"dependencies": {
"@azure/ms-rest-azure-js": "^2.1.0",
"@azure/ms-rest-js": "^2.2.0",
Expand All @@ -19,15 +19,17 @@
],
"license": "MIT",
"main": "./dist/batch.js",
"module": "./esm/batchServiceClient.js",
"module": "./dist-esm/index.js",
"types": "./types/src/index.d.ts",
"devDependencies": {
"@rollup/plugin-commonjs": "^11.0.2",
"@types/chai": "^4.2.21",
"@types/chai-as-promised": "^7.1.4",
"@types/mocha": "^9.0.0",
"@types/node": "^16.4.7",
"@types/url-parse": "^1.4.3",
"@types/uuid": "^8.3.1",
"buffer": "^6.0.0",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"cross-env": "^7.0.3",
Expand Down
12 changes: 10 additions & 2 deletions sdk/batch/batch/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import nodeResolve from "rollup-plugin-node-resolve";
import cjs from "@rollup/plugin-commonjs";
import sourcemaps from "rollup-plugin-sourcemaps";

/**
* @type {rollup.RollupFileOptions}
*/
const config = {
input: "./dist-esm/src/batchServiceClient.js",
input: "./dist-esm/src/index.js",
external: ["@azure/ms-rest-js", "@azure/ms-rest-azure-js"],
output: {
file: "./dist/batch.js",
Expand All @@ -24,7 +25,14 @@ const config = {
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/`
},
plugins: [nodeResolve({ mainFields: ["module", "main"] }), sourcemaps()]
plugins: [
nodeResolve({
mainFields: ["module", "main"],
preferBuiltins: false
}),
sourcemaps(),
cjs()
]
};

export default config;
2 changes: 1 addition & 1 deletion sdk/batch/batch/src/batchServiceClientContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as msRest from "@azure/ms-rest-js";
import * as msRestAzure from "@azure/ms-rest-azure-js";

const packageName = "@azure/batch";
const packageVersion = "10.0.2";
const packageVersion = "10.0.3";

export class BatchServiceClientContext extends msRestAzure.AzureServiceClient {
credentials: msRest.ServiceClientCredentials;
Expand Down
97 changes: 48 additions & 49 deletions sdk/batch/batch/test/batchClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { duration } from "moment";
import { AccountListPoolNodeCountsResponse, TaskGetResponse } from "../src/models";
import { assert } from "chai";
import { BatchServiceClient, BatchServiceModels } from "../src/batchServiceClient";
import { TokenCredentials } from "@azure/ms-rest-js";
import moment from "moment";
import { createClient } from "./utils/recordedClient";

Expand Down Expand Up @@ -41,7 +40,7 @@ function getPoolName(type: string) {

describe("Batch Service", () => {
let client: BatchServiceClient;
let batchEndpoint: string;
// let batchEndpoint: string;
// let clientId: string;
// let secret: string;
let certThumb: string;
Expand All @@ -62,7 +61,7 @@ describe("Batch Service", () => {
};

beforeEach(async () => {
batchEndpoint = process.env["AZURE_BATCH_ENDPOINT"]!;
// batchEndpoint = process.env["AZURE_BATCH_ENDPOINT"]!;

// dummy thumb
certThumb = "cff2ab63c8c955aaf71989efa641b906558d9fb7";
Expand Down Expand Up @@ -215,41 +214,41 @@ describe("Batch Service", () => {
assert.equal(result._response.status, 200);
});

it.skip("should perform AAD authentication successfully", (done) => {
const verifyAadAuth = function(token: string, callback: any) {
const tokenCreds = new TokenCredentials(token, "Bearer");
const aadClient = new BatchServiceClient(tokenCreds, batchEndpoint);
aadClient.account.listSupportedImages(function(err, result, request, response) {
assert.isNull(err);
assert.isDefined(result);
assert.isAtLeast(result!.length, 1);
assert.equal(response!.status, 200);
assert.isDefined(request!.headers.get("authorization"));
assert.equal(request!.headers.get("authorization"), "Bearer " + token);
callback();
});
};

// if (!suite.isPlayback) {
// const authContext = new AuthenticationContext(
// "https://login.microsoftonline.com/microsoft.onmicrosoft.com"
// );

// authContext.acquireTokenWithClientCredentials(
// "https://batch.core.windows.net/",
// clientId,
// secret,
// function(err: any, tokenResponse: TokenResponse) {
// assert.isNull(err);
// assert.isDefined(tokenResponse);
// assert.isDefined((tokenResponse as TokenResponse).accessToken);
// verifyAadAuth((tokenResponse as TokenResponse).accessToken, done);
// }
// );
// } else {
verifyAadAuth("dummy token", done);
// }
});
// it("should perform AAD authentication successfully", (done) => {
// const verifyAadAuth = function(token: string, callback: any) {
// const tokenCreds = new TokenCredentials(token, "Bearer");
// const aadClient = new BatchServiceClient(tokenCreds, batchEndpoint);
// aadClient.account.listSupportedImages(function(err, result, request, response) {
// assert.isNull(err);
// assert.isDefined(result);
// assert.isAtLeast(result!.length, 1);
// assert.equal(response!.status, 200);
// assert.isDefined(request!.headers.get("authorization"));
// assert.equal(request!.headers.get("authorization"), "Bearer " + token);
// callback();
// });
// };

// // if (!suite.isPlayback) {
// // const authContext = new AuthenticationContext(
// // "https://login.microsoftonline.com/microsoft.onmicrosoft.com"
// // );

// // authContext.acquireTokenWithClientCredentials(
// // "https://batch.core.windows.net/",
// // clientId,
// // secret,
// // function(err: any, tokenResponse: TokenResponse) {
// // assert.isNull(err);
// // assert.isDefined(tokenResponse);
// // assert.isDefined((tokenResponse as TokenResponse).accessToken);
// // verifyAadAuth((tokenResponse as TokenResponse).accessToken, done);
// // }
// // );
// // } else {
// verifyAadAuth("dummy token", done);
// // }
// });

it("should add a pool with vnet and get expected error", async () => {
const pool: BatchServiceModels.PoolAddParameter = {
Expand Down Expand Up @@ -1025,19 +1024,19 @@ describe("Batch Service", () => {
});
});

describe("Applications", async () => {
// the application is not added by the tests and should be added by the tester manually
it.skip("should list applications successfully", async () => {
const result = await client.application.list();
// describe("Applications", async () => {
// // the application is not added by the tests and should be added by the tester manually
// it("should list applications successfully", async () => {
// const result = await client.application.list();

assert.isAtLeast(result.length, 1);
assert.equal(result._response.status, 200);
});
// assert.isAtLeast(result.length, 1);
// assert.equal(result._response.status, 200);
// });

it.skip("should get application reference successfully", async () => {
await client.application.get("my_application_id");
});
});
// it("should get application reference successfully", async () => {
// await client.application.get("my_application_id");
// });
// });

describe("Task cleanup", async () => {
it("should delete a task successfully", async () => {
Expand Down