Skip to content

Commit

Permalink
Rename RawTokenCredential to SimpleTokenCredential
Browse files Browse the repository at this point in the history
  • Loading branch information
daviwil committed Jul 25, 2019
1 parent f8f1304 commit ee97655
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions sdk/core/core-arm/test/azureServiceClientTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

import assert from "assert";
import { HttpHeaders, HttpOperationResponse, RequestOptionsBase, RestError, RawTokenCredential, WebResource, OperationArguments, OperationSpec, Serializer } from "@azure/core-http";
import { HttpHeaders, HttpOperationResponse, RequestOptionsBase, RestError, SimpleTokenCredential, WebResource, OperationArguments, OperationSpec, Serializer } from "@azure/core-http";
import { AzureServiceClient, AzureServiceClientOptions, updateOptionsWithDefaultValues } from "../lib/azureServiceClient";
import * as msAssert from "./msAssert";
import { LROPoller } from "../lib/lroPoller";
Expand All @@ -11,25 +11,25 @@ import { CloudErrorMapper } from "../lib/cloudError";
describe("AzureServiceClient", () => {
describe("constructor", () => {
it("with no options provided", () => {
const client = new AzureServiceClient(new RawTokenCredential("my-fake-token"));
const client = new AzureServiceClient(new SimpleTokenCredential("my-fake-token"));
assert.strictEqual(client.acceptLanguage, "en-us");
assert.strictEqual(client.longRunningOperationRetryTimeout, undefined);
});

it("with acceptLanguage provided", () => {
const client = new AzureServiceClient(new RawTokenCredential("my-fake-token"), { acceptLanguage: "my-fake-language" });
const client = new AzureServiceClient(new SimpleTokenCredential("my-fake-token"), { acceptLanguage: "my-fake-language" });
assert.strictEqual(client.acceptLanguage, "my-fake-language");
assert.strictEqual(client.longRunningOperationRetryTimeout, undefined);
});

it("with longRunningOperationRetryTimeout provided", () => {
const client = new AzureServiceClient(new RawTokenCredential("my-fake-token"), { longRunningOperationRetryTimeout: 2 });
const client = new AzureServiceClient(new SimpleTokenCredential("my-fake-token"), { longRunningOperationRetryTimeout: 2 });
assert.strictEqual(client.acceptLanguage, "en-us");
assert.strictEqual(client.longRunningOperationRetryTimeout, 2);
});

it("should apply the resourceManagerEndpointUrl from credentials", async function() {
const creds = new RawTokenCredential("my-fake-token");
const creds = new SimpleTokenCredential("my-fake-token");
(creds as any).environment = { resourceManagerEndpointUrl: "foo" };

const client = new AzureServiceClient(creds);
Expand Down Expand Up @@ -2585,7 +2585,7 @@ function createServiceClient(responses: HttpResponse[]): AzureServiceClient {
}

function createServiceClientWithOptions(options: AzureServiceClientOptions, responses: HttpResponse[]): AzureServiceClient {
return new AzureServiceClient(new RawTokenCredential("my-fake-token"), Object.assign({
return new AzureServiceClient(new SimpleTokenCredential("my-fake-token"), Object.assign({
httpClient: {
sendRequest(httpRequest: WebResource): Promise<HttpOperationResponse> {
const response: HttpResponse | undefined = responses.shift();
Expand Down
12 changes: 6 additions & 6 deletions sdk/core/core-arm/test/lroPollStrategyTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

import assert from "assert";
import { HttpHeaders, HttpOperationResponse, RawTokenCredential, WebResource } from "@azure/core-http";
import { HttpHeaders, HttpOperationResponse, SimpleTokenCredential, WebResource } from "@azure/core-http";
import { AzureServiceClient } from "../lib/azureServiceClient";
import { getDelayInSeconds, isFinished } from "../lib/lroPollStrategy";

describe("LROPollStrategy", function () {
describe("getDelayInMilliseconds()", function () {
it("with no AzureServiceClient.longRunningOperationRetryTimeout value and no retry-after header", function () {
const azureServiceClient = new AzureServiceClient(new RawTokenCredential("my-fake-token"));
const azureServiceClient = new AzureServiceClient(new SimpleTokenCredential("my-fake-token"));
const previousResponse: HttpOperationResponse = {
request: new WebResource(),
status: 200,
Expand All @@ -19,7 +19,7 @@ describe("LROPollStrategy", function () {
});

it("with 11 AzureServiceClient.longRunningOperationRetryTimeout and no retry-after header", function () {
const azureServiceClient = new AzureServiceClient(new RawTokenCredential("my-fake-token"), { longRunningOperationRetryTimeout: 11 });
const azureServiceClient = new AzureServiceClient(new SimpleTokenCredential("my-fake-token"), { longRunningOperationRetryTimeout: 11 });
const previousResponse: HttpOperationResponse = {
request: new WebResource(),
status: 200,
Expand All @@ -29,7 +29,7 @@ describe("LROPollStrategy", function () {
});

it("with no AzureServiceClient.longRunningOperationRetryTimeout value and 12 retry-after header", function () {
const azureServiceClient = new AzureServiceClient(new RawTokenCredential("my-fake-token"));
const azureServiceClient = new AzureServiceClient(new SimpleTokenCredential("my-fake-token"));
const previousResponse: HttpOperationResponse = {
request: new WebResource(),
status: 200,
Expand All @@ -39,7 +39,7 @@ describe("LROPollStrategy", function () {
});

it("with no AzureServiceClient.longRunningOperationRetryTimeout value and spam retry-after header", function () {
const azureServiceClient = new AzureServiceClient(new RawTokenCredential("my-fake-token"));
const azureServiceClient = new AzureServiceClient(new SimpleTokenCredential("my-fake-token"));
const previousResponse: HttpOperationResponse = {
request: new WebResource(),
status: 200,
Expand All @@ -49,7 +49,7 @@ describe("LROPollStrategy", function () {
});

it("with 11 AzureServiceClient.longRunningOperationRetryTimeout and 12 retry-after header", function () {
const azureServiceClient = new AzureServiceClient(new RawTokenCredential("my-fake-token"), { longRunningOperationRetryTimeout: 11 });
const azureServiceClient = new AzureServiceClient(new SimpleTokenCredential("my-fake-token"), { longRunningOperationRetryTimeout: 11 });
const previousResponse: HttpOperationResponse = {
request: new WebResource(),
status: 200,
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-auth/review/core-auth.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface GetTokenOptions {
export function isTokenCredential(credential: any): credential is TokenCredential;

// @public
export class RawTokenCredential implements TokenCredential {
export class SimpleTokenCredential implements TokenCredential {
constructor(token: string, expiresOn?: Date);
expiresOn: Date;
getToken(_scopes: string | string[], _options?: GetTokenOptions): Promise<AccessToken | null>;
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export {
isTokenCredential
} from "./tokenCredential";

export { RawTokenCredential } from "./rawTokenCredential";
export { SimpleTokenCredential } from "./simpleTokenCredential";
export { AbortSignalLike } from '@azure/abort-controller';
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TokenCredential, GetTokenOptions, AccessToken } from "./tokenCredential
* used when the access token is already known or can be retrieved from an
* outside source.
*/
export class RawTokenCredential implements TokenCredential {
export class SimpleTokenCredential implements TokenCredential {
/**
* The raw token string. Can be changed when the token needs to be updated.
*/
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-http/lib/coreHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export {
export { URLBuilder, URLQuery } from "./url";

// Credentials
export { TokenCredential, GetTokenOptions, AccessToken, isTokenCredential, RawTokenCredential } from "@azure/core-auth";
export { TokenCredential, GetTokenOptions, AccessToken, isTokenCredential, SimpleTokenCredential } from "@azure/core-auth";
export { AccessTokenCache, ExpiringAccessTokenCache } from "./credentials/accessTokenCache";
export { BasicAuthenticationCredentials } from "./credentials/basicAuthenticationCredentials";
export { ApiKeyCredentials, ApiKeyCredentialOptions } from "./credentials/apiKeyCredentials";
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-http/samples/node-sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"] || "subscriptionId";
// 1.5 in the curl tab you will see the actual curl request that has the bearer token in it
// 1.6 copy paste that token here. That token is valid for 1 hour
const token = process.env["ACCESS_TOKEN"] || "token";
const creds = new coreHttp.RawTokenCredential(token);
const creds = new coreHttp.SimpleTokenCredential(token);
const client = new coreHttp.ServiceClient(creds, clientOptions);
const req: coreHttp.RequestPrepareOptions = {
url: `https://management.azure.com/subscriptions/${subscriptionId}/providers/Microsoft.Storage/storageAccounts?api-version=2015-06-15`,
Expand Down

0 comments on commit ee97655

Please sign in to comment.