Skip to content

Commit 9565241

Browse files
ravitenerich-wang
authored andcommitted
[DataBoxEdge] adding orders cmdlet and changes related to local share and adding iot roles (Azure#10527)
* adding orders cmdlet and changes related to local share and adding iot roles * resolving static analysis error * removing switch parameters ForwardTrackingInfo, ReturnTrackingInfo, OrderHistory as they will be part of output object only. Updated changelog md and sorted name spaces * renaming sac => storageAccountCredential * incorporating review feedback
1 parent 6631b4e commit 9565241

33 files changed

+10973
-3169
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
16+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17+
using Xunit;
18+
19+
namespace Microsoft.Azure.PowerShell.Cmdlets.DataBoxEdge.Test.ScenarioTests
20+
{
21+
public class DataBoxEdgeOrderTests : DataBoxEdgeScenarioTestBase
22+
{
23+
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
24+
25+
public DataBoxEdgeOrderTests(Xunit.Abstractions.ITestOutputHelper output)
26+
{
27+
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
28+
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
29+
}
30+
31+
[Fact]
32+
[Trait(Category.AcceptanceType, Category.CheckIn)]
33+
public void TestGetNonExistingOrder()
34+
{
35+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-GetOrderNonExistent");
36+
}
37+
38+
39+
[Fact]
40+
[Trait(Category.AcceptanceType, Category.CheckIn)]
41+
public void TestCreateOrder()
42+
{
43+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-CreateNewOrder");
44+
}
45+
46+
[Fact]
47+
[Trait(Category.AcceptanceType, Category.CheckIn)]
48+
public void TestRemoveOrder()
49+
{
50+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-RemoveOrder");
51+
}
52+
}
53+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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-DeviceForOrder
16+
{
17+
return getAssetName
18+
}
19+
20+
21+
<#
22+
.SYNOPSIS
23+
Negative test. Get resources from an non-existing empty group.
24+
#>
25+
function Test-GetOrderNonExistent
26+
{
27+
$rgname = Get-DeviceResourceGroupName
28+
$dfname = Get-DeviceForOrder
29+
$sku = 'Edge'
30+
$location = 'westus2'
31+
32+
# Test
33+
try
34+
{
35+
$newDevice = New-AzDataBoxEdgeDevice $rgname $dfname -Sku $sku -Location $location
36+
Assert-ThrowsContains { Get-AzDataBoxEdgeOrder $rgname $dfname } "not find"
37+
}
38+
finally
39+
{
40+
Remove-AzDataBoxEdgeDevice $rgname $dfname
41+
}
42+
43+
}
44+
45+
46+
<#
47+
.SYNOPSIS
48+
Tests Create Order and Validate shipping address and Contact Information
49+
#>
50+
function Test-CreateNewOrder
51+
{
52+
$rgname = Get-DeviceResourceGroupName
53+
$dfname = Get-DeviceForOrder
54+
$sku = 'Edge'
55+
$location = 'westus2'
56+
57+
$contactPerson = 'John Mcclane'
58+
$companyName = 'Microsoft'
59+
$phone = 8004269400
60+
$email = '[email protected]'
61+
$addressLine1 = "Microsoft Corporation"
62+
$postalCode = 98052
63+
$city = 'Redmond'
64+
$state = 'WA'
65+
$country = "United States"
66+
67+
# Test
68+
try
69+
{
70+
$newDevice = New-AzDataBoxEdgeDevice $rgname $dfname -Sku $sku -Location $location
71+
$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
72+
Assert-AreEqual $newDevice.Name $dfname
73+
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ContactInformation.ContactPerson $contactPerson
74+
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ContactInformation.CompanyName $companyName
75+
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ContactInformation.Phone $phone
76+
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ContactInformation.EmailList $email
77+
78+
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ShippingAddress.AddressLine1 $addressLine1
79+
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ShippingAddress.PostalCode $postalCode
80+
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ShippingAddress.City $city
81+
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ShippingAddress.State $state
82+
Assert-AreEqual $newOrder.DataBoxEdgeOrder.ShippingAddress.Country $country
83+
84+
}
85+
finally
86+
{
87+
Remove-AzDataBoxEdgeOrder $rgname $dfname
88+
Remove-AzDataBoxEdgeDevice $rgname $dfname
89+
}
90+
}
91+
92+
<#
93+
.SYNOPSIS
94+
Tests Create Order and Validate shipping address and Contact Information
95+
#>
96+
function Test-RemoveOrder
97+
{
98+
$rgname = Get-DeviceResourceGroupName
99+
$dfname = Get-DeviceForOrder
100+
$sku = 'Edge'
101+
$location = 'westus2'
102+
103+
$contactPerson = 'John Mcclane'
104+
$companyName = 'Microsoft'
105+
$phone = 8004269400
106+
$email = '[email protected]'
107+
$addressLine1 = "Microsoft Corporation"
108+
$postalCode = 98052
109+
$city = 'Redmond'
110+
$state = 'WA'
111+
$country = "United States"
112+
113+
# Test
114+
try
115+
{
116+
$newDevice = New-AzDataBoxEdgeDevice $rgname $dfname -Sku $sku -Location $location
117+
$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
118+
Remove-AzDataBoxEdgeOrder $rgname $dfname
119+
120+
}
121+
finally
122+
{
123+
Assert-ThrowsContains { Get-AzDataBoxEdgeOrder $rgname $dfname} "not find"
124+
Remove-AzDataBoxEdgeDevice $rgname $dfname
125+
}
126+
}

src/DataBoxEdge/DataBoxEdge.Test/ScenarioTests/DataBoxEdgeShareTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,16 @@ public void TestCreateShare()
4141
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-CreateShare");
4242
}
4343

44+
[Fact]
45+
[Trait(Category.AcceptanceType, Category.CheckIn)]
46+
public void TestCreateLocalShare()
47+
{
48+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-CreateLocalShare");
49+
}
50+
4451

4552
[Fact]
46-
[Trait(Category.AcceptanceType, Category.LiveOnly)]
53+
[Trait(Category.AcceptanceType, Category.CheckIn)]
4754
public void TestRemoveShare()
4855
{
4956
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-RemoveShare");

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

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function Test-CreateShare
6565
# Test
6666
try
6767
{
68-
$expected = New-AzDataBoxEdgeShare $rgname $dfname $sharename $storageAccountCredential.Name -Smb -DataFormat $dataFormat
68+
$expected = New-AzDataBoxEdgeShare $rgname $dfname $sharename $storageAccountCredential.Name -SMB -DataFormat $dataFormat
6969
Assert-AreEqual $expected.Name $sharename
7070

7171
}
@@ -77,43 +77,42 @@ function Test-CreateShare
7777
}
7878
}
7979

