Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into nori/migrate-resources
Browse files Browse the repository at this point in the history
  • Loading branch information
NoriZC committed Mar 14, 2024
2 parents 8f96734 + a6c112f commit c5bc3b5
Show file tree
Hide file tree
Showing 1,235 changed files with 236,079 additions and 77,705 deletions.
6 changes: 4 additions & 2 deletions .azure-pipelines/code-sign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ jobs:
displayName: 'Install PowerShellGet [v2.1.3 has a Publish-Module bug]'

- task: DotNetCoreCLI@2
displayName: Build
displayName: Build For Target Module
condition: ne('${{ parameters.TargetModule }}', 'none')
inputs:
command: custom
custom: msbuild
arguments: 'build.proj /t:"Build;CopyAboutTopics;GenerateHelp" /p:"Configuration=Release;GenerateDocumentationFile=true;TargetModule=${{ parameters.TargetModule }}"'
- task: DotNetCoreCLI@2
displayName: Build
displayName: Build For Modified Modules
condition: eq('${{ parameters.TargetModule }}', 'none')
inputs:
command: custom
Expand Down Expand Up @@ -366,6 +366,8 @@ jobs:
./tools/Docs/OutputTypeIndex.ps1 -OutputFile ./artifacts/outputtypes.json -BuildConfig Release
./tools/Docs/HelpIndex.ps1 -OutputFile ./artifacts/index.json -BuildConfig Release
displayName: 'Post process for Docs'
condition: eq('${{ parameters.TargetModule }}', 'none')
- task: PublishBuildArtifacts@1
displayName: 'Save artifacts'
Expand Down
25 changes: 23 additions & 2 deletions .github/policies/resourceManagement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,8 @@ configuration:
then:
- mentionUsers:
mentionees:
- alec-baird,costinhagiu
- alec-baird
- costinhagiu
replyTemplate: Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}.
assignMentionees: False
- if:
Expand Down Expand Up @@ -1984,6 +1985,24 @@ configuration:
- omzevall
replyTemplate: Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}.
assignMentionees: False
- if:
- or:
- labelAdded:
label: Service Attention
- labelAdded:
label: ImageBuilder
- hasLabel:
label: Service Attention
- hasLabel:
label: ImageBuilder
then:
- mentionUsers:
mentionees:
- adana-popescu
- KalpeshChavan12
- ralucaminea
replyTemplate: Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}.
assignMentionees: False
- if:
- or:
- labelAdded:
Expand Down Expand Up @@ -2229,7 +2248,9 @@ configuration:
then:
- mentionUsers:
mentionees:
- adana-popescu,KalpeshChavan12,ralucaminea
- adana-popescu
- KalpeshChavan12
- ralucaminea
replyTemplate: Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}.
assignMentionees: False
- if:
Expand Down
81 changes: 37 additions & 44 deletions build.proj

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion documentation/azure-powershell-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
| Content Delivery Network | `Az.Cdn` | [![Cdn]][CdnGallery] | [Changelog][CdnChangeLog] |
| Change Analysis | `Az.ChangeAnalysis` | [![ChangeAnalysis]][ChangeAnalysisGallery] | [Changelog][ChangeAnalysisChangeLog] |
| Cloud Service | `Az.CloudService` | [![CloudService]][CloudServiceGallery] | [Changelog][CloudServiceChangeLog] |
| CodeSigning | `Az.CodeSigning` | [![CodeSigning]][CodeSigningGallery] | [Changelog][CodeSigningChangeLog] |
| Cognitive Services | `Az.CognitiveServices` | [![CognitiveServices]][CognitiveServicesGallery] | [Changelog][CognitiveServicesChangeLog] |
| Communication | `Az.Communication` | [![Communication]][CommunicationGallery] | [Changelog][CommunicationChangeLog] |
| Compute | `Az.Compute` | [![Compute]][ComputeGallery] | [Changelog][ComputeChangeLog] |
Expand Down Expand Up @@ -78,7 +79,8 @@
| ElasticSan on Azure | `Az.ElasticSan` | [![ElasticSan]][ElasticSanGallery] | [Changelog][ElasticSanChangeLog] |
| Event Grid | `Az.EventGrid` | [![EventGrid]][EventGridGallery] | [Changelog][EventGridChangeLog] |
| Event Hubs | `Az.EventHub` | [![EventHub]][EventHubGallery] | [Changelog][EventHubChangeLog] |
| Fleet | `Az.Fleet` | [![Fleet]][FleetGallery] | [Changelog][FleetChangeLog] |
| FirmwareAnalysis | `FirmwareAnalysis` | [![FirmwareAnalysis]][FirmwareAnalysisGallery] | [Changelog][FirmwareAnalysisChangeLog] |
| Fleet | `Az.Fleet` | [![Fleet]][FleetGallery] | [Changelog][FleetChangeLog] |
| Fluid Relay | `Az.FluidRelay` | [![FluidRelay]][FluidRelayGallery] | [Changelog][FluidRelayChangeLog] |
| Front Door | `Az.FrontDoor` | [![FrontDoor]][FrontDoorGallery] | [Changelog][FrontDoorChangeLog] |
| Functions | `Az.Functions` | [![Functions]][FunctionsGallery] | [Changelog][FunctionsChangeLog] |
Expand Down Expand Up @@ -210,6 +212,7 @@
[Cdn]: https://img.shields.io/powershellgallery/v/Az.Cdn.svg?style=flat-square&label=Az.Cdn
[ChangeAnalysis]: https://img.shields.io/powershellgallery/v/Az.ChangeAnalysis.svg?style=flat-square&label=Az.ChangeAnalysis
[CloudService]: https://img.shields.io/powershellgallery/v/Az.CloudService.svg?style=flat-square&label=Az.CloudService
[CodeSigning]: https://img.shields.io/powershellgallery/v/Az.CodeSigning.svg?style=flat-square&label=Az.CodeSigning
[CognitiveServices]: https://img.shields.io/powershellgallery/v/Az.CognitiveServices.svg?style=flat-square&label=Az.CognitiveServices
[Communication]: https://img.shields.io/powershellgallery/v/Az.Communication.svg?style=flat-square&label=Az.Communication
[Compute]: https://img.shields.io/powershellgallery/v/Az.Compute.svg?style=flat-square&label=Az.Compute
Expand Down Expand Up @@ -253,6 +256,7 @@
[ElasticSan]: https://img.shields.io/powershellgallery/v/Az.ElasticSan.svg?style=flat-square&label=Az.ElasticSan
[EventGrid]: https://img.shields.io/powershellgallery/v/Az.EventGrid.svg?style=flat-square&label=Az.EventGrid
[EventHub]: https://img.shields.io/powershellgallery/v/Az.EventHub.svg?style=flat-square&label=Az.EventHub
[FirmwareAnalysis]: https://img.shields.io/powershellgallery/v/Az.FirmwareAnalysis.svg?style=flat-square&label=Az.FirmwareAnalysis
[Fleet]: https://img.shields.io/powershellgallery/v/Az.Fleet.svg?style=flat-square&label=Az.Fleet
[FluidRelay]: https://img.shields.io/powershellgallery/v/Az.FluidRelay.svg?style=flat-square&label=Az.FluidRelay
[FrontDoor]: https://img.shields.io/powershellgallery/v/Az.FrontDoor.svg?style=flat-square&label=Az.FrontDoor
Expand Down Expand Up @@ -381,6 +385,7 @@
[CdnGallery]: https://www.powershellgallery.com/packages/Az.Cdn/
[ChangeAnalysisGallery]: https://www.powershellgallery.com/packages/Az.ChangeAnalysis/
[CloudServiceGallery]: https://www.powershellgallery.com/packages/Az.CloudService/
[CodeSigningGallery]: https://www.powershellgallery.com/packages/Az.CodeSigning/
[CognitiveServicesGallery]: https://www.powershellgallery.com/packages/Az.CognitiveServices/
[CommunicationGallery]: https://www.powershellgallery.com/packages/Az.Communication/
[ComputeGallery]: https://www.powershellgallery.com/packages/Az.Compute/
Expand Down Expand Up @@ -424,6 +429,7 @@
[ElasticSanGallery]: https://www.powershellgallery.com/packages/Az.ElasticSan/
[EventGridGallery]: https://www.powershellgallery.com/packages/Az.EventGrid/
[EventHubGallery]: https://www.powershellgallery.com/packages/Az.EventHub/
[FirmwareAnalysisGallery]: https://www.powershellgallery.com/packages/Az.FirmwareAnalysis/
[FleetGallery]: https://www.powershellgallery.com/packages/Az.Fleet/
[FluidRelayGallery]: https://www.powershellgallery.com/packages/Az.FluidRelay/
[FrontDoorGallery]: https://www.powershellgallery.com/packages/Az.FrontDoor/
Expand Down Expand Up @@ -550,6 +556,7 @@
[CdnChangeLog]: ../src/Cdn/Cdn/ChangeLog.md
[ChangeAnalysisChangeLog]: ../src/ChangeAnalysis/ChangeAnalysis/ChangeLog.md
[CloudServiceChangeLog]: ../src/CloudService/CloudService/ChangeLog.md
[CodeSigningChangeLog]: ../src/CodeSigning/CodeSigning/ChangeLog.md
[CognitiveServicesChangeLog]: ../src/CognitiveServices/CognitiveServices/ChangeLog.md
[CommunicationChangeLog]: ../src/Communication/Communication/ChangeLog.md
[ComputeChangeLog]: ../src/Compute/Compute/ChangeLog.md
Expand Down Expand Up @@ -593,6 +600,7 @@
[ElasticSanChangeLog]: ../src/ElasticSan/ElasticSan/ChangeLog.md
[EventGridChangeLog]: ../src/EventGrid/EventGrid/ChangeLog.md
[EventHubChangeLog]: ../src/EventHub/EventHub/ChangeLog.md
[FirmwareAnalysisChangeLog]: ../src/FirmwareAnalysis/FirmwareAnalysis/ChangeLog.md
[FleetChangeLog]: ../src/Fleet/Fleet/ChangeLog.md
[FluidRelayChangeLog]: ../src/FluidRelay/FluidRelay/ChangeLog.md
[FrontDoorChangeLog]: ../src/FrontDoor/FrontDoor/ChangeLog.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,25 @@ You must provide expected breaking change az version and moudle verision otherwi
## Case 1 — Generic Breaking change for a cmdlet
```csharp
[Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.GenericBreakingChangeWithVersionAttribute("16.0.0", "4.0.0", "2022/05/30")
[Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.GenericBreakingChangeAttribute("message about the change", "16.0.0", "4.0.0", "2022/05/30")
```

