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

[Identity] Change base type of IdentityClientOptions to PipelineOptions #5711

Merged
merged 3 commits into from
Oct 23, 2019
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
4 changes: 2 additions & 2 deletions sdk/identity/identity/review/identity.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { AccessToken } from '@azure/core-http';
import { GetTokenOptions } from '@azure/core-http';
import { ServiceClientOptions } from '@azure/core-http';
import { PipelineOptions } from '@azure/core-http';
import { TokenCredential } from '@azure/core-http';

export { AccessToken }
Expand Down Expand Up @@ -101,7 +101,7 @@ export function getDefaultAzureCredential(): TokenCredential;
export { GetTokenOptions }

// @public
export interface IdentityClientOptions extends ServiceClientOptions {
export interface IdentityClientOptions extends PipelineOptions {
authorityHost?: string;
}

Expand Down
15 changes: 5 additions & 10 deletions sdk/identity/identity/src/client/identityClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ import qs from "qs";
import {
AccessToken,
ServiceClient,
ServiceClientOptions,
PipelineOptions,
WebResource,
RequestPrepareOptions,
GetTokenOptions,
tracingPolicy,
RequestPolicyFactory
createPipelineFromOptions
} from "@azure/core-http";
import { CanonicalCode } from "@azure/core-tracing";
import { AuthenticationError, AuthenticationErrorName } from "./errors";
import { createSpan } from "../util/tracing";
import { logger } from '../util/logging';


const DefaultAuthorityHost = "https://login.microsoftonline.com";

/**
Expand All @@ -41,7 +39,7 @@ export class IdentityClient extends ServiceClient {

constructor(options?: IdentityClientOptions) {
options = options || IdentityClient.getDefaultOptions();
super(undefined, options);
super(undefined, createPipelineFromOptions(options));

this.baseUri = this.authorityHost = options.authorityHost || DefaultAuthorityHost;

Expand Down Expand Up @@ -162,10 +160,7 @@ export class IdentityClient extends ServiceClient {

static getDefaultOptions(): IdentityClientOptions {
return {
authorityHost: DefaultAuthorityHost,
requestPolicyFactories: (factories: RequestPolicyFactory[]) => {
return [tracingPolicy(), ...factories];
}
authorityHost: DefaultAuthorityHost
};
}
}
Expand All @@ -174,7 +169,7 @@ export class IdentityClient extends ServiceClient {
* Provides options to configure how the Identity library makes authentication
* requests to Azure Active Directory.
*/
export interface IdentityClientOptions extends ServiceClientOptions {
export interface IdentityClientOptions extends PipelineOptions {
/**
* The authority host to use for authentication requests. The default is
* "https://login.microsoftonline.com".
Expand Down
4 changes: 3 additions & 1 deletion sdk/identity/identity/test/authTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export class MockAuthHttpClient implements HttpClient {
this.identityClientOptions = {
authorityHost: "https://authority",
httpClient: this,
noRetryPolicy: true
retryOptions: {
maxRetries: 0
}
};
}

Expand Down
1 change: 1 addition & 0 deletions sdk/identity/identity/test/identityClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe("IdentityClient", function () {
"secret",
mockHttp.identityClientOptions
);

await assertRejects(
credential.getToken("https://test/.default"),
isExpectedError("unknown_error")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe("AuthorizationCodeCredential", function() {

const rootSpan = tracer.startSpan("root");

const credential = new AuthorizationCodeCredential(
const credential = new AuthorizationCodeCredential(
"tenant",
"client",
"secret",
Expand Down Expand Up @@ -116,7 +116,12 @@ describe("AuthorizationCodeCredential", function() {
children: [
{
name: "Azure.Identity.AuthorizationCodeCredential-getToken",
children: []
children: [
{
children: [],
name: "core-http"
}
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ describe("ClientCertificateCredential", function() {
children: [
{
name: "Azure.Identity.ClientCertificateCredential-getToken",
children: []
children: [
{
children: [],
name: "core-http"
}
]
}
]
}
Expand Down
28 changes: 26 additions & 2 deletions sdk/identity/identity/test/node/deviceCodeCredential.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,35 @@ describe("DeviceCodeCredential", function() {
children: [
{
name: "Azure.Identity.DeviceCodeCredential-sendDeviceCodeRequest",
children: []
children: [
{
children: [],
name: "core-http"
}
]
},
{
name: "Azure.Identity.DeviceCodeCredential-pollForToken",
children: []
children: [
// We see 4 traces from core-http here because the client in
// this test polls 4 times for the authorization code.
{
children: [],
name: "core-http"
},
{
children: [],
name: "core-http"
},
{
children: [],
name: "core-http"
},
{
children: [],
name: "core-http"
}
daviwil marked this conversation as resolved.
Show resolved Hide resolved
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ describe("EnvironmentCredential", function() {
children: [
{
name: "Azure.Identity.ClientSecretCredential-getToken",
children: []
children: [
{
children: [],
name: "core-http"
}
]
}
]
}
Expand Down