80-
<#
81-
.SYNOPSIS
82-
Tests Create New StorageAccountCredential
83-
#>
84-
function Test-RemoveShare
80+
function Test-CreateLocalShare
8581
{
8682
$rgname = Get-DeviceResourceGroupName
8783
$dfname = Get-DeviceName
8884
$sharename = Get-ShareName
89-
$dataFormat = 'BlockBlob'
90-
91-
92-
$staname = Get-StorageAccountCredentialName
93-
$encryptionKeyString = Get-EncryptionKey
94-
$encryptionKey = ConvertTo-SecureString $encryptionKeyString -AsPlainText -Force
95-
96-
$storageAccountType = 'GeneralPurposeStorage'
97-
$storageAccountSkuName = 'Standard_LRS'
98-
$storageAccountLocation = 'WestUS'
99-
$storageAccount = New-AzStorageAccount $rgname $staname $storageAccountSkuName -Location $storageAccountLocation
100-
101-
$storageAccountKeys = Get-AzStorageAccountKey $rgname $staname
102-
$storageAccountKey = ConvertTo-SecureString $storageAccountKeys[0] -AsPlainText -Force
103-
$storageAccountCredential = New-AzDataBoxEdgeStorageAccountCredential $rgname $dfname $staname -StorageAccountType $storageAccountType -StorageAccountAccessKey $storageAccountKey -EncryptionKey $encryptionKey
10485

10586
# Test
10687
try
10788
{
108-
$expected = New-AzDataBoxEdgeShare $rgname $dfname $sharename $storageAccountCredential.Name -Smb -DataFormat $dataFormat
109-
Remove-AzDataBoxEdgeShare $rgname $dfname $sharename
110-
Assert-ThrowsContains { Get-AzDataBoxEdgeShare $rgname $dfname $sharename } "not find"
111-
89+
$expected = New-AzDataBoxEdgeShare $rgname $dfname $sharename -NFS
90+
Assert-AreEqual $expected.Name $sharename
11291

11392
}
11493
finally
11594
{
116-
Remove-AzDataBoxEdgeStorageAccountCredential $rgname $dfname $staname
117-
Remove-AzStorageAccount $rgname $staname
95+
Remove-AzDataBoxEdgeShare $rgname $dfname $sharename
11896
}
11997
}
98+
99+
<#
100+
.SYNOPSIS
101+
Tests Create New StorageAccountCredential
102+
#>
103+
function Test-RemoveShare
104+
{
105+
$rgname = Get-DeviceResourceGroupName
106+
$dfname = Get-DeviceName
107+
$sharename = Get-ShareName
108+
109+
# Test
110+
111+
$expected = New-AzDataBoxEdgeShare $rgname $dfname $sharename -SMB
112+
Assert-AreEqual $expected.Name $sharename
113+
Remove-AzDataBoxEdgeShare $rgname $dfname $sharename
114+
Assert-ThrowsContains { Get-AzDataBoxEdgeShare $rgname $dfname $sharename } "not find"
115+
116+
117+
118+
}

0 commit comments

Comments
 (0)