Skip to content

Commit c43172c

Browse files
author
Ravi Teja
committed
adding cmdlets for edge storage account and edge storage container
1 parent ed9e9aa commit c43172c

File tree

157 files changed

+21119
-9519
lines changed

Some content is hidden

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

157 files changed

+21119
-9519
lines changed

src/DataBoxEdge/DataBoxEdge.Test/DataBoxEdge.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.Azure.Management.EdgeGateway" Version="0.8.1-preview" />
10+
<PackageReference Include="Microsoft.Azure.Management.DataBoxEdge" Version="1.0.0" />
1111
</ItemGroup>
1212

1313
</Project>

src/DataBoxEdge/DataBoxEdge.Test/ScenarioTests/DataBoxEdgeRoleTests.ps1

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,10 @@ function Test-CreateRole
4141
$rgname = Get-DeviceResourceGroupName
4242
$dfname = Get-DeviceName
4343
$name = Get-RoleName
44-
45-
$deviceConnectionString = Get-DeviceConnectionString
46-
$deviceConnSec = ConvertTo-SecureString $deviceConnectionString -AsPlainText -Force
47-
48-
$iotDeviceConnectionString = Get-IotDeviceConnectionString
49-
$iotDeviceConnSec = ConvertTo-SecureString $iotDeviceConnectionString -AsPlainText -Force
50-
51-
$encryptionKeyString = Get-EncryptionKey
52-
$encryptionKey = ConvertTo-SecureString $encryptionKeyString -AsPlainText -Force
53-
44+
$deviceConnSec = Get-DeviceConnectionString
45+
$iotDeviceConnSec = Get-IotDeviceConnectionString
46+
$encryptionKey = Get-EncryptionKey
47+
5448
$enabled = "Enabled"
5549
$platform = "Windows"
5650
# Test
@@ -74,17 +68,10 @@ function Test-RemoveRole
7468
$rgname = Get-DeviceResourceGroupName
7569
$dfname = Get-DeviceName
7670
$name = Get-RoleName
77-
71+
$deviceConnSec = Get-DeviceConnectionString
72+
$iotDeviceConnSec = Get-IotDeviceConnectionString
73+
$encryptionKey = Get-EncryptionKey
7874

79-
$deviceConnectionString = Get-DeviceConnectionString
80-
$deviceConnSec = ConvertTo-SecureString $deviceConnectionString -AsPlainText -Force
81-
82-
$iotDeviceConnectionString = Get-IotDeviceConnectionString
83-
$iotDeviceConnSec = ConvertTo-SecureString $iotDeviceConnectionString -AsPlainText -Force
84-
85-
$encryptionKeyString = Get-EncryptionKey
86-
$encryptionKey = ConvertTo-SecureString $encryptionKeyString -AsPlainText -Force
87-
8875
$enabled = "Enabled"
8976
$platform = "Windows"
9077
# Test

src/DataBoxEdge/DataBoxEdge.Test/ScenarioTests/DataBoxEdgeScenarioTestBase.cs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
using System.IO;
1919
using System.Linq;
2020
using Microsoft.Azure.Commands.Common.Authentication;
21-
using Microsoft.Azure.Management.EdgeGateway;
21+
using Microsoft.Azure.Management.DataBoxEdge;
2222
using Microsoft.Azure.Test.HttpRecorder;
2323
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
2424
using Microsoft.WindowsAzure.Commands.ScenarioTest;
@@ -46,18 +46,7 @@ protected DataBoxEdgeScenarioTestBase()
4646
public static DataBoxEdgeScenarioTestBase NewInstance => new DataBoxEdgeScenarioTestBase();
4747

4848