## Case 2 — Breaking change for a cmdlet

```csharp
[Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.CmdletDeprecationWithVersionAttribute("16.0.0", "4.0.0", "2022/05/30", ReplacementCmdletName = 'replace-xxx')
[Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.CmdletBreakingChangeAttribute("16.0.0", "4.0.0", "2022/05/30", ReplacementCmdletName = 'replace-xxx')
```

## Case 3 — Breaking change for an output type

```csharp
[Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.CmdletOutputBreakingChangeWithVersionAttribute("oldtype", "11.0.0", "5.0.0", "2022/05/11", ReplacementCmdletOutputType = "newtype", DeprecatedOutputProperties = ("propertyA", "PropertyB"), NewOutputProperties = ("PropertyC", "PropertyD"))]
[Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.OutputBreakingChangeAttribute("oldtype", "11.0.0", "5.0.0", "2022/05/11", ReplacementCmdletOutputType = "newtype", DeprecatedOutputProperties = ("propertyA", "PropertyB"), NewOutputProperties = ("PropertyC", "PropertyD"))]
```

## Case 4 — Breaking change for a parameter

```csharp
[Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.CmdletParameterBreakingChangeWithVersionAttribute("ResourceGroupName", "11.0.0", "4.1.0", "2028/06/18")]
[Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.ParameterBreakingChangeAttribute("ResourceGroupName", "11.0.0", "4.1.0", "2028/06/18")]
```

