Skip to content

Commit 7470ac6

Browse files
authored
Merge pull request #10763 from raviten/raviten/dec-13
adding cmdlets for edge storage account and edge storage container
2 parents 4fdb331 + f59fc71 commit 7470ac6

File tree

160 files changed

+21174
-9545
lines changed

Some content is hidden

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

160 files changed

+21174
-9545
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/Common.ps1

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,62 +15,79 @@
1515

1616
<#
1717
.SYNOPSIS
18-
Gets valid Device Connection String
18+
Gets valid resource group name
1919
#>
20+
function Get-DeviceResourceGroupName
21+
{
22+
return "psrgpfortest"
23+
}
2024

21-
function Get-DeviceConnectionString
25+
<#
26+
.SYNOPSIS
27+
Gets valid resource name
28+
#>
29+
function Get-DeviceName
2230
{
23-
return "";
31+
return "psddataboxedgecan"
2432
}
2533

2634
<#
2735
.SYNOPSIS
28-
Gets valid IOT Device Connection String
36+
Gets valid resource name
2937
#>
30-
function Get-IotDeviceConnectionString
38+
function Get-VaultName
3139
{
32-
return "";
40+
return "azpsdbe"
3341
}
3442

43+
3544
<#
3645
.SYNOPSIS
37-
Returns Userpassword used for password
38-
Gets valid resource group name
39-
#>
40-
function Get-Userpassword
46+
Gets valid Device Connection String
47+
#>
48+
49+
function Get-DeviceConnectionString
4150
{
42-
return "";
51+
$vaultName = Get-VaultName
52+
$val = Get-AzKeyVaultSecret -VaultName $vaultName -Name "DeviceConnectionString"
53+
return $val.SecretValue
4354
}
4455

4556
<#
4657
.SYNOPSIS
47-
Returns standard EncryptionKey
58+
Gets valid IOT Device Connection String
4859
#>
49-
function Get-EncryptionKey
60+
function Get-IotDeviceConnectionString
5061
{
51-
$encryptionKey = ConvertTo-SecureString -String ""
52-
return $encryptionKey
62+
$vaultName = Get-VaultName
63+
$val = Get-AzKeyVaultSecret -VaultName $vaultName -Name "IotDeviceConnectionString"
64+
return $val.SecretValue
5365
}
5466

5567
<#
5668
.SYNOPSIS
69+
Returns Userpassword used for password
5770
Gets valid resource group name
58-
#>
59-
function Get-DeviceResourceGroupName
71+
#>
72+
function Get-Userpassword
6073
{
61-
return "psrgpfortest"
74+
$vaultName = Get-VaultName
75+
$val = Get-AzKeyVaultSecret -VaultName $vaultName -Name "UserPassword"
76+
return $val.SecretValue
6277
}
6378

6479
<#
6580
.SYNOPSIS
66-
Gets valid resource name
81+
Returns standard EncryptionKey
6782
#>
68-
function Get-DeviceName
83+
function Get-EncryptionKey
6984
{
70-
return "psdataboxedgedevice"
85+
$val = "faked"
86+
return ConvertTo-SecureString $val -AsPlainText -Force
7187
}
7288

7389

90+
7491
function Get-StringHash([String] $String,$HashName = "MD5")
7592
{
7693
$StringBuilder = New-Object System.Text.StringBuilder

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.LiveOnly)]
46+
public void TestRemoveEdgeStorageAccount()
47+
{
48+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-RemoveEdgeStorageAccount");
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)