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
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions sdk/storage/storage-blob/src/StorageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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
Expand Up @@ -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);

Expand All @@ -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" }
Expand All @@ -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);
Expand Down
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
Expand Up @@ -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);

Expand All @@ -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: {
Expand All @@ -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);
Expand Down
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
Expand Up @@ -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);

Expand All @@ -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: {
Expand All @@ -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);
Expand Down
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
Expand Up @@ -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);

Expand All @@ -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: {
Expand All @@ -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);
Expand Down
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
Expand Up @@ -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);

Expand All @@ -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: {
Expand All @@ -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);
Expand Down
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
Expand Up @@ -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);

Expand All @@ -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: {
Expand All @@ -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);
Expand Down
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
Expand Up @@ -13,7 +13,7 @@ import {
PageBlobClient,
BlobServiceClient,
SharedKeyCredential,
newPipeline,
newPipeline
} from "../../src";
import { SASProtocol } from "../../src/SASQueryParameters";
import { getBSU, getUniqueName } from "../utils";
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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();
Expand Down
14 changes: 8 additions & 6 deletions sdk/storage/storage-blob/test/retrypolicy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading