Skip to content

Commit dbcecdd

Browse files
committed
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
2 parents c25f620 + 0ca7a49 commit dbcecdd

File tree

92 files changed

+58959
-10342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+58959
-10342
lines changed

build.proj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,11 @@
111111

112112
<PropertyGroup>
113113
<NuGetCommand>$(MSBuildProjectDirectory)\tools\NuGet.exe</NuGetCommand>
114+
<LibraryNugetPackageFolder>$(LibrarySourceFolder)\packages</LibraryNugetPackageFolder>
114115
<NuGetRestoreConfigFile>$(MSBuildProjectDirectory)\restore.config</NuGetRestoreConfigFile>
115116
<NuGetRestoreConfigSwitch>-ConfigFile &quot;$(NuGetRestoreConfigFile)&quot;</NuGetRestoreConfigSwitch>
117+
<NuGetRestorePackageSetting>-PackagesDirectory $(LibraryNugetPackageFolder)</NuGetRestorePackageSetting>
118+
116119
<PowerShellCommand>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</PowerShellCommand>
117120
</PropertyGroup>
118121

@@ -135,9 +138,9 @@
135138
Encoding="Unicode"/>
136139

137140
<Exec Command="$(NuGetCommand) sources add -Name LocalFeed -Source &quot;$(MSBuildProjectDirectory)\tools\LocalFeed&quot; $(NuGetRestoreConfigSwitch)"/>
138-
141+
<Exec Command="$(NuGetCommand) sources add -Name nugetRemote -Source &quot;https://api.nuget.org/v3/index.json&quot; $(NuGetRestoreConfigSwitch)"/>
139142
<!-- Restore packages -->
140-
<Exec Command="$(NuGetCommand) restore %(CmdletSolutionsToBuild.FullPath) $(NuGetRestoreConfigSwitch)"
143+
<Exec Command="$(NuGetCommand) restore %(CmdletSolutionsToBuild.FullPath) $(NuGetRestoreConfigSwitch) $(NuGetRestorePackageSetting)"
141144
ContinueOnError="false" />
142145
<!-- Restore packages for static analysis-->
143146
<Exec Command="$(NuGetCommand) restore %(StaticAnalysis.FullPath) $(NuGetRestoreConfigSwitch)"

