Skip to content

Commit cd9d852

Browse files
committed
Merge pull request #37 from MabOneSdk/pikumar3
Pikumar3
2 parents 4efcae1 + 2fd9b00 commit cd9d852

File tree

12 files changed

+885
-138
lines changed

12 files changed

+885
-138
lines changed

setup/azurecmdfiles.wxi

Lines changed: 450 additions & 90 deletions
Large diffs are not rendered by default.

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@
155155
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
156156
</None>
157157
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\BackUpAzureBackUpItem.json" />
158+
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\EnableDisableAzureBackupProtectionTest.json" />
158159
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\GetAzureBackupJobTests.json" />
159160
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\GetRecoveryPointTests.json" />
161+
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\ListAzureBackupItemTests.json" />
160162
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\ListProtectionPolicyTests.json">
161163
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
162164
</None>

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ public void ListProtectionPolicyTests()
2525
this.RunPowerShellTest("Test-GetAzureBackupProtectionPolicyTests");
2626
}
2727

28+
[Fact]
29+
public void ListAzureBackupItemTests()
30+
{
31+
this.RunPowerShellTest("Test-GetAzureBackupItemTests");
32+
}
33+
34+
[Fact]
35+
public void EnableDisableAzureBackupProtectionTest()
36+
{
37+
this.RunPowerShellTest("Test-EnableDisableAzureBackupProtectionTest");
38+
}
39+
2840
[Fact]
2941

3042
public void GetAzureBackupJobTests()

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.ps1

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ $ContainerType = "IaasVMContainer"
1919
$DataSourceType = "VM"
2020
$DataSourceId = "17593283453810"
2121
$Location = "SouthEast Asia"
22+
$PolicyName = "Policy9";
23+
$PolicyId = "c87bbada-6e1b-4db2-b76c-9062d28959a4";
24+
$POName = "iaasvmcontainer;dev01testing;dev01testing"
2225

2326
<#
2427
.SYNOPSIS
@@ -54,15 +57,69 @@ function GetAzureRecoveryPointTest
5457
$recoveryPoints = Get-AzureBackupRecoveryPoint -item $azureBackUpItem
5558
if (!($recoveryPoints -eq $null))
5659
{
57-
foreach($recoveryPoint in $recoveryPoints)
58-
{
59-
Assert-NotNull $recoveryPoint.RecoveryPointTime 'RecoveryPointTime should not be null'
60-
Assert-NotNull $recoveryPoint.RecoveryPointType 'RecoveryPointType should not be null'
61-
Assert-NotNull $recoveryPoint.RecoveryPointId 'RecoveryPointId should not be null'
62-
}
60+
foreach($recoveryPoint in $recoveryPoints)
61+
{
62+
Assert-NotNull $recoveryPoint.RecoveryPointTime 'RecoveryPointTime should not be null'
63+
Assert-NotNull $recoveryPoint.RecoveryPointType 'RecoveryPointType should not be null'
64+
Assert-NotNull $recoveryPoint.RecoveryPointId 'RecoveryPointId should not be null'
6365
}
6466
}
6567

