Skip to content

adding cmdlets for edge storage account and edge storage container #10763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DataBoxEdge/DataBoxEdge.Test/DataBoxEdge.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.EdgeGateway" Version="0.8.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.DataBoxEdge" Version="1.0.0" />
</ItemGroup>

</Project>
59 changes: 38 additions & 21 deletions src/DataBoxEdge/DataBoxEdge.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,62 +15,79 @@

<#
.SYNOPSIS
Gets valid Device Connection String
Gets valid resource group name
#>
function Get-DeviceResourceGroupName
{
return "psrgpfortest"
}

function Get-DeviceConnectionString
<#
.SYNOPSIS
Gets valid resource name
#>
function Get-DeviceName
{
return "";
return "psddataboxedgecan"
}

<#
.SYNOPSIS
Gets valid IOT Device Connection String
Gets valid resource name
#>
function Get-IotDeviceConnectionString
function Get-VaultName
{
return "";
return "azpsdbe"
}


<#
.SYNOPSIS
Returns Userpassword used for password
Gets valid resource group name
#>
function Get-Userpassword
Gets valid Device Connection String
#>

function Get-DeviceConnectionString
{
return "";
$vaultName = Get-VaultName
$val = Get-AzKeyVaultSecret -VaultName $vaultName -Name "DeviceConnectionString"
return $val.SecretValue
}

<#
.SYNOPSIS
Returns standard EncryptionKey
Gets valid IOT Device Connection String
#>
function Get-EncryptionKey
function Get-IotDeviceConnectionString
{
$encryptionKey = ConvertTo-SecureString -String ""
return $encryptionKey
$vaultName = Get-VaultName
$val = Get-AzKeyVaultSecret -VaultName $vaultName -Name "IotDeviceConnectionString"
return $val.SecretValue
}

<#
.SYNOPSIS
Returns Userpassword used for password
Gets valid resource group name
#>
function Get-DeviceResourceGroupName
#>
function Get-Userpassword
{
return "psrgpfortest"
$vaultName = Get-VaultName
$val = Get-AzKeyVaultSecret -VaultName $vaultName -Name "UserPassword"
return $val.SecretValue
}

<#
.SYNOPSIS
Gets valid resource name
Returns standard EncryptionKey
#>
function Get-DeviceName
function Get-EncryptionKey
{
return "psdataboxedgedevice"
$val = "faked"
return ConvertTo-SecureString $val -AsPlainText -Force
}