src/ResourceManager/AzureBatch/Commands.Batch.Test/BatchTestHelpers.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ namespace Microsoft.Azure.Commands.Batch.Test
3737
/// </summary>
3838
public static class BatchTestHelpers
3939
{
40-
internal static readonly string TestCertificateFileName1 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources\\BatchTestCert01.cer");
41-
internal static readonly string TestCertificateFileName2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources\\BatchTestCert02.cer");
40+
internal static readonly string TestCertificateFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources\\BatchTestCert01.cer");
4241
internal const string TestCertificateAlgorithm = "sha1";
4342
internal const string TestCertificatePassword = "Passw0rd";
4443
internal static readonly int DefaultQuotaCount = 20;

src/ResourceManager/AzureBatch/Commands.Batch.Test/Certificates/NewBatchCertificateCommandTests.cs

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Microsoft.Azure.Batch;
1616
using Microsoft.Azure.Batch.Protocol;
17+
using Microsoft.Azure.Batch.Protocol.BatchRequests;
1718
using Microsoft.Azure.Batch.Protocol.Models;
1819
using Microsoft.Rest.Azure;
1920
using Microsoft.WindowsAzure.Commands.ScenarioTest;
@@ -22,6 +23,7 @@
2223
using System.Collections.Generic;
2324
using System.Management.Automation;
2425
using System.Security.Cryptography.X509Certificates;
26+
using System.Threading.Tasks;
2527
using Xunit;
2628
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
2729

@@ -47,15 +49,15 @@ public NewBatchCertificateCommandTests(Xunit.Abstractions.ITestOutputHelper outp
4749

4850
[Fact]
4951
[Trait(Category.AcceptanceType, Category.CheckIn)]
50-
public void NewBatchCertificateParametersTest()
52+
public void NewBatchCertificateRequiredParametersTest()
5153
{
5254
// Setup cmdlet without the required parameters
5355
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
5456
cmdlet.BatchContext = context;
5557

5658
Assert.Throws<ArgumentException>(() => cmdlet.ExecuteCmdlet());
5759

58-
cmdlet.FilePath = BatchTestHelpers.TestCertificateFileName1;
60+
cmdlet.FilePath = BatchTestHelpers.TestCertificateFileName;
5961

6062
// Don't go to the service on an Add Certificate call
6163
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
@@ -70,11 +72,80 @@ public void NewBatchCertificateParametersTest()
7072

7173
// Use the RawData parameter set next
7274
cmdlet.FilePath = null;
73-
X509Certificate2 cert = new X509Certificate2(BatchTestHelpers.TestCertificateFileName1);
75+
X509Certificate2 cert = new X509Certificate2(BatchTestHelpers.TestCertificateFileName);
7476
cmdlet.RawData = cert.RawData;
7577

7678
// Verify no exceptions when required parameters are set
7779
cmdlet.ExecuteCmdlet();
7880
}
81+
82+
[Fact]
83+
[Trait(Category.AcceptanceType, Category.CheckIn)]
84+
public void NewBatchCertificateRequestBodyTest()
85+
{
86+
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
87+
cmdlet.BatchContext = context;
88+
89+
X509Certificate2 cert = new X509Certificate2(BatchTestHelpers.TestCertificateFileName);
90+
string certDataBase64String = Convert.ToBase64String(cert.RawData);
91+
92+
CertificateAddParameter requestParameters = null;
93+
94+
// Don't go to the service on an Add Certificate call
95+
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
96+
{
97+
CertificateAddBatchRequest request = (CertificateAddBatchRequest)baseRequest;
98+
99+
request.ServiceRequestFunc = (cancellationToken) =>
100+
{
101+
requestParameters = request.Parameters;
102+
103+
var response = new AzureOperationHeaderResponse<CertificateAddHeaders>();
104+
Task<AzureOperationHeaderResponse<CertificateAddHeaders>> task = Task.FromResult(response);
105+
return task;
106+
};
107+
});
108+
109+
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
110+
111+
// Verify that when just the raw data is specified, the request body matches expectations
112+
cmdlet.RawData = cert.RawData;
113+
cmdlet.ExecuteCmdlet();
114+
Assert.Equal(CertificateFormat.Cer, requestParameters.CertificateFormat);
115+
Assert.Equal(BatchTestHelpers.TestCertificateAlgorithm, requestParameters.ThumbprintAlgorithm);
116+
Assert.Equal(cert.Thumbprint.ToLowerInvariant(), requestParameters.Thumbprint.ToLowerInvariant());
117+
Assert.True(string.IsNullOrEmpty(requestParameters.Password));
118+
Assert.Equal(certDataBase64String, requestParameters.Data);
119+
120+
// Verify that when the raw data is specified with a password, the request body matches expectations
121+
cmdlet.RawData = cert.RawData;
122+
cmdlet.Password = BatchTestHelpers.TestCertificatePassword;
123+
cmdlet.ExecuteCmdlet();
124+
Assert.Equal(CertificateFormat.Pfx, requestParameters.CertificateFormat);
125+
Assert.Equal(BatchTestHelpers.TestCertificateAlgorithm, requestParameters.ThumbprintAlgorithm);
126+
Assert.Equal(cert.Thumbprint.ToLowerInvariant(), requestParameters.Thumbprint.ToLowerInvariant());
127+
Assert.Equal(BatchTestHelpers.TestCertificatePassword, requestParameters.Password);
128+
Assert.Equal(certDataBase64String, requestParameters.Data);
129+
130+
// Verify that when just a file path is specified, the request body matches expectations
131+
cmdlet.RawData = null;
132+
cmdlet.Password = null;
133+
cmdlet.FilePath = BatchTestHelpers.TestCertificateFileName;
134+
cmdlet.ExecuteCmdlet();
135+
Assert.Equal(CertificateFormat.Cer, requestParameters.CertificateFormat);
136+
Assert.Equal(BatchTestHelpers.TestCertificateAlgorithm, requestParameters.ThumbprintAlgorithm);
137+
Assert.Equal(cert.Thumbprint.ToLowerInvariant(), requestParameters.Thumbprint.ToLowerInvariant());
138+
Assert.True(string.IsNullOrEmpty(requestParameters.Password));
139+
Assert.Equal(certDataBase64String, requestParameters.Data);
140+
141+
// Verify that when a file path is specified with a password, the request body matches expectations
142+
cmdlet.Password = BatchTestHelpers.TestCertificatePassword;
143+
cmdlet.ExecuteCmdlet();
144+
Assert.Equal(CertificateFormat.Pfx, requestParameters.CertificateFormat);
145+
Assert.Equal(BatchTestHelpers.TestCertificateAlgorithm, requestParameters.ThumbprintAlgorithm);
146+
Assert.Equal(cert.Thumbprint.ToLowerInvariant(), requestParameters.Thumbprint.ToLowerInvariant());
147+
Assert.Equal(BatchTestHelpers.TestCertificatePassword, requestParameters.Password);
148+
Assert.Equal(certDataBase64String, requestParameters.Data);
149+
}
79150
}
80151
}