## Case 5 — Preview message
Expand Down
178 changes: 178 additions & 0 deletions src/Accounts/Accounts.Test/AccessTokenCmdletTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.Commands.Profile;
using Microsoft.Azure.Commands.Profile.Models;
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.Azure.Commands.TestFx.Mocks;
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.Common;
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

using Moq;

using System;
using System.Linq;
using System.Security;

using Xunit;
using Xunit.Abstractions;

namespace Microsoft.Azure.Commands.ResourceManager.Common.Test
{
public class AccessTokenCmdletTests
{
private GetAzureRmAccessTokenCommand cmdlet;
private Mock<IAuthenticationFactory> factoryMock = new Mock<IAuthenticationFactory>();
private MockCommandRuntime mockedCommandRuntime;
private IAuthenticationFactory previousFactory = null;

private string tenantId = Guid.NewGuid().ToString();

public AccessTokenCmdletTests(ITestOutputHelper output)
{
TestExecutionHelpers.SetUpSessionAndProfile();
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));

var defaultContext = new AzureContext(
new AzureSubscription()
{
Id = Guid.NewGuid().ToString(),
Name = "Test subscription"
},
new AzureAccount()
{
Id = "admin@contoso.com",
Type = AzureAccount.AccountType.User
},
AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud],
new AzureTenant()
{
Id = tenantId
});

