Skip to content

Commit 57d8200

Browse files
author
Hovsep
committed
Merge pull request Azure#2245 from arcadiahlyy/dev
[UVHD Tenant Admin] Add admin cmdlet to delete and copy UVHD
2 parents 204b6f3 + 5fc8a1a commit 57d8200

File tree

16 files changed

+618
-11
lines changed

16 files changed

+618
-11
lines changed

src/ServiceManagement/RemoteApp/Commands.RemoteApp.ScenarioTest/Commands.RemoteAppScenarioTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
8484
</Reference>
8585
<Reference Include="Microsoft.WindowsAzure.Management.RemoteApp, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
86-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.RemoteApp.2.0.4\lib\net40\Microsoft.WindowsAzure.Management.RemoteApp.dll</HintPath>
86+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.RemoteApp.2.0.6\lib\net40\Microsoft.WindowsAzure.Management.RemoteApp.dll</HintPath>
8787
</Reference>
8888
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
8989
<HintPath>..\..\..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Test/Collection/RemoteAppCollection.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace Microsoft.WindowsAzure.Commands.RemoteApp.Test
3232
using Xunit;
3333

3434
// Get-AzureRemoteAppCollectionUsageDetails, Get-AzureRemoteAppCollectionUsageSummary,
35+
3536
public class RemoteAppCollectionTest : RemoteAppClientTest
3637
{
3738

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Test/Commands.RemoteApp.Test.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<ItemGroup>
4343
<Compile Include="Collection\RemoteAppCollection.cs" />
4444
<Compile Include="Common\MockAdHelper.cs" />
45+
<Compile Include="Common\UserDiskObjects.cs" />
4546
<Compile Include="Common\VmObjects.cs" />
4647
<Compile Include="Common\CollectionObjects.cs" />
4748
<Compile Include="Common\MockObject.cs" />
@@ -56,6 +57,7 @@
5657
<Compile Include="RemoteProgram\RemoteAppProgram.cs" />
5758
<Compile Include="SecurityPrincipals\RemoteAppSecurityPrincipals.cs" />
5859
<Compile Include="Templates\RemoteAppTemplates.cs" />
60+
<Compile Include="UserDisk\RemoteAppUserDisk.cs" />
5961
<Compile Include="Vm\RemoteAppVm.cs" />
6062
<Compile Include="VNet\RemoteAppVNet.cs" />
6163
<Compile Include="Workspace\RemoteAppWorkspace.cs" />
@@ -147,7 +149,7 @@
147149
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
148150
</Reference>
149151
<Reference Include="Microsoft.WindowsAzure.Management.RemoteApp, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
150-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.RemoteApp.2.0.4\lib\net40\Microsoft.WindowsAzure.Management.RemoteApp.dll</HintPath>
152+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.RemoteApp.2.0.6\lib\net40\Microsoft.WindowsAzure.Management.RemoteApp.dll</HintPath>
151153
</Reference>
152154
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
153155
<HintPath>..\..\..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
@@ -171,8 +173,10 @@
171173
<HintPath>..\..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll</HintPath>
172174
</Reference>
173175
<Reference Include="System.Net.Http.WebRequest" />
174-
<Reference Include="System.Xml" /> <Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
175-
<HintPath>..\..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath> <Private>True</Private>
176+
<Reference Include="System.Xml" />
177+
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
178+
<HintPath>..\..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
179+
<Private>True</Private>
176180
</Reference>
177181
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
178182
<HintPath>..\..\..\packages\xunit.assert.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.assert.dll</HintPath>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public abstract class RemoteAppClientTest : SMTestBase
4444

4545
protected const string collectionName = "test1";
4646

47+
protected const string secondaryCollectionName = "test2";
48+
49+
protected const bool OverwriteExistingUserDisk = false;
50+
4751
protected const string vmName = "testVm";
4852

4953
protected const string loggedInUserUpn = "[email protected]";
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.WindowsAzure.Commands.RemoteApp.Test.Common
16+
{
17+
using Microsoft.WindowsAzure.Management.RemoteApp;
18+
using Microsoft.Azure;
19+
using Moq;
20+
using Moq.Language.Flow;
21+
using System.Collections.Generic;
22+
using System.Threading;
23+
using System.Threading.Tasks;
24+
25+
public partial class MockObject
26+
{
27+
public static void SetUpDefaultRemoteAppRemoveUserDisk(Mock<IRemoteAppManagementClient> clientMock, string collectionName, string userUpn)
28+
{
29+
AzureOperationResponse response = new AzureOperationResponse()
30+
{
31+
RequestId = "12345",
32+
StatusCode = System.Net.HttpStatusCode.Accepted
33+
};
34+
35+
ISetup<IRemoteAppManagementClient, Task<AzureOperationResponse>> setup =
36+
clientMock.Setup(c => c.UserDisks.DeleteAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()));
37+
setup.Returns(Task.Factory.StartNew(() => response));
38+
}
39+
40+
public static void SetUpDefaultRemoteAppCopyUserDisk(Mock<IRemoteAppManagementClient> clientMock, string sourceCollectionName, string destinationCollectionName, string userUpn, bool overwriteExistingUserDisk)
41+
{
42+
AzureOperationResponse response = new AzureOperationResponse()
43+
{
44+
RequestId = "12345",
45+
StatusCode = System.Net.HttpStatusCode.Accepted
46+
};
47+
48+
ISetup<IRemoteAppManagementClient, Task<AzureOperationResponse>> setup =
49+
clientMock.Setup(c => c.UserDisks.CopyAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<CancellationToken>()));
50+
setup.Returns(Task.Factory.StartNew(() => response));
51+
}
52+
}
53+
}

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Test/OperationResult/RemoteAppOperationResult.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ namespace Microsoft.WindowsAzure.Commands.RemoteApp.Test
2323
using System.Management.Automation;
2424
using Xunit;
2525

