Skip to content
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

[DataBoxEdge] adding orders cmdlet and changes related to local share and adding iot roles #10527

Merged
merged 5 commits into from
Nov 17, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// ----------------------------------------------------------------------------------
//
// 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 DataBoxEdgeOrderTests : DataBoxEdgeScenarioTestBase
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public DataBoxEdgeOrderTests(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 TestGetNonExistingOrder()
{
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-GetOrderNonExistent");
}


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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveOrder()
{
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-RemoveOrder");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

function Get-DeviceForOrder
{
return getAssetName
}


<#
.SYNOPSIS
Negative test. Get resources from an non-existing empty group.
#>
function Test-GetOrderNonExistent
{
$rgname = Get-DeviceResourceGroupName
$dfname = Get-DeviceForOrder
$sku = 'Edge'
$location = 'westus2'

# Test
try
{
$newDevice = New-AzDataBoxEdgeDevice $rgname $dfname -Sku $sku -Location $location
Assert-ThrowsContains { Get-AzDataBoxEdgeOrder $rgname $dfname } "not find"
}
finally
{
Remove-AzDataBoxEdgeDevice $rgname $dfname
}

}


<#
.SYNOPSIS
Tests Create Order and Validate shipping address and Contact Information
#>
function Test-CreateNewOrder
{
$rgname = Get-DeviceResourceGroupName
$dfname = Get-DeviceForOrder
$sku = 'Edge'
$location = 'westus2'

$contactPerson = 'John Mcclane'
$companyName = 'Microsoft'
$phone = 8004269400
$email = 'john@microsoft.com'
$addressLine1 = "Microsoft Corporation"
$postalCode = 98052
$city = 'Redmond'
$state = 'WA'
$country = "United States"

# Test
try
{
$newDevice = New-AzDataBoxEdgeDevice $rgname $dfname -Sku $sku -Location $location
$newOrder = New-AzDataBoxEdgeOrder -ResourceGroupName $rgname -DeviceName $dfname -ContactPerson $contactPerson -CompanyName $companyName -Phone $phone -Email $email -AddressLine1 $addressLine1 -PostalCode $postalCode -City $city -State $state -Country $country
Assert-AreEqual $newDevice.Name $dfname
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ContactInformation.ContactPerson $contactPerson
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ContactInformation.CompanyName $companyName
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ContactInformation.Phone $phone
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ContactInformation.EmailList $email

Assert-AreEqual $newOrder.DataBoxEdgeOrder.ShippingAddress.AddressLine1 $addressLine1
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ShippingAddress.PostalCode $postalCode
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ShippingAddress.City $city
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ShippingAddress.State $state
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ShippingAddress.Country $country

}
finally
{
Remove-AzDataBoxEdgeOrder $rgname $dfname
Remove-AzDataBoxEdgeDevice $rgname $dfname
}
}

<#
.SYNOPSIS
Tests Create Order and Validate shipping address and Contact Information
#>
function Test-RemoveOrder
{
$rgname = Get-DeviceResourceGroupName
$dfname = Get-DeviceForOrder
$sku = 'Edge'
$location = 'westus2'

$contactPerson = 'John Mcclane'
$companyName = 'Microsoft'
$phone = 8004269400
$email = 'john@microsoft.com'
$addressLine1 = "Microsoft Corporation"
$postalCode = 98052
$city = 'Redmond'
$state = 'WA'
$country = "United States"

# Test
try
{
$newDevice = New-AzDataBoxEdgeDevice $rgname $dfname -Sku $sku -Location $location
$newOrder = New-AzDataBoxEdgeOrder -ResourceGroupName $rgname -DeviceName $dfname -ContactPerson $contactPerson -CompanyName $companyName -Phone $phone -Email $email -AddressLine1 $addressLine1 -PostalCode $postalCode -City $city -State $state -Country $country
Remove-AzDataBoxEdgeOrder $rgname $dfname

}
finally
{
Assert-ThrowsContains { Get-AzDataBoxEdgeOrder $rgname $dfname} "not find"
Remove-AzDataBoxEdgeDevice $rgname $dfname
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ public void TestCreateShare()
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-CreateShare");
}

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


[Fact]
[Trait(Category.AcceptanceType, Category.LiveOnly)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveShare()
{
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-RemoveShare");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function Test-CreateShare
# Test
try
{
$expected = New-AzDataBoxEdgeShare $rgname $dfname $sharename $storageAccountCredential.Name -Smb -DataFormat $dataFormat
$expected = New-AzDataBoxEdgeShare $rgname $dfname $sharename $storageAccountCredential.Name -SMB -DataFormat $dataFormat
Assert-AreEqual $expected.Name $sharename

}
Expand All @@ -77,43 +77,42 @@ function Test-CreateShare
}
}

<#
.SYNOPSIS
Tests Create New StorageAccountCredential
#>
function Test-RemoveShare
function Test-CreateLocalShare
{
$rgname = Get-DeviceResourceGroupName
$dfname = Get-DeviceName
$sharename = Get-ShareName
$dataFormat = 'BlockBlob'


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

$storageAccountType = 'GeneralPurposeStorage'
$storageAccountSkuName = 'Standard_LRS'
$storageAccountLocation = 'WestUS'
$storageAccount = New-AzStorageAccount $rgname $staname $storageAccountSkuName -Location $storageAccountLocation

$storageAccountKeys = Get-AzStorageAccountKey $rgname $staname
$storageAccountKey = ConvertTo-SecureString $storageAccountKeys[0] -AsPlainText -Force
$storageAccountCredential = New-AzDataBoxEdgeStorageAccountCredential $rgname $dfname $staname -StorageAccountType $storageAccountType -StorageAccountAccessKey $storageAccountKey -EncryptionKey $encryptionKey

# Test
try
{
$expected = New-AzDataBoxEdgeShare $rgname $dfname $sharename $storageAccountCredential.Name -Smb -DataFormat $dataFormat
Remove-AzDataBoxEdgeShare $rgname $dfname $sharename
Assert-ThrowsContains { Get-AzDataBoxEdgeShare $rgname $dfname $sharename } "not find"

$expected = New-AzDataBoxEdgeShare $rgname $dfname $sharename -NFS
Assert-AreEqual $expected.Name $sharename

}
finally
{
Remove-AzDataBoxEdgeStorageAccountCredential $rgname $dfname $staname
Remove-AzStorageAccount $rgname $staname
Remove-AzDataBoxEdgeShare $rgname $dfname $sharename
}
}

<#
.SYNOPSIS
Tests Create New StorageAccountCredential
#>
function Test-RemoveShare
{
$rgname = Get-DeviceResourceGroupName
$dfname = Get-DeviceName
$sharename = Get-ShareName

# Test

$expected = New-AzDataBoxEdgeShare $rgname $dfname $sharename -SMB
Assert-AreEqual $expected.Name $sharename
Remove-AzDataBoxEdgeShare $rgname $dfname $sharename
Assert-ThrowsContains { Get-AzDataBoxEdgeShare $rgname $dfname $sharename } "not find"



}
Loading