mockedCommandRuntime = new MockCommandRuntime();
cmdlet = new GetAzureRmAccessTokenCommand()
{
CommandRuntime = mockedCommandRuntime,
DefaultProfile = new AzureRmProfile()
};
cmdlet.DefaultProfile.DefaultContext = defaultContext;
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetAccessTokenAsPlainText()
{
// Setup
cmdlet.TenantId = tenantId;
var fakeToken = "eyfaketoken.eyfaketoken";

var expected = new PSAccessToken {
UserId = "faker@contoso.com",
TenantId = cmdlet.TenantId,
Token = fakeToken
};

factoryMock.Setup(t => t.Authenticate(
It.IsAny<IAzureAccount>(),
It.IsAny<IAzureEnvironment>(),
It.IsAny<string>(),
It.IsAny<SecureString>(),
It.IsAny<string>(),
It.IsAny<Action<string>>(),
It.IsAny<IAzureTokenCache>(),
It.IsAny<string>())).Returns(new MockAccessToken
{
UserId = expected.UserId,
LoginType = LoginType.OrgId,
AccessToken = expected.Token,
TenantId = expected.TenantId
});
previousFactory = AzureSession.Instance.AuthenticationFactory;
AzureSession.Instance.AuthenticationFactory = factoryMock.Object;

// Act
cmdlet.InvokeBeginProcessing();
cmdlet.ExecuteCmdlet();
cmdlet.InvokeEndProcessing();

//Verify
Assert.Single(mockedCommandRuntime.OutputPipeline);
var outputPipeline = mockedCommandRuntime.OutputPipeline;
Assert.Equal(expected.TenantId, ((PSAccessToken)outputPipeline.First()).TenantId);
Assert.Equal(expected.UserId, ((PSAccessToken)outputPipeline.First()).UserId);
Assert.Equal("Bearer", ((PSAccessToken)outputPipeline.First()).Type);
Assert.Equal(expected.Token, ((PSAccessToken)outputPipeline.First()).Token);

AzureSession.Instance.AuthenticationFactory = previousFactory;
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetAccessTokenAsSecureString()
{
// Setup
cmdlet.TenantId = tenantId;
cmdlet.AsSecureString = true;
var fakeToken = "eyfaketoken.eyfaketoken";

var expected = new PSSecureAccessToken();
expected.UserId = "faker@contoso.com";
expected.TenantId = cmdlet.TenantId;
expected.Token = fakeToken.ConvertToSecureString();


factoryMock.Setup(t => t.Authenticate(
It.IsAny<IAzureAccount>(),
It.IsAny<IAzureEnvironment>(),
It.IsAny<string>(),
It.IsAny<SecureString>(),
It.IsAny<string>(),
It.IsAny<Action<string>>(),
It.IsAny<IAzureTokenCache>(),
It.IsAny<string>())).Returns(new MockAccessToken
{
UserId = expected.UserId,
LoginType = LoginType.OrgId,
AccessToken = fakeToken,
TenantId = expected.TenantId
});
previousFactory = AzureSession.Instance.AuthenticationFactory;
AzureSession.Instance.AuthenticationFactory = factoryMock.Object;

// Act
cmdlet.InvokeBeginProcessing();
cmdlet.ExecuteCmdlet();
cmdlet.InvokeEndProcessing();

//Verify
Assert.Single(mockedCommandRuntime.OutputPipeline);
var outputPipeline = mockedCommandRuntime.OutputPipeline;
Assert.Equal(expected.TenantId, ((PSSecureAccessToken)outputPipeline.First()).TenantId);
Assert.Equal(expected.UserId, ((PSSecureAccessToken)outputPipeline.First()).UserId);
Assert.Equal("Bearer", ((PSSecureAccessToken)outputPipeline.First()).Type);
var expectedToken = expected.Token.ConvertToString();
var actualToken = ((PSSecureAccessToken)outputPipeline.First()).Token.ConvertToString();
Assert.Equal(expectedToken, actualToken);

AzureSession.Instance.AuthenticationFactory = previousFactory;
}
}
}
2 changes: 2 additions & 0 deletions src/Accounts/Accounts/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
-->

## Upcoming Release
* Added `AsSecureString` to `Get-AzAccessToken` to convert the returned token to SecureString [#24190].
* Upgraded Azure.Core to 1.37.0.

## Version 2.16.0
* Added a preview feature to detect secrets and sensitive information from the output of Azure PowerShell cmdlets to prevent leakage. Enable it by `Set-AzConfig -DisplaySecretsWarning $true`. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844
Expand Down
Loading

0 comments on commit c5bc3b5

Please sign in to comment.