26-
2726
public class RemoteAppOperationResult : RemoteAppClientTest
2827
{
2928

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Test/RemoteProgram/RemoteAppProgram.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ namespace Microsoft.WindowsAzure.Commands.RemoteApp.Test
2424
using Xunit;
2525

2626
// Publish-AzureRemoteAppProgram, Unpublish-AzureRemoteAppProgram
27+
2728
public class RemoteAppProgramTest : RemoteAppClientTest
2829
{
30+
2931
[Fact]
3032
[Trait(Category.AcceptanceType, Category.CheckIn)]
3133
public void GetAllRemoteApps()

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Test/SecurityPrincipals/RemoteAppSecurityPrincipals.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ namespace Microsoft.WindowsAzure.Commands.RemoteApp.Test
2020
using Microsoft.WindowsAzure.Management.RemoteApp.Models;
2121
using System;
2222
using System.Collections.Generic;
23-
using Xunit;
2423
using Microsoft.WindowsAzure.Commands.ScenarioTest;
24+
using Xunit;
2525

2626
public class AzureRemoteAppServiceUser : RemoteAppClientTest
2727
{

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ namespace Microsoft.WindowsAzure.Commands.RemoteApp.Test
2424
using Xunit;
2525

2626
// Get-AzureRemoteAppResetVpnSharedKey, Get-AzureRemoteAppVpnDeviceConfigScript, Reset-AzureRemoteAppVpnSharedKey
27-
2827
public class NewAzureRemoteAppTemplateImageTest : NewAzureRemoteAppTemplateImage
2928
{
3029
/// <summary>
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.WindowsAzure.Commands.RemoteApp.Test
16+
{
17+
using Common;
18+
using Microsoft.WindowsAzure.Management.RemoteApp.Cmdlets;
19+
using Microsoft.WindowsAzure.Management.RemoteApp.Models;
20+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
21+
using System;
22+
using System.Collections.Generic;
23+
using System.Management.Automation;
24+
using Xunit;
25+
26+
public class RemoteAppUserDiskTest : RemoteAppClientTest
27+
{
28+
[Fact]
29+
[Trait(Category.AcceptanceType, Category.CheckIn)]
30+
public void RemoveUserDisk()
31+
{
32+
RemoveAzureRemoteAppUserDisk mockCmdlet = SetUpTestCommon<RemoveAzureRemoteAppUserDisk>();
33+
34+
// Required parameters for this test
35+
mockCmdlet.CollectionName = collectionName;
36+
mockCmdlet.UserUpn = loggedInUserUpn;
37+
38+
// Setup the environment for testing this cmdlet
39+
MockObject.SetUpDefaultRemoteAppRemoveUserDisk(remoteAppManagementClientMock, mockCmdlet.CollectionName, mockCmdlet.UserUpn);
40+
41+
mockCmdlet.ResetPipelines();
42+
43+
mockCmdlet.ExecuteCmdlet();
44+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
45+
{
46+
Assert.True(false,
47+
String.Format("Remove-AzureRemoteAppUserDisk returned the following error {0}",
48+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
49+
)
50+
);
51+
}
52+
53+
Log("The test for Remove-AzureRemoteAppUserDisk completed successfully");
54+
}
55+
56+
[Fact]
57+
[Trait(Category.AcceptanceType, Category.CheckIn)]
58+
public void CopyUserDisk()
59+
{
60+
CopyAzureRemoteAppUserDisk mockCmdlet = SetUpTestCommon<CopyAzureRemoteAppUserDisk>();
61+
62+
// Required parameters for this test
63+
mockCmdlet.SourceCollectionName = collectionName;
64+
mockCmdlet.DestinationCollectionName = secondaryCollectionName;
65+
mockCmdlet.UserUpn = loggedInUserUpn;
66+
mockCmdlet.OverwriteExistingUserDisk = OverwriteExistingUserDisk;
67+
68+
// Setup the environment for testing this cmdlet
69+
MockObject.SetUpDefaultRemoteAppCopyUserDisk(remoteAppManagementClientMock, mockCmdlet.SourceCollectionName, mockCmdlet.DestinationCollectionName, mockCmdlet.UserUpn, mockCmdlet.OverwriteExistingUserDisk);
70+
mockCmdlet.ResetPipelines();
71+
72+
mockCmdlet.ExecuteCmdlet();
73+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
74+
{
75+
Assert.True(false,
76+
String.Format("Copy-AzureRemoteAppTemplate returned the following error {0}",
77+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
78+
)
79+
);
80+
}
81+
82+
Log("The test for Copy-AzureRemoteAppTemplate completed successfully");
83+
}
84+
}
85+
}

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Test/VNet/RemoteAppVNet.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ namespace Microsoft.WindowsAzure.Commands.RemoteApp.Test
2323
using System.Linq;
2424
using Xunit;
2525

26-
2726
public class RemoteAppVNetTest : RemoteAppClientTest
2827
{
2928

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<package id="Microsoft.Rest.ClientRuntime" version="2.1.0" targetFramework="net45" />
1313
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.0.1-preview" targetFramework="net45" />
1414
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
15-
<package id="Microsoft.WindowsAzure.Management.RemoteApp" version="2.0.4" targetFramework="net45" />
15+
<package id="Microsoft.WindowsAzure.Management.RemoteApp" version="2.0.6" targetFramework="net45" />
1616
<package id="Moq" version="4.2.1510.2205" targetFramework="net45" />
1717
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
1818
<package id="xunit" version="2.1.0" targetFramework="net45" />

src/ServiceManagement/RemoteApp/Commands.RemoteApp/Commands.RemoteApp.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@
112112
<Reference Include="Microsoft.WindowsAzure.Management.Network">
113113
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.7.1.1\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
114114
</Reference>
115-
<Reference Include="Microsoft.WindowsAzure.Management.RemoteApp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
116-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.RemoteApp.2.0.4\lib\net40\Microsoft.WindowsAzure.Management.RemoteApp.dll</HintPath>
115+
<Reference Include="Microsoft.WindowsAzure.Management.RemoteApp, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
116+
<SpecificVersion>False</SpecificVersion>
117+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.RemoteApp.2.0.6\lib\net40\Microsoft.WindowsAzure.Management.RemoteApp.dll</HintPath>
117118
</Reference>
118119
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
119120
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.1.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
@@ -217,6 +218,8 @@
217218
<Compile Include="TemplateImage\RemoveAzureRemoteAppTemplateImage.cs" />
218219
<Compile Include="TemplateImage\RenameAzureRemoteAppTemplateImage.cs" />
219220
<Compile Include="TemplateImage\TemplateImage.cs" />
221+
<Compile Include="UserDisk\CopyAzureRemoteAppUserDisk.cs" />
222+
<Compile Include="UserDisk\RemoveAzureRemoteAppUserDisk.cs" />
220223
<Compile Include="Vm\ClearAzureRemoteAppVmStaleAdObject.cs" />
221224
<Compile Include="Vm\GetAzureRemoteAppVm.cs" />
222225
<Compile Include="Vm\GetAzureRemoteAppVmStaleAdObject.cs" />

0 commit comments

Comments
 (0)