src/ResourceManager/AzureBatch/Commands.Batch.Test/Commands.Batch.Test.csproj

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -284,18 +284,6 @@
284284
<None Include="Resources\BatchTestCert01.cer">
285285
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
286286
</None>
287-
<None Include="Resources\BatchTestCert02.cer">
288-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
289-
</None>
290-
<None Include="Resources\BatchTestCert03.cer">
291-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
292-
</None>
293-
<None Include="Resources\BatchTestCert04.pfx">
294-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
295-
</None>
296-
<None Include="Resources\BatchTestCert05.pfx">
297-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
298-
</None>
299287
<Content Include="Resources\TestApplicationPackage.zip">
300288
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
301289
</Content>
@@ -371,29 +359,11 @@
371359
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchApplicationTests\TestUploadApplicationPackage.json">
372360
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
373361
</None>
374-
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.CertificateTests\TestAddCertificate.json">
375-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
376-
</None>
377362
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.CertificateTests\TestCancelCertificateDelete.json">
378363
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
379364
</None>
380-
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.CertificateTests\TestDeleteCertificate.json">
381-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
382-
</None>
383-
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.CertificateTests\TestGetAndListCertificatesWithSelect.json">
384-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
385-
</None>
386-
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.CertificateTests\TestGetCertificateByThumbprint.json">
387-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
388-
</None>
389-
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.CertificateTests\TestListAllCertificates.json">
390-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
391-
</None>
392-
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.CertificateTests\TestListCertificatesByFilter.json">
393-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
394-
</None>
395-
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.CertificateTests\TestListCertificatesWithMaxCount.json">
396-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
365+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.CertificateTests\TestCertificateCrudOperations.json">
366+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
397367
</None>
398368
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.ComputeNodeTests\TestDisableAndEnableComputeNodeSchedulingById.json">
399369
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -695,9 +665,6 @@
695665
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.TaskTests\TestListAllTasks.json">
696666
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
697667
</None>
698-
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.TaskTests\TestListSubtasksWithMaxCount.json">
699-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
700-
</None>
701668
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.TaskTests\TestListTaskPipeline.json">
702669
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
703670
</None>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/BatchController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
using Microsoft.Azure.Management.Resources;
2020
using Microsoft.Azure.Test;
2121
using Microsoft.Azure.Test.HttpRecorder;
22+
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
2223
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2324
using System;
2425
using System.Collections.Generic;
2526
using System.IO;
2627
using System.Linq;
27-
using Microsoft.Azure.Commands.Common.Authentication;
28-
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
2928
using TestBase = Microsoft.Azure.Test.TestBase;
3029
using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory;
3130
using TestUtilities = Microsoft.Azure.Test.TestUtilities;

0 commit comments

Comments
 (0)