function Get-StringHash([String] $String,$HashName = "MD5")
{
$StringBuilder = New-Object System.Text.StringBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,10 @@ function Test-CreateRole
$rgname = Get-DeviceResourceGroupName
$dfname = Get-DeviceName
$name = Get-RoleName

$deviceConnectionString = Get-DeviceConnectionString
$deviceConnSec = ConvertTo-SecureString $deviceConnectionString -AsPlainText -Force

$iotDeviceConnectionString = Get-IotDeviceConnectionString
$iotDeviceConnSec = ConvertTo-SecureString $iotDeviceConnectionString -AsPlainText -Force

$encryptionKeyString = Get-EncryptionKey
$encryptionKey = ConvertTo-SecureString $encryptionKeyString -AsPlainText -Force

$deviceConnSec = Get-DeviceConnectionString
$iotDeviceConnSec = Get-IotDeviceConnectionString
$encryptionKey = Get-EncryptionKey

$enabled = "Enabled"
$platform = "Windows"
# Test
Expand All @@ -74,17 +68,10 @@ function Test-RemoveRole
$rgname = Get-DeviceResourceGroupName
$dfname = Get-DeviceName
$name = Get-RoleName

$deviceConnSec = Get-DeviceConnectionString
$iotDeviceConnSec = Get-IotDeviceConnectionString
$encryptionKey = Get-EncryptionKey

$deviceConnectionString = Get-DeviceConnectionString
$deviceConnSec = ConvertTo-SecureString $deviceConnectionString -AsPlainText -Force

$iotDeviceConnectionString = Get-IotDeviceConnectionString
$iotDeviceConnSec = ConvertTo-SecureString $iotDeviceConnectionString -AsPlainText -Force

$encryptionKeyString = Get-EncryptionKey
$encryptionKey = ConvertTo-SecureString $encryptionKeyString -AsPlainText -Force

$enabled = "Enabled"
$platform = "Windows"
# Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using System.IO;
using System.Linq;
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Management.EdgeGateway;
using Microsoft.Azure.Management.DataBoxEdge;
using Microsoft.Azure.Test.HttpRecorder;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
Expand Down Expand Up @@ -46,18 +46,7 @@ protected DataBoxEdgeScenarioTestBase()
public static DataBoxEdgeScenarioTestBase NewInstance => new DataBoxEdgeScenarioTestBase();


protected void SetupManagementClients(MockContext context)
{
var dataBoxEdgeManagementClient = GetDataBoxEdgeManagementClient(context);
var resourceManagementClient = GetResourceManagementClient(context);
var storageManagementClient = GetStorageManagementClient(context);

_helper.SetupManagementClients(
dataBoxEdgeManagementClient,
resourceManagementClient,
storageManagementClient);
}


/// <summary>
/// Methods for invoking PowerShell scripts
/// </summary>
Expand Down Expand Up @@ -104,17 +93,18 @@ private void RunPsTestWorkflow(
{
SetupManagementClients(context);

_helper.SetupEnvironment(AzureModule.AzureResourceManager);
var azDBPath = _helper.GetRMModulePath("Az.DataBoxEdge.psd1");
var callingClassName =
callingClassType.Split(new[] {"."}, StringSplitOptions.RemoveEmptyEntries).Last();

var azDBEPath = _helper.GetRMModulePath("Az.DataBoxEdge.psd1");
_helper.SetupModules(AzureModule.AzureResourceManager,
_helper.RMProfileModule,
azDBEPath,
"ScenarioTests\\Common.ps1",
"ScenarioTests\\" + callingClassName + ".ps1",
_helper.RMProfileModule,
azDBPath,
"AzureRM.Resources.ps1",
"AzureRM.Storage.ps1");
"AzureRM.Storage.ps1",
"AzureRM.Resources.ps1");

try
{
var psScripts = scriptBuilder?.Invoke();
Expand All @@ -130,6 +120,20 @@ private void RunPsTestWorkflow(
}
}


protected void SetupManagementClients(MockContext context)
{
var dataBoxEdgeManagementClient = GetDataBoxEdgeManagementClient(context);
var resourceManagementClient = GetResourceManagementClient(context);
var storageManagementClient = GetStorageManagementClient(context);

_helper.SetupManagementClients(
dataBoxEdgeManagementClient,
resourceManagementClient,
storageManagementClient);
}


protected DataBoxEdgeManagementClient GetDataBoxEdgeManagementClient(MockContext context)
{
return context.GetServiceClient<DataBoxEdgeManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ function Test-CreateShare


$staname = Get-StorageAccountCredentialName
$encryptionKeyString = Get-EncryptionKey
$encryptionKey = ConvertTo-SecureString $encryptionKeyString -AsPlainText -Force
$encryptionKey = Get-EncryptionKey
$storageAccountType = 'GeneralPurposeStorage'
$storageAccountSkuName = 'Standard_LRS'
$storageAccountLocation = 'WestUS'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ function Test-CreateStorageAccountCredential
$rgname = Get-DeviceResourceGroupName
$dfname = Get-DeviceName
$staname = Get-StorageAccountCredentialName
$encryptionKeyString = Get-EncryptionKey
$encryptionKey = ConvertTo-SecureString $encryptionKeyString -AsPlainText -Force

$encryptionKey = Get-EncryptionKey

$storageAccountType = 'GeneralPurposeStorage'
$storageAccountSkuName = 'Standard_LRS'
$storageAccountLocation = 'WestUS'
Expand Down Expand Up @@ -72,9 +71,8 @@ function Test-RemoveStorageAccountCredential
{
$rgname = Get-DeviceResourceGroupName
$dfname = Get-DeviceName
$staname = Get-StorageAccountCredentialName
$encryptionKeyString = Get-EncryptionKey
$encryptionKey = ConvertTo-SecureString $encryptionKeyString -AsPlainText -Force
$staname = Get-StorageAccountCredentialName
$encryptionKey = Get-EncryptionKey

$storageAccountType = 'GeneralPurposeStorage'
$storageAccountSkuName = 'Standard_LRS'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.PowerShell.Cmdlets.DataBoxEdge.Test.ScenarioTests
{
public class DataBoxEdgeStorageAccountTests : DataBoxEdgeScenarioTestBase
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public DataBoxEdgeStorageAccountTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetNonExistingEdgeStorageAccount()
{
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-GetEdgeStorageAccountNonExistent");
}

[Fact]
[Trait(Category.AcceptanceType, Category.LiveOnly)]
public void TestCreateEdgeStorageAccount()
{
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-CreateEdgeStorageAccount");
}

[Fact]
[Trait(Category.AcceptanceType, Category.LiveOnly)]
public void TestRemoveEdgeStorageAccount()
{
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-RemoveEdgeStorageAccount");
}
}
}
Loading