Skip to content

Commit bf76871

Browse files
committed
Admin Export Template Image: Add Ops, TA Cmdlet and security check for exporting template image out of ARA part 3
1 parent 1820abc commit bf76871

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Test/Common/TemplateObjects.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,18 @@ public static bool ContainsExpectedResult(List<TemplateImageResult> expectedResu
343343
return isIdentical;
344344
}
345345

346-
public static void SetUpDefaultRemoteAppExportTemplateImage(Mock<IRemoteAppManagementClient> clientMock, string sourceCollectionName, string DestinationStorageAccountName, string DestinationStorageAccountKey, string DestinationStorageAccountContainerName)
346+
public static void SetUpDefaultRemoteAppExportTemplateImage(Mock<IRemoteAppManagementClient> clientMock, string sourceCollectionName, string DestinationStorageAccountName, string DestinationStorageAccountKey, string DestinationStorageAccountContainerName, string trackingId)
347347
{
348348
OperationResultWithTrackingId response = new OperationResultWithTrackingId()
349349
{
350-
RequestId = "12345",
351-
StatusCode = System.Net.HttpStatusCode.Accepted
350+
StatusCode = System.Net.HttpStatusCode.Accepted,
351+
TrackingId = trackingId,
352+
RequestId = "02111-222-3456"
353+
};
354+
355+
mockTrackingId = new List<TrackingResult>()
356+
{
357+
new TrackingResult(response)
352358
};
353359

354360
ISetup<IRemoteAppManagementClient, Task<OperationResultWithTrackingId>> setup =

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Test/Common/UserDiskObjects.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,18 @@ public static void SetUpDefaultRemoteAppCopyUserDisk(Mock<IRemoteAppManagementCl
5151
setup.Returns(Task.Factory.StartNew(() => response));
5252
}
5353

54-
public static void SetUpDefaultRemoteAppExportUserDisk(Mock<IRemoteAppManagementClient> clientMock, string sourceCollectionName, string DestinationStorageAccountName, string DestinationStorageAccountKey, string DestinationStorageAccountContainerName)
54+
public static void SetUpDefaultRemoteAppExportUserDisk(Mock<IRemoteAppManagementClient> clientMock, string sourceCollectionName, string DestinationStorageAccountName, string DestinationStorageAccountKey, string DestinationStorageAccountContainerName, string trackingId)
5555
{
5656
OperationResultWithTrackingId response = new OperationResultWithTrackingId()
5757
{
58-
RequestId = "12345",
59-
StatusCode = System.Net.HttpStatusCode.Accepted
58+
StatusCode = System.Net.HttpStatusCode.Accepted,
59+
TrackingId = trackingId,
60+
RequestId = "02111-222-3456"
61+
};
62+
63+
mockTrackingId = new List<TrackingResult>()
64+
{
65+
new TrackingResult(response)
6066
};
6167

6268
ISetup<IRemoteAppManagementClient, Task<OperationResultWithTrackingId>> setup =

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Test/Templates/RemoteAppTemplates.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public void ExportTemplateImage()
202202
mockCmdlet.DestinationStorageAccountContainerName = containerName;
203203

204204
// Setup the environment for testing this cmdlet
205-
MockObject.SetUpDefaultRemoteAppExportTemplateImage(remoteAppManagementClientMock, mockCmdlet.CollectionName, mockCmdlet.DestinationStorageAccountName, mockCmdlet.DestinationStorageAccountKey, mockCmdlet.DestinationStorageAccountContainerName);
205+
MockObject.SetUpDefaultRemoteAppExportTemplateImage(remoteAppManagementClientMock, mockCmdlet.CollectionName, mockCmdlet.DestinationStorageAccountName, mockCmdlet.DestinationStorageAccountKey, mockCmdlet.DestinationStorageAccountContainerName, trackingId);
206206
mockCmdlet.ResetPipelines();
207207

208208
Log("Calling Export-AzureRemoteAppTemplateImage");
@@ -220,10 +220,6 @@ public void ExportTemplateImage()
220220
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
221221
Assert.NotNull(trackingIds);
222222

223-
Assert.True(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
224-
"The actual result does not match the expected."
225-
);
226-
227223
Log("The test for Export-AzureRemoteAppTemplateImage completed successfully");
228224
}
229225
}

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Test/UserDisk/RemoteAppUserDisk.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void ExportUserDisk()
9595
mockCmdlet.DestinationStorageAccountKey = storageAccountKey;
9696
mockCmdlet.DestinationStorageAccountContainerName = containerName;
9797

98-
MockObject.SetUpDefaultRemoteAppExportUserDisk(remoteAppManagementClientMock, mockCmdlet.CollectionName, mockCmdlet.DestinationStorageAccountName, mockCmdlet.DestinationStorageAccountKey, mockCmdlet.DestinationStorageAccountContainerName);
98+
MockObject.SetUpDefaultRemoteAppExportUserDisk(remoteAppManagementClientMock, mockCmdlet.CollectionName, mockCmdlet.DestinationStorageAccountName, mockCmdlet.DestinationStorageAccountKey, mockCmdlet.DestinationStorageAccountContainerName, trackingId);
9999
mockCmdlet.ResetPipelines();
100100

101101
Log("Calling Export-AzureRemoteAppUserDisk");
@@ -113,10 +113,6 @@ public void ExportUserDisk()
113113
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
114114
Assert.NotNull(trackingIds);
115115

116-
Assert.True(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
117-
"The actual result does not match the expected."
118-
);
119-
120116
Log("The test for Export-AzureRemoteAppUserDisk completed successfully");
121117
}
122118
}

0 commit comments

Comments
 (0)