Skip to content

Commit a08cb44

Browse files
author
Ravi Teja
committed
[DataBoxEdge] Adding Invoke cmdlets for device, Fetching alerts for Device and Adding New, Get and Remove cmdlets for Trigger
1 parent 743f1ae commit a08cb44

28 files changed

+4776
-31
lines changed

src/DataBoxEdge/DataBoxEdge.Test/ScenarioTests/Common.ps1

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,50 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
1516
<#
1617
.SYNOPSIS
17-
Gets valid resource group name
18+
Gets valid Device Connection String
1819
#>
1920

20-
21-
2221
function Get-DeviceConnectionString
2322
{
2423
return "";
2524
}
2625

27-
26+
<#
27+
.SYNOPSIS
28+
Gets valid IOT Device Connection String
29+
#>
2830
function Get-IotDeviceConnectionString
2931
{
3032
return "";
3133
}
3234

3335
<#
3436
.SYNOPSIS
35-
Returns EncryptionKey
36-
#>
37-
function Get-EncryptionKey
37+
Returns Userpassword used for password
38+
Gets valid resource group name
39+
#>
40+
function Get-Userpassword
3841
{
3942
return "";
4043
}
4144

4245
<#
4346
.SYNOPSIS
44-
Returns Userpassword used for password
47+
Returns standard EncryptionKey
4548
#>
46-
function Get-Userpassword
49+
function Get-EncryptionKey
4750
{
48-
return "";
51+
$encryptionKey = ConvertTo-SecureString -String ""
52+
return $encryptionKey
4953
}
5054

51-
52-
53-
55+
<#
56+
.SYNOPSIS
57+
Gets valid resource group name
58+
#>
5459
function Get-DeviceResourceGroupName
5560
{
5661
return "psrgpfortest"
@@ -76,20 +81,18 @@ function Get-StringHash([String] $String,$HashName = "MD5")
7681

7782
<#
7883
.SYNOPSIS
79-
Helper script to generate EncryptionKey
84+
Returns EncryptionKey
8085
#>
8186
function Get-EncryptionKeyForDevice($resourceGroupName, $deviceName)
8287
{
8388

8489
$sp = Get-AzADServicePrincipal -ApplicationId "2368d027-f996-4edb-bf48-928f98f2ab8c"
85-
$e = Get-AzDataBoxEdgeDevice -ResourceGroupName $resourceGroupName -DeviceName $deviceName -ExtendedInfo
90+
$e = Get-AzDataBoxEdgeDevice -ResourceGroupName $resourceGroupName -Name $deviceName -ExtendedInfo
8691
$k = $sp.Id+$e.ResourceKey
92+
echo $k
8793
return Get-StringHash $k "SHA512"
8894
}
8995

90-
91-
92-
9396
<#
9497
.SYNOPSIS
9598
Gets valid storage account name
@@ -133,3 +136,4 @@ function SleepInRecordMode ([int]$SleepIntervalInSec)
133136
}
134137
}
135138

139+
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 DataBoxEdgeTriggerTests : DataBoxEdgeScenarioTestBase
22+
{
23+
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
24+
25+
public DataBoxEdgeTriggerTests(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 TestGetNonExistingTrigger()
34+
{
35+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-GetNonExistingTrigger");
36+
}
37+
38+
39+
[Fact]
40+
[Trait(Category.AcceptanceType, Category.CheckIn)]
41+
public void TestCreateTrigger()
42+
{
43+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-CreateNewTrigger");
44+
}
45+
46+
[Fact]
47+
[Trait(Category.AcceptanceType, Category.CheckIn)]
48+
public void TestRemoveTrigger()
49+
{
50+
DataBoxEdgeScenarioTestBase.NewInstance.RunPowerShellTest(_logger, "Test-RemoveTrigger");
51+
}
52+
}
53+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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-Trigger
16+
{
17+
return getAssetName
18+
}
19+
20+
<#
21+
.SYNOPSIS
22+
Negative test. Get resources from an non-existing empty group.
23+
#>
24+
function Test-GetNonExistingTrigger
25+
{
26+
$rgname = Get-DeviceResourceGroupName
27+
$dfname = Get-DeviceName
28+
$name = Get-Trigger
29+
30+
# Test
31+
Assert-ThrowsContains { Get-AzDataBoxEdgeTrigger -ResourceGroupName $rgname -DeviceName $dfname -Name $name } "not find"
32+
}
33+
34+
35+
<#
36+
.SYNOPSIS
37+
Tests Create New User
38+
#>
39+
function Test-CreateNewTrigger
40+
{
41+
$rgname = Get-DeviceResourceGroupName
42+
$dfname = Get-DeviceName
43+
$name = Get-Trigger
44+
$schedule = "1.00:00"
45+
$startTime = "2022-10-28 12:00:00"
46+
$topic = "topic"
47+
48+
49+
$iotRole = Get-AzDataBoxEdgeRole -ResourceGroupName $rgname -DeviceName $dfname
50+
51+
52+
# Test
53+
try
54+
{
55+
$expected = New-AzDataBoxEdgeTrigger -ResourceGroupName $rgname -DeviceName $dfname -Name $name -PeriodicTimerEvent -RoleName $iotRole.Name -Schedule $schedule -StartTime $startTime -Topic $topic
56+
Assert-AreEqual $expected.Name $name
57+
}
58+
finally
59+
{
60+
Remove-AzDataBoxEdgeTrigger $rgname $dfname $name
61+
}
62+
}
63+
64+
65+
<#
66+
.SYNOPSIS
67+
Test remove User. Creates new user then removes user and try to get the user
68+
#>
69+
function Test-RemoveTrigger
70+
{
71+
$rgname = Get-DeviceResourceGroupName
72+
$dfname = Get-DeviceName
73+
$name = Get-Trigger
74+
$schedule = "1.00:00"
75+
$startTime = "2022-10-28 12:00:00"
76+
$topic = "topic"
77+
78+
79+
$iotRole = Get-AzDataBoxEdgeRole -ResourceGroupName $rgname -DeviceName $dfname
80+
81+
82+
# Test
83+
try
84+
{
85+
$expected = New-AzDataBoxEdgeTrigger -ResourceGroupName $rgname -DeviceName $dfname -Name $name -PeriodicTimerEvent -RoleName $iotRole.Name -Schedule $schedule -StartTime $startTime -Topic $topic
86+
Assert-AreEqual $expected.Name $name
87+
Remove-AzDataBoxEdgeTrigger $rgname $dfname $name
88+
}
89+
finally
90+
{
91+
Assert-ThrowsContains { Get-AzDataBoxEdgeTrigger -ResourceGroupName $rgname -DeviceName $dfname -Name $name } "not find"
92+
}
93+
}

0 commit comments

Comments
 (0)