68+
function Test-GetAzureBackupItemTests
69+
{
70+
$azureBackUpContainer = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupContainer
71+
$azureBackUpContainer.ResourceGroupName = $ResourceGroupName
72+
$azureBackUpContainer.ResourceName = $ResourceName
73+
$azureBackUpContainer.Location = $Location
74+
$azureBackUpContainer.ContainerUniqueName = $ContainerName
75+
$azureBackUpContainer.ContainerType = $ContainerType
76+
$item = Get-AzureBackupItem -container $azureBackUpContainer
77+
if (!($item -eq $null))
78+
{
79+
foreach($backupitem in $item)
80+
{
81+
Assert-NotNull $backupitem.ProtectionStatus 'ProtectionStatus should not be null'
82+
Assert-NotNull $backupitem.Name 'Name should not be null'
83+
Assert-NotNull $backupitem.Type 'Type should not be null'
84+
Assert-NotNull $backupitem.ContainerType 'ContainerType should not be null'
85+
Assert-NotNull $backupitem.ContainerUniqueName 'ContainerUniqueName should not be null'
86+
Assert-NotNull $backupitem.ResourceGroupName 'ResourceGroupName should not be null'
87+
Assert-NotNull $backupitem.ResourceName 'ResourceName should not be null'
88+
Assert-NotNull $backupitem.Location 'Location should not be null'
89+
}
90+
}
91+
}
92+
93+
function Test-EnableDisableAzureBackupProtectionTest
94+
{
95+
$policy = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupProtectionPolicy
96+
$policy.InstanceId = $PolicyId
97+
$policy.Name = $PolicyName
98+
$policy.ResourceGroupName = $ResourceGroupName
99+
$policy.ResourceName = $ResourceName
100+
$policy.Location = $Location
101+
$policy.WorkloadType = "VM"
102+
$policy.RetentionType = "1"
103+
$policy.ScheduleRunTimes = "2015-06-13T20:30:00"
104+
105+
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupItem
106+
$azureBackUpItem.ResourceGroupName = $ResourceGroupName
107+
$azureBackUpItem.ResourceName = $ResourceName
108+
$azureBackUpItem.Location = $Location
109+
$azureBackUpItem.ContainerUniqueName = $ContainerName
110+
$azureBackUpItem.ContainerType = $ContainerType
111+
$azureBackUpItem.DataSourceId = $DataSourceId
112+
$azureBackUpItem.Type = $DataSourceType
113+
$azureBackUpItem.Name = $POName
114+
115+
$jobId = Enable-AzureBackupProtection -item $azureBackUpItem -Policy $policy
116+
sleep(20)
117+
$jobId1 = Disable-AzureBackupProtection -item $azureBackUpItem
118+
sleep(20)
119+
$jobId2 = Enable-AzureBackupProtection -item $azureBackUpItem -Policy $policy
120+
}
121+
}
122+
66123
function BackUpAzureBackUpItemTest
67124
{
68125
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupItem
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/Subscriptions/f5303a0b-fae4-4cdb-b44d-0e4c032dde26/resourceGroups/backuprg/providers/Microsoft.Backupseadev01/BackupVault/backuprn/protectableobjects/protect?api-version=2014-09-01",
5+
"EncodedRequestUri": "L1N1YnNjcmlwdGlvbnMvZjUzMDNhMGItZmFlNC00Y2RiLWI0NGQtMGU0YzAzMmRkZTI2L3Jlc291cmNlR3JvdXBzL2JhY2t1cHJnL3Byb3ZpZGVycy9NaWNyb3NvZnQuQmFja3Vwc2VhZGV2MDEvQmFja3VwVmF1bHQvYmFja3Vwcm4vcHJvdGVjdGFibGVvYmplY3RzL3Byb3RlY3Q/YXBpLXZlcnNpb249MjAxNC0wOS0wMQ==",
6+
"RequestMethod": "POST",
7+
"RequestBody": "{\r\n \"ProtectableObjects\": [\r\n \"iaasvmcontainer;dev01testing;dev01testing\"\r\n ],\r\n \"ProtectableObjectType\": \"VM\",\r\n \"PolicyId\": \"c87bbada-6e1b-4db2-b76c-9062d28959a4\"\r\n}",
8+
"RequestHeaders": {
9+
"Content-Type": [
10+
"application/json"
11+
],
12+
"Content-Length": [
13+
"174"
14+
],
15+
"Accept-Language": [
16+
"en-us"
17+
],
18+
"User-Agent": [
19+
"Microsoft.Azure.Management.BackupServices.BackupServicesManagementClient/0.0.0.0"
20+
]
21+
},
22+
"ResponseBody": "\"f0cba117-8ffe-4f9e-8ca5-84104e73d8d8\"",
23+
"ResponseHeaders": {
24+
"Content-Length": [
25+
"38"
26+
],
27+
"Content-Type": [
28+
"application/json"
29+
],
30+
"Expires": [
31+
"-1"
32+
],
33+
"Pragma": [
34+
"no-cache"
35+
],
36+
"x-ms-request-id": [
37+
"2fc9c464-5788-4a97-974c-27e3e3ffbe4d"
38+
],
39+
"x-ms-client-request-id": [
40+
"4cd7d528-2138-46fe-a247-b3e8115ff54a",
41+
"4cd7d528-2138-46fe-a247-b3e8115ff54a"
42+
],
43+
"Strict-Transport-Security": [
44+
"max-age=31536000; includeSubDomains"
45+
],
46+
"x-ms-ratelimit-remaining-subscription-writes": [
47+
"1198"
48+
],
49+
"x-ms-correlation-request-id": [
50+
"2fc9c464-5788-4a97-974c-27e3e3ffbe4d"
51+
],
52+
"x-ms-routing-request-id": [
53+
"CENTRALUS:20150615T144514Z:2fc9c464-5788-4a97-974c-27e3e3ffbe4d"
54+
],
55+
"Cache-Control": [
56+
"no-cache"
57+
],
58+
"Date": [
59+
"Mon, 15 Jun 2015 14:45:14 GMT"
60+
],
61+
"Server": [
62+
"Microsoft-IIS/8.0"
63+
],
64+
"X-Powered-By": [
65+
"ASP.NET"
66+
]
67+
},
68+
"StatusCode": 202
69+
},
70+
{
71+
"RequestUri": "/Subscriptions/f5303a0b-fae4-4cdb-b44d-0e4c032dde26/resourceGroups/backuprg/providers/Microsoft.Backupseadev01/BackupVault/backuprn/protectableobjects/protect?api-version=2014-09-01",
72+
"EncodedRequestUri": "L1N1YnNjcmlwdGlvbnMvZjUzMDNhMGItZmFlNC00Y2RiLWI0NGQtMGU0YzAzMmRkZTI2L3Jlc291cmNlR3JvdXBzL2JhY2t1cHJnL3Byb3ZpZGVycy9NaWNyb3NvZnQuQmFja3Vwc2VhZGV2MDEvQmFja3VwVmF1bHQvYmFja3Vwcm4vcHJvdGVjdGFibGVvYmplY3RzL3Byb3RlY3Q/YXBpLXZlcnNpb249MjAxNC0wOS0wMQ==",
73+
"RequestMethod": "POST",
74+
"RequestBody": "{\r\n \"ProtectableObjects\": [\r\n \"iaasvmcontainer;dev01testing;dev01testing\"\r\n ],\r\n \"ProtectableObjectType\": \"VM\",\r\n \"PolicyId\": \"c87bbada-6e1b-4db2-b76c-9062d28959a4\"\r\n}",
75+
"RequestHeaders": {
76+
"Content-Type": [
77+
"application/json"
78+
],
79+
"Content-Length": [
80+
"174"
81+
],
82+
"Accept-Language": [
83+
"en-us"
84+
],
85+
"User-Agent": [
86+
"Microsoft.Azure.Management.BackupServices.BackupServicesManagementClient/0.0.0.0"
87+
]
88+
},
89+
"ResponseBody": "\"8a5a5957-9fdf-43da-9259-63e8abe3fc57\"",
90+
"ResponseHeaders": {
91+
"Content-Length": [
92+
"38"
93+
],
94+
"Content-Type": [
95+
"application/json"
96+
],
97+
"Expires": [
98+
"-1"
99+
],
100+
"Pragma": [
101+
"no-cache"
102+
],
103+
"x-ms-request-id": [
104+
"772c23c3-c24a-48f0-a6db-b57afa35ebaf"
105+
],
106+
"x-ms-client-request-id": [
107+
"4e04d16f-deb2-4ab6-89ef-5c971506864b",
108+
"4e04d16f-deb2-4ab6-89ef-5c971506864b"
109+
],
110+
"Strict-Transport-Security": [
111+
"max-age=31536000; includeSubDomains"
112+
],
113+
"x-ms-ratelimit-remaining-subscription-writes": [
114+
"1196"
115+
],
116+
"x-ms-correlation-request-id": [
117+
"772c23c3-c24a-48f0-a6db-b57afa35ebaf"
118+
],
119+
"x-ms-routing-request-id": [
120+
"CENTRALUS:20150615T144558Z:772c23c3-c24a-48f0-a6db-b57afa35ebaf"
121+
],
122+
"Cache-Control": [
123+
"no-cache"
124+
],
125+
"Date": [
126+
"Mon, 15 Jun 2015 14:45:58 GMT"
127+
],
128+
"Server": [
129+
"Microsoft-IIS/8.0"
130+
],
131+
"X-Powered-By": [
132+
"ASP.NET"
133+
]
134+
},
135+
"StatusCode": 202
136+
},
137+
{
138+
"RequestUri": "/Subscriptions/f5303a0b-fae4-4cdb-b44d-0e4c032dde26/resourceGroups/backuprg/providers/Microsoft.Backupseadev01/BackupVault/backuprn/containers/iaasvmcontainer%3Bdev01testing%3Bdev01testing/datasources/VM/17593283453810/unprotect?api-version=2014-09-01",
139+
"EncodedRequestUri": "L1N1YnNjcmlwdGlvbnMvZjUzMDNhMGItZmFlNC00Y2RiLWI0NGQtMGU0YzAzMmRkZTI2L3Jlc291cmNlR3JvdXBzL2JhY2t1cHJnL3Byb3ZpZGVycy9NaWNyb3NvZnQuQmFja3Vwc2VhZGV2MDEvQmFja3VwVmF1bHQvYmFja3Vwcm4vY29udGFpbmVycy9pYWFzdm1jb250YWluZXIlM0JkZXYwMXRlc3RpbmclM0JkZXYwMXRlc3RpbmcvZGF0YXNvdXJjZXMvVk0vMTc1OTMyODM0NTM4MTAvdW5wcm90ZWN0P2FwaS12ZXJzaW9uPTIwMTQtMDktMDE=",
140+
"RequestMethod": "POST",
141+
"RequestBody": "{\r\n \"RemoveProtectionOption\": \"RetainBackupData\"\r\n}",
142+
"RequestHeaders": {
143+
"Content-Type": [
144+
"application/json"
145+
],
146+
"Content-Length": [
147+
"52"
148+
],
149+
"Accept-Language": [
150+
"en-us"
151+
],
152+
"User-Agent": [
153+
"Microsoft.Azure.Management.BackupServices.BackupServicesManagementClient/0.0.0.0"
154+
]
155+
},
156+
"ResponseBody": "\"a6c19cb6-6f29-40d7-a216-e4590ad7550d\"",
157+
"ResponseHeaders": {
158+
"Content-Length": [
159+
"38"
160+
],
161+
"Content-Type": [
162+
"application/json"
163+
],
164+
"Expires": [
165+
"-1"
166+
],
167+
"Pragma": [
168+
"no-cache"
169+
],
170+
"x-ms-request-id": [
171+
"a51fe2a5-f3d6-4d3e-af88-0e421ffe207c"
172+
],
173+
"x-ms-client-request-id": [
174+
"e0dc8344-0909-4188-aa69-49f7f5914b16",
175+
"e0dc8344-0909-4188-aa69-49f7f5914b16"
176+
],
177+
"Strict-Transport-Security": [
178+
"max-age=31536000; includeSubDomains"
179+
],
180+
"x-ms-ratelimit-remaining-subscription-writes": [
181+
"1197"
182+
],
183+
"x-ms-correlation-request-id": [
184+
"a51fe2a5-f3d6-4d3e-af88-0e421ffe207c"
185+
],
186+
"x-ms-routing-request-id": [
187+
"CENTRALUS:20150615T144536Z:a51fe2a5-f3d6-4d3e-af88-0e421ffe207c"
188+
],
189+
"Cache-Control": [
190+
"no-cache"
191+
],
192+
"Date": [
193+
"Mon, 15 Jun 2015 14:45:36 GMT"
194+
],
195+
"Server": [
196+
"Microsoft-IIS/8.0"
197+
],
198+
"X-Powered-By": [
199+
"ASP.NET"
200+
]
201+
},
202+
"StatusCode": 202
203+
}
204+
],
205+
"Names": {},
206+
"Variables": {
207+
"SubscriptionId": "f5303a0b-fae4-4cdb-b44d-0e4c032dde26"
208+
}
209+
}

0 commit comments

Comments
 (0)