diff --git a/src/ResourceManager/AzureBatch/Commands.Batch.Test/BatchTestHelpers.cs b/src/ResourceManager/AzureBatch/Commands.Batch.Test/BatchTestHelpers.cs
index ae97b2d4de8d..8fe09b5e06ff 100644
--- a/src/ResourceManager/AzureBatch/Commands.Batch.Test/BatchTestHelpers.cs
+++ b/src/ResourceManager/AzureBatch/Commands.Batch.Test/BatchTestHelpers.cs
@@ -31,6 +31,11 @@ namespace Microsoft.Azure.Commands.Batch.Test
///
public static class BatchTestHelpers
{
+ internal const string TestCertificateFileName1 = "Resources\\BatchTestCert01.cer";
+ internal const string TestCertificateFileName2 = "Resources\\BatchTestCert02.cer";
+ internal const string TestCertificateAlgorithm = "sha1";
+ internal const string TestCertificatePassword = "Passw0rd";
+
///
/// Builds an AccountResource object using the specified parameters
///
@@ -168,6 +173,44 @@ public static RequestInterceptor CreateFakGetFileAndPropertiesResponseIntercepto
return interceptor;
}
+ ///
+ /// Builds a CertificateGetResponse object
+ ///
+ public static ProxyModels.CertificateGetResponse CreateCertificateGetResponse(string thumbprint)
+ {
+ ProxyModels.CertificateGetResponse response = new ProxyModels.CertificateGetResponse();
+ response.StatusCode = HttpStatusCode.OK;
+
+ ProxyModels.Certificate cert = new ProxyModels.Certificate();
+ cert.Thumbprint = thumbprint;
+
+ response.Certificate = cert;
+
+ return response;
+ }
+
+ ///
+ /// Builds a CertificateListResponse object
+ ///
+ public static ProxyModels.CertificateListResponse CreateCertificateListResponse(IEnumerable certThumbprints)
+ {
+ ProxyModels.CertificateListResponse response = new ProxyModels.CertificateListResponse();
+ response.StatusCode = HttpStatusCode.OK;
+
+ List certs = new List();
+
+ foreach (string t in certThumbprints)
+ {
+ ProxyModels.Certificate cert = new ProxyModels.Certificate();
+ cert.Thumbprint = t;
+ certs.Add(cert);
+ }
+
+ response.Certificates = certs;
+
+ return response;
+ }
+
///
/// Builds a CloudPoolGetResponse object
///
diff --git a/src/ResourceManager/AzureBatch/Commands.Batch.Test/Certificates/GetBatchCertificateCommandTests.cs b/src/ResourceManager/AzureBatch/Commands.Batch.Test/Certificates/GetBatchCertificateCommandTests.cs
new file mode 100644
index 000000000000..8c6e7c1f564e
--- /dev/null
+++ b/src/ResourceManager/AzureBatch/Commands.Batch.Test/Certificates/GetBatchCertificateCommandTests.cs
@@ -0,0 +1,215 @@
+// ----------------------------------------------------------------------------------
+//
+// 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.Batch;
+using Microsoft.Azure.Batch.Protocol;
+using Microsoft.Azure.Batch.Protocol.Models;
+using Microsoft.Azure.Commands.Batch.Models;
+using Microsoft.WindowsAzure.Commands.ScenarioTest;
+using Moq;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Management.Automation;
+using System.Threading.Tasks;
+using Xunit;
+using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
+
+namespace Microsoft.Azure.Commands.Batch.Test.Certificates
+{
+ public class GetBatchCertificateCommandTests : WindowsAzure.Commands.Test.Utilities.Common.RMTestBase
+ {
+ private GetBatchCertificateCommand cmdlet;
+ private Mock batchClientMock;
+ private Mock commandRuntimeMock;
+
+ public GetBatchCertificateCommandTests()
+ {
+ batchClientMock = new Mock();
+ commandRuntimeMock = new Mock();
+ cmdlet = new GetBatchCertificateCommand()
+ {
+ CommandRuntime = commandRuntimeMock.Object,
+ BatchClient = batchClientMock.Object,
+ };
+ }
+
+ [Fact]
+ [Trait(Category.AcceptanceType, Category.CheckIn)]
+ public void GetBatchCertificateTest()
+ {
+ // Setup cmdlet to get a cert by its thumbprint
+ BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
+ cmdlet.BatchContext = context;
+ cmdlet.ThumbprintAlgorithm = "sha1";
+ cmdlet.Thumbprint = "123456789";
+ cmdlet.Filter = null;
+
+ // Build a Certificate instead of querying the service on a Get Certificate call
+ CertificateGetResponse response = BatchTestHelpers.CreateCertificateGetResponse(cmdlet.Thumbprint);
+ RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor(response);
+ cmdlet.AdditionalBehaviors = new List() { interceptor };
+
+ // Setup the cmdlet to write pipeline output to a list that can be examined later
+ List pipeline = new List();
+ commandRuntimeMock.Setup(r => r.WriteObject(It.IsAny())).Callback