49-
protected void SetupManagementClients(MockContext context)
50-
{
51-
var dataBoxEdgeManagementClient = GetDataBoxEdgeManagementClient(context);
52-
var resourceManagementClient = GetResourceManagementClient(context);
53-
var storageManagementClient = GetStorageManagementClient(context);
54-
55-
_helper.SetupManagementClients(
56-
dataBoxEdgeManagementClient,
57-
resourceManagementClient,
58-
storageManagementClient);
59-
}
60-
49+
6150
/// <summary>
6251
/// Methods for invoking PowerShell scripts
6352
/// </summary>
@@ -104,17 +93,18 @@ private void RunPsTestWorkflow(
10493
{
10594
SetupManagementClients(context);
10695

107-
_helper.SetupEnvironment(AzureModule.AzureResourceManager);
108-
var azDBPath = _helper.GetRMModulePath("Az.DataBoxEdge.psd1");
10996
var callingClassName =
11097
callingClassType.Split(new[] {"."}, StringSplitOptions.RemoveEmptyEntries).Last();
98+
99+
var azDBEPath = _helper.GetRMModulePath("Az.DataBoxEdge.psd1");
111100
_helper.SetupModules(AzureModule.AzureResourceManager,
101+
_helper.RMProfileModule,
102+
azDBEPath,
112103
"ScenarioTests\\Common.ps1",
113104
"ScenarioTests\\" + callingClassName + ".ps1",
114-
_helper.RMProfileModule,
115-
azDBPath,
116-
"AzureRM.Resources.ps1",
117-
"AzureRM.Storage.ps1");
105+
"AzureRM.Storage.ps1",
106+
"AzureRM.Resources.ps1");
107+
118108
try
119109
{
120110
var psScripts = scriptBuilder?.Invoke();
@@ -130,6 +120,20 @@ private void RunPsTestWorkflow(
130120
}
131121
}
132122

123+
124+
protected void SetupManagementClients(MockContext context)
125+
{
126+
var dataBoxEdgeManagementClient = GetDataBoxEdgeManagementClient(context);
127+
var resourceManagementClient = GetResourceManagementClient(context);
128+
var storageManagementClient = GetStorageManagementClient(context);
129+
130+
_helper.SetupManagementClients(
131+
dataBoxEdgeManagementClient,
132+
resourceManagementClient,
133+
storageManagementClient);
134+
}
135+
136+
133137
protected DataBoxEdgeManagementClient GetDataBoxEdgeManagementClient(MockContext context)
134138
{
135139
return context.GetServiceClient<DataBoxEdgeManagementClient>(TestEnvironmentFactory.GetTestEnvironment());

src/DataBoxEdge/DataBoxEdge.Test/ScenarioTests/DataBoxEdgeShareTests.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ function Test-CreateShare
5151

5252

5353
$staname = Get-StorageAccountCredentialName
54-
$encryptionKeyString = Get-EncryptionKey
55-
$encryptionKey = ConvertTo-SecureString $encryptionKeyString -AsPlainText -Force
54+
$encryptionKey = Get-EncryptionKey
5655
$storageAccountType = 'GeneralPurposeStorage'
5756
$storageAccountSkuName = 'Standard_LRS'
5857
$storageAccountLocation = 'WestUS'

src/DataBoxEdge/DataBoxEdge.Test/ScenarioTests/DataBoxEdgeStorageAccountCredentialTests.ps1

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ function Test-CreateStorageAccountCredential
4040
$rgname = Get-DeviceResourceGroupName
4141
$dfname = Get-DeviceName
4242
$staname = Get-StorageAccountCredentialName
43-
$encryptionKeyString = Get-EncryptionKey
44-
$encryptionKey = ConvertTo-SecureString $encryptionKeyString -AsPlainText -Force
45-
43+
$encryptionKey = Get-EncryptionKey
44+
4645
$storageAccountType = 'GeneralPurposeStorage'
4746
$storageAccountSkuName = 'Standard_LRS'
4847
$storageAccountLocation = 'WestUS'
@@ -72,9 +71,8 @@ function Test-RemoveStorageAccountCredential
7271
{
7372
$rgname = Get-DeviceResourceGroupName
7473
$dfname = Get-DeviceName
75-
$staname = Get-StorageAccountCredentialName
76-
$encryptionKeyString = Get-EncryptionKey
77-
$encryptionKey = ConvertTo-SecureString $encryptionKeyString -AsPlainText -Force
74+
$staname = Get-StorageAccountCredentialName
75+
$encryptionKey = Get-EncryptionKey
7876

7977
$storageAccountType = 'GeneralPurposeStorage'
8078
$storageAccountSkuName = 'Standard_LRS'
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.PowerShell.Cmdlets.DataBoxEdge.Test.ScenarioTests
19+
{
20+
public class DataBoxEdgeStorageAccountTests : DataBoxEdgeScenarioTestBase
21+
{
22+
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
23+
24+
public DataBoxEdgeStorageAccountTests(Xunit.Abstractions.ITestOutputHelper output)
25+
{
26+
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
27+
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
28+
}
29+
30+
[Fact]
31+
[Trait(Category.AcceptanceType, Category.CheckIn)]
32+
public void TestGetNonExistingEdgeStorageAccount()
33+
{
34+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-GetEdgeStorageAccountNonExistent");
35+
}
36+
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.LiveOnly)]
39+
public void TestCreateEdgeStorageAccount()
40+
{
41+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-CreateEdgeStorageAccount");
42+
}
43+
44+
[Fact]
45+
[Trait(Category.AcceptanceType, Category.CheckIn)]
46+
public void TestRemoveEdgeStorageAccount()
47+
{
48+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-RemoveEdgeStorageAccount");
49+
}
50+
}
51+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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+
function Get-StorageAccountCredentialName
16+
{
17+
return getAssetName
18+
}
19+
20+
function Get-EdgeStorageAccountName
21+
{
22+
return getAssetName
23+
}
24+
25+
26+
27+
<#
28+
.SYNOPSIS
29+
Negative test. Get resources from an non-existing empty group.
30+
#>
31+
function Test-GetEdgeStorageAccountNonExistent
32+
{
33+
$rgname = Get-DeviceResourceGroupName
34+
$dfname = Get-DeviceName
35+
$estaname = Get-EdgeStorageAccountName
36+
37+
# Test
38+
Assert-ThrowsContains { Get-AzDataBoxEdgeStorageAccount $rgname $dfname $estaname } "not find"
39+
}
40+
41+
<#
42+
.SYNOPSIS
43+
Tests Create New StorageAccountCredential
44+
#>
45+
function Test-CreateEdgeStorageAccount
46+
{
47+
$rgname = Get-DeviceResourceGroupName
48+
$dfname = Get-DeviceName
49+
$edgeStorageAccountName = Get-EdgeStorageAccountName
50+
51+
52+
$staname = Get-StorageAccountCredentialName
53+
$encryptionKey = Get-EncryptionKey
54+
$storageAccountType = 'GeneralPurposeStorage'
55+
$storageAccountSkuName = 'Standard_LRS'
56+
$storageAccountLocation = 'WestUS'
57+
$storageAccount = New-AzStorageAccount $rgname $staname $storageAccountSkuName -Location $storageAccountLocation
58+
59+
$storageAccountKeys = Get-AzStorageAccountKey $rgname $staname
60+
$storageAccountKey = ConvertTo-SecureString $storageAccountKeys[0] -AsPlainText -Force
61+
$storageAccountCredential = New-AzDataBoxEdgeStorageAccountCredential $rgname $dfname $staname -StorageAccountType $storageAccountType -StorageAccountAccessKey $storageAccountKey -EncryptionKey $encryptionKey
62+
63+
# Test
64+
try
65+
{
66+
$expected = New-AzDataBoxEdgeStorageAccount $rgname $dfname $edgeStorageAccountName -StorageAccountCredentialName $storageAccountCredential.Name
67+
Assert-AreEqual $expected.Name $edgeStorageAccountName
68+
69+
}
70+
finally
71+
{
72+
Remove-AzDataBoxEdgeStorageAccount $rgname $dfname $edgeStorageAccountName
73+
Remove-AzDataBoxEdgeStorageAccountCredential $rgname $dfname $staname
74+
Remove-AzStorageAccount $rgname $staname
75+
}
76+
}
77+
78+
<#
79+
.SYNOPSIS
80+
Tests Create New StorageAccountCredential
81+
#>
82+
function Test-RemoveEdgeStorageAccount
83+
{
84+
$rgname = Get-DeviceResourceGroupName
85+
$dfname = Get-DeviceName
86+
$edgeStorageAccountName = Get-EdgeStorageAccountName
87+
88+
89+
$staname = Get-StorageAccountCredentialName
90+
$encryptionKey = Get-EncryptionKey
91+
$storageAccountType = 'GeneralPurposeStorage'
92+
$storageAccountSkuName = 'Standard_LRS'
93+
$storageAccountLocation = 'WestUS'
94+
$storageAccount = New-AzStorageAccount $rgname $staname $storageAccountSkuName -Location $storageAccountLocation
95+
96+
$storageAccountKeys = Get-AzStorageAccountKey $rgname $staname
97+
$storageAccountKey = ConvertTo-SecureString $storageAccountKeys[0] -AsPlainText -Force
98+
$storageAccountCredential = New-AzDataBoxEdgeStorageAccountCredential $rgname $dfname $staname -StorageAccountType $storageAccountType -StorageAccountAccessKey $storageAccountKey -EncryptionKey $encryptionKey
99+
100+
# Test
101+
try
102+
{
103+
New-AzDataBoxEdgeStorageAccount $rgname $dfname $edgeStorageAccountName -StorageAccountCredentialName $storageAccountCredential.Name
104+
Remove-AzDataBoxEdgeStorageAccount $rgname $dfname $edgeStorageAccountName
105+
Assert-ThrowsContains { Get-AzDataBoxEdgeStorageAccount $rgname $dfname $edgeStorageAccountName } "not find"
106+
107+
}
108+
finally
109+
{
110+
Remove-AzDataBoxEdgeStorageAccountCredential $rgname $dfname $staname
111+
Remove-AzStorageAccount $rgname $staname
112+
}
113+
114+
115+
116+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.PowerShell.Cmdlets.DataBoxEdge.Test.ScenarioTests
19+
{
20+
public class DataBoxEdgeStorageContainerTests : DataBoxEdgeScenarioTestBase
21+
{
22+
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
23+
24+
public DataBoxEdgeStorageContainerTests(Xunit.Abstractions.ITestOutputHelper output)
25+
{
26+
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
27+
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
28+
}
29+
30+
[Fact]
31+
[Trait(Category.AcceptanceType, Category.CheckIn)]
32+
public void TestGetNonExistingEdgeStorageContainer()
33+
{
34+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-GetEdgeStorageContainerNonExistent");
35+
}
36+
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.LiveOnly)]
39+
public void TestCreateEdgeStorageContainer()
40+
{
41+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-CreateEdgeStorageContainer");
42+
}
43+
44+
[Fact]
45+
[Trait(Category.AcceptanceType, Category.CheckIn)]
46+
public void TestRemoveEdgeStorageContainer()
47+
{
48+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-RemoveEdgeStorageContainer");
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)