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

Make pipeline protected #3934

Merged
merged 2 commits into from
Jun 19, 2019
Merged
Changes from 1 commit
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
Next Next commit
Make pipeline protected
jeremymeng committed Jun 18, 2019
commit 74b0a9365baf0bf3928b5239958ca8999d1a0d95
14 changes: 7 additions & 7 deletions sdk/storage/storage-blob/src/StorageClient.ts
Original file line number Diff line number Diff line change
@@ -13,21 +13,21 @@ import { escapeURLPath } from "./utils/utils.common";
*/
export abstract class StorageClient {
/**
* Request policy pipeline.
* Encoded URL string value.
*
* @internal
* @type {Pipeline}
* @type {string}
* @memberof StorageClient
*/
public readonly pipeline: Pipeline;
public readonly url: string;

/**
* Encoded URL string value.
* Request policy pipeline.
*
* @type {string}
* @internal
* @type {Pipeline}
* @memberof StorageClient
*/
public readonly url: string;
protected readonly pipeline: Pipeline;

/**
* StorageClient is a reference to protocol layer operations entry, which is
6 changes: 3 additions & 3 deletions sdk/storage/storage-blob/test/node/appendblobclient.spec.ts
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ describe("AppendBlobClient Node.js only", () => {
});

it("can be created with a url and a credential", async () => {
const factories = appendBlobClient.pipeline.factories;
const factories = (appendBlobClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const newClient = new AppendBlobClient(appendBlobClient.url, credential);

@@ -34,7 +34,7 @@ describe("AppendBlobClient Node.js only", () => {
});

it("can be created with a url and a credential and an option bag", async () => {
const factories = appendBlobClient.pipeline.factories;
const factories = (appendBlobClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const newClient = new AppendBlobClient(appendBlobClient.url, credential, {
telemetry: { value: "test/1.0" }
@@ -45,7 +45,7 @@ describe("AppendBlobClient Node.js only", () => {
});

it("can be created with a url and a pipeline", async () => {
const factories = appendBlobClient.pipeline.factories;
const factories = (appendBlobClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const pipeline = newPipeline(credential);
const newClient = new AppendBlobClient(appendBlobClient.url, pipeline);
6 changes: 3 additions & 3 deletions sdk/storage/storage-blob/test/node/blobclient.spec.ts
Original file line number Diff line number Diff line change
@@ -234,7 +234,7 @@ describe("BlobClient Node.js only", () => {
});

it("can be created with a url and a credential", async () => {
const factories = blobClient.pipeline.factories;
const factories = (blobClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const newClient = new BlobClient(blobClient.url, credential);

@@ -248,7 +248,7 @@ describe("BlobClient Node.js only", () => {
});

it("can be created with a url and a credential and an option bag", async () => {
const factories = blobClient.pipeline.factories;
const factories = (blobClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const newClient = new BlobClient(blobClient.url, credential, {
retryOptions: {
@@ -266,7 +266,7 @@ describe("BlobClient Node.js only", () => {
});

it("can be created with a url and a pipeline", async () => {
const factories = blobClient.pipeline.factories;
const factories = (blobClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const pipeline = newPipeline(credential);
const newClient = new BlobClient(blobClient.url, pipeline);
6 changes: 3 additions & 3 deletions sdk/storage/storage-blob/test/node/blobserviceclient.spec.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ dotenv.config({ path: "../.env" });
describe("BlobServiceClient Node.js only", () => {
it("can be created with a url and a credential", async () => {
const serviceClient = getBSU();
const factories = serviceClient.pipeline.factories;
const factories = (serviceClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const newClient = new BlobServiceClient(serviceClient.url, credential);

@@ -22,7 +22,7 @@ describe("BlobServiceClient Node.js only", () => {

it("can be created with a url and a credential and an option bag", async () => {
const serviceClient = getBSU();
const factories = serviceClient.pipeline.factories;
const factories = (serviceClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const newClient = new BlobServiceClient(serviceClient.url, credential, {
retryOptions: {
@@ -40,7 +40,7 @@ describe("BlobServiceClient Node.js only", () => {

it("can be created with a url and a pipeline", async () => {
const serviceClient = getBSU();
const factories = serviceClient.pipeline.factories;
const factories = (serviceClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const pipeline = newPipeline(credential);
const newClient = new BlobServiceClient(serviceClient.url, pipeline);
6 changes: 3 additions & 3 deletions sdk/storage/storage-blob/test/node/blockblobclient.spec.ts
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ describe("BlockBlobClient Node.js only", () => {
});

it("can be created with a url and a credential", async () => {
const factories = blockBlobClient.pipeline.factories;
const factories = (blockBlobClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const newClient = new BlockBlobClient(blockBlobClient.url, credential);

@@ -64,7 +64,7 @@ describe("BlockBlobClient Node.js only", () => {
});

it("can be created with a url and a credential and an option bag", async () => {
const factories = blockBlobClient.pipeline.factories;
const factories = (blockBlobClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const newClient = new BlockBlobClient(blockBlobClient.url, credential, {
retryOptions: {
@@ -79,7 +79,7 @@ describe("BlockBlobClient Node.js only", () => {
});

it("can be created with a url and a pipeline", async () => {
const factories = blockBlobClient.pipeline.factories;
const factories = (blockBlobClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const pipeline = newPipeline(credential);
const newClient = new BlockBlobClient(blockBlobClient.url, pipeline);
6 changes: 3 additions & 3 deletions sdk/storage/storage-blob/test/node/containerclient.spec.ts
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ describe("ContainerClient Node.js only", () => {
});

it("can be created with a url and a credential", async () => {
const factories = containerClient.pipeline.factories;
const factories = (containerClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const newClient = new ContainerClient(containerClient.url, credential);

@@ -66,7 +66,7 @@ describe("ContainerClient Node.js only", () => {
});

it("can be created with a url and a credential and an option bag", async () => {
const factories = containerClient.pipeline.factories;
const factories = (containerClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const newClient = new ContainerClient(containerClient.url, credential, {
retryOptions: {
@@ -88,7 +88,7 @@ describe("ContainerClient Node.js only", () => {
});

it("can be created with a url and a pipeline", async () => {
const factories = containerClient.pipeline.factories;
const factories = (containerClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const pipeline = newPipeline(credential);
const newClient = new ContainerClient(containerClient.url, pipeline);
6 changes: 3 additions & 3 deletions sdk/storage/storage-blob/test/node/pageblobclient.spec.ts
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ describe("PageBlobClient Node.js only", () => {
});

it("can be created with a url and a credential", async () => {
const factories = pageBlobClient.pipeline.factories;
const factories = (pageBlobClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const newClient = new PageBlobClient(pageBlobClient.url, credential);

@@ -109,7 +109,7 @@ describe("PageBlobClient Node.js only", () => {
});

it("can be created with a url and a credential and an option bag", async () => {
const factories = pageBlobClient.pipeline.factories;
const factories = (pageBlobClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const newClient = new PageBlobClient(pageBlobClient.url, credential, {
retryOptions: {
@@ -123,7 +123,7 @@ describe("PageBlobClient Node.js only", () => {
});

it("can be created with a url and a pipeline", async () => {
const factories = pageBlobClient.pipeline.factories;
const factories = (pageBlobClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as SharedKeyCredential;
const pipeline = newPipeline(credential);
const newClient = new PageBlobClient(pageBlobClient.url, pipeline);
33 changes: 12 additions & 21 deletions sdk/storage/storage-blob/test/node/sas.spec.ts
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import {
PageBlobClient,
BlobServiceClient,
SharedKeyCredential,
newPipeline,
newPipeline
} from "../../src";
import { SASProtocol } from "../../src/SASQueryParameters";
import { getBSU, getUniqueName } from "../utils";
@@ -29,7 +29,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
tmr.setDate(tmr.getDate() + 1);

// By default, credential is always the last element of pipeline factories
const factories = blobServiceClient.pipeline.factories;
const factories = (blobServiceClient as any).pipeline.factories;
const sharedKeyCredential = factories[factories.length - 1];

const sas = generateAccountSASQueryParameters(
@@ -60,7 +60,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
tmr.setDate(tmr.getDate() + 1);

// By default, credential is always the last element of pipeline factories
const factories = blobServiceClient.pipeline.factories;
const factories = (blobServiceClient as any).pipeline.factories;
const sharedKeyCredential = factories[factories.length - 1];

const sas = generateAccountSASQueryParameters(
@@ -94,7 +94,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
tmr.setDate(tmr.getDate() + 1);

// By default, credential is always the last element of pipeline factories
const factories = blobServiceClient.pipeline.factories;
const factories = (blobServiceClient as any).pipeline.factories;
const sharedKeyCredential = factories[factories.length - 1];

const sas = generateAccountSASQueryParameters(
@@ -128,7 +128,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
tmr.setDate(tmr.getDate() + 1);

// By default, credential is always the last element of pipeline factories
const factories = blobServiceClient.pipeline.factories;
const factories = (blobServiceClient as any).pipeline.factories;
const sharedKeyCredential = factories[factories.length - 1];

const sas = generateAccountSASQueryParameters(
@@ -168,7 +168,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
tmr.setDate(tmr.getDate() + 1);

// By default, credential is always the last element of pipeline factories
const factories = blobServiceClient.pipeline.factories;
const factories = (blobServiceClient as any).pipeline.factories;
const sharedKeyCredential = factories[factories.length - 1];

const containerName = getUniqueName("container");
@@ -206,7 +206,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
tmr.setDate(tmr.getDate() + 1);

// By default, credential is always the last element of pipeline factories
const factories = blobServiceClient.pipeline.factories;
const factories = (blobServiceClient as any).pipeline.factories;
const sharedKeyCredential = factories[factories.length - 1];

const containerName = getUniqueName("container");
@@ -241,10 +241,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
);

const sasClient = `${blobClient.url}?${blobSAS}`;
const blobClientwithSAS = new PageBlobClient(
sasClient,
newPipeline(new AnonymousCredential())
);
const blobClientwithSAS = new PageBlobClient(sasClient, newPipeline(new AnonymousCredential()));

const properties = await blobClientwithSAS.getProperties();
assert.equal(properties.cacheControl, "cache-control-override");
@@ -264,7 +261,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
tmr.setDate(tmr.getDate() + 1);

// By default, credential is always the last element of pipeline factories
const factories = blobServiceClient.pipeline.factories;
const factories = (blobServiceClient as any).pipeline.factories;
const sharedKeyCredential = factories[factories.length - 1];

const containerName = getUniqueName("container-with-dash");
@@ -302,10 +299,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
);

const sasClient = `${blobClient.url}?${blobSAS}`;
const blobClientwithSAS = new PageBlobClient(
sasClient,
newPipeline(new AnonymousCredential())
);
const blobClientwithSAS = new PageBlobClient(sasClient, newPipeline(new AnonymousCredential()));

const properties = await blobClientwithSAS.getProperties();
assert.equal(properties.cacheControl, "cache-control-override");
@@ -325,7 +319,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
tmr.setDate(tmr.getDate() + 1);

// By default, credential is always the last element of pipeline factories
const factories = blobServiceClient.pipeline.factories;
const factories = (blobServiceClient as any).pipeline.factories;
const sharedKeyCredential = factories[factories.length - 1];

const containerName = getUniqueName("container");
@@ -357,10 +351,7 @@ describe("Shared Access Signature (SAS) generation Node.js only", () => {
);

const sasClient = `${blobClient.url}?${blobSAS}`;
const blobClientwithSAS = new PageBlobClient(
sasClient,
newPipeline(new AnonymousCredential())
);
const blobClientwithSAS = new PageBlobClient(sasClient, newPipeline(new AnonymousCredential()));

await blobClientwithSAS.getProperties();
await containerClient.delete();
14 changes: 8 additions & 6 deletions sdk/storage/storage-blob/test/retrypolicy.spec.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { URLBuilder } from "@azure/ms-rest-js";
import * as assert from "assert";

import { ContainerClient, RestError } from "../src";
import { newPipeline, Pipeline } from "../src/Pipeline";
import { newPipeline, Pipeline } from "../src/Pipeline";
import { getBSU, getUniqueName } from "./utils";
import { InjectorPolicyFactory } from "./utils/InjectorPolicyFactory";
import * as dotenv from "dotenv";
@@ -31,7 +31,7 @@ describe("RetryPolicy", () => {
return new RestError("Server Internal Error", "ServerInternalError", 500);
}
});
const factories = containerClient.pipeline.factories.slice(); // clone factories array
const factories = (containerClient as any).pipeline.factories.slice(); // clone factories array
factories.push(injector);
const pipeline = new Pipeline(factories);
const injectContainerClient = new ContainerClient(containerClient.url, pipeline);
@@ -52,8 +52,9 @@ describe("RetryPolicy", () => {
return new RestError("Server Internal Error", "ServerInternalError", 500);
});

const credential =
containerClient.pipeline.factories[containerClient.pipeline.factories.length - 1];
const credential = (containerClient as any).pipeline.factories[
(containerClient as any).pipeline.factories.length - 1
];
const factories = newPipeline(credential, {
retryOptions: { maxTries: 3 }
}).factories;
@@ -92,8 +93,9 @@ describe("RetryPolicy", () => {
hostParts.unshift(secondaryAccount);
const secondaryHost = hostParts.join(".");

const credential =
containerClient.pipeline.factories[containerClient.pipeline.factories.length - 1];
const credential = (containerClient as any).pipeline.factories[
(containerClient as any).pipeline.factories.length - 1
];
const factories = newPipeline(credential, {
retryOptions: { maxTries: 2, secondaryHost }
}).factories;
Loading