Skip to content
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
1 change: 1 addition & 0 deletions sdk/identity/Azure.Identity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Restoring Application Authentication APIs from 1.2.0-preview.6
- Added `IncludeX5CClaimHeader` to `ClientCertificateCredentialOptions` to enable subject name / issuer authentication with the `ClientCertificateCredential`.
- Added `RedirectUri` to `InteractiveBrowserCredentialOptions` to enable authentication with user specified application with a custom redirect url.
- Added `IdentityModelFactory` to enable constructing models from the Azure.Identity library for mocking.

### Fixes and improvements
- Fixed issue with non GUID Client Ids (Issue [#14585](https://github.com/Azure/azure-sdk-for-net/issues/14585))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ public EnvironmentCredential(Azure.Identity.TokenCredentialOptions options) { }
public override Azure.Core.AccessToken GetToken(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public override System.Threading.Tasks.ValueTask<Azure.Core.AccessToken> GetTokenAsync(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public static partial class IdentityModelFactory
{
public static Azure.Identity.AuthenticationRecord AuthenticationRecord(string username, string authority, string homeAccountId, string tenantId, string clientId) { throw null; }
public static Azure.Identity.DeviceCodeInfo DeviceCodeInfo(string userCode, string deviceCode, System.Uri verificationUri, System.DateTimeOffset expiresOn, string message, string clientId, System.Collections.Generic.IReadOnlyCollection<string> scopes) { throw null; }
}
public partial class InteractiveBrowserCredential : Azure.Core.TokenCredential
{
public InteractiveBrowserCredential() { }
Expand Down
20 changes: 12 additions & 8 deletions sdk/identity/Azure.Identity/src/DeviceCodeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.Identity.Client;
using System;
using System.Collections.Generic;
using System.Text;

namespace Azure.Identity
{
Expand All @@ -14,14 +13,19 @@ namespace Azure.Identity
public struct DeviceCodeInfo
{
internal DeviceCodeInfo(DeviceCodeResult deviceCode)
: this(deviceCode.UserCode, deviceCode.DeviceCode, new Uri(deviceCode.VerificationUrl), deviceCode.ExpiresOn, deviceCode.Message, deviceCode.ClientId, deviceCode.Scopes)
{
UserCode = deviceCode.UserCode;
DeviceCode = deviceCode.DeviceCode;
VerificationUri = new Uri(deviceCode.VerificationUrl);
ExpiresOn = deviceCode.ExpiresOn;
Message = deviceCode.Message;
ClientId = deviceCode.ClientId;
Scopes = deviceCode.Scopes;
}

internal DeviceCodeInfo(string userCode, string deviceCode, Uri verificationUri, DateTimeOffset expiresOn, string message, string clientId, IReadOnlyCollection<string> scopes)
{
UserCode = userCode;
DeviceCode = deviceCode;
VerificationUri = verificationUri;
ExpiresOn = expiresOn;
Message = message;
ClientId = clientId;
Scopes = scopes;
}

/// <summary>
Expand Down
41 changes: 41 additions & 0 deletions sdk/identity/Azure.Identity/src/IdentityModelFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;

namespace Azure.Identity
{

/// <summary>
/// Model factory that enables mocking for the Azure Identity library.
/// </summary>
public static class IdentityModelFactory
{
/// <summary>
/// Initializes a new instance of the <see cref="AuthenticationRecord"/> class for mocking purposes.
/// </summary>
/// <param name="username">Sets the <see cref="AuthenticationRecord.Username"/>.</param>
/// <param name="authority">Sets the <see cref="AuthenticationRecord.Authority"/>.</param>
/// <param name="homeAccountId">Sets the <see cref="AuthenticationRecord.HomeAccountId"/>.</param>
/// <param name="tenantId">Sets the <see cref="AuthenticationRecord.TenantId"/>.</param>
/// <param name="clientId">Sets the <see cref="AuthenticationRecord.ClientId"/>.</param>
/// <returns>A new instance of the <see cref="AuthenticationRecord"/> for mocking purposes.</returns>
public static AuthenticationRecord AuthenticationRecord(string username, string authority, string homeAccountId, string tenantId, string clientId)
=> new AuthenticationRecord(username, authority, homeAccountId, tenantId, clientId);

/// <summary>
/// Initializes a new instance of the <see cref="DeviceCodeInfo"/> class for mocking purposes.
/// </summary>
/// <param name="userCode">Sets the <see cref="DeviceCodeInfo.UserCode"/>.</param>
/// <param name="deviceCode">Sets the <see cref="DeviceCodeInfo.DeviceCode"/>.</param>
/// <param name="verificationUri">Sets the <see cref="DeviceCodeInfo.VerificationUri"/>.</param>
/// <param name="expiresOn">Sets the <see cref="DeviceCodeInfo.ExpiresOn"/>.</param>
/// <param name="message">Sets the <see cref="DeviceCodeInfo.Message"/>.</param>
/// <param name="clientId">Sets the <see cref="DeviceCodeInfo.ClientId"/>.</param>
/// <param name="scopes">Sets the <see cref="DeviceCodeInfo.Scopes"/>.</param>
/// <returns>A new instance of the <see cref="DeviceCodeInfo"/> for mocking purposes.</returns>
public static DeviceCodeInfo DeviceCodeInfo(string userCode, string deviceCode, Uri verificationUri, DateTimeOffset expiresOn, string message, string clientId, IReadOnlyCollection<string> scopes)
=> new DeviceCodeInfo(userCode, deviceCode, verificationUri, expiresOn, message, clientId, scopes);
}
}