Skip to content

Commit 05fa62d

Browse files
authored
Merge pull request Azure#10257 from rileymckenna/feature/updateApiVersion
Fixed bug and added more tests
2 parents 4548cbe + e32846c commit 05fa62d

30 files changed

+5100
-369
lines changed

src/Peering/Peering.Test/ScenarioTests/CreateNewDirectConnectionTests.cs

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
1616
{
1717
using Microsoft.Azure.ServiceManagement.Common.Models;
18-
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
1918
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2019

2120
using Xunit;
@@ -123,6 +122,66 @@ public void TestNewDirectConnectionWrongV6()
123122
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWrongV6");
124123
}
125124

125+
/// <summary>
126+
/// The test new direct connection with microsoft ip address
127+
/// </summary>
128+
[Fact]
129+
[Trait(Category.AcceptanceType, Category.CheckIn)]
130+
public void TestNewDirectConnectionWithMicrosoftSession()
131+
{
132+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSession");
133+
}
134+
135+
/// <summary>
136+
/// The test new direct connection with microsoft ip address
137+
/// </summary>
138+
[Fact]
139+
[Trait(Category.AcceptanceType, Category.CheckIn)]
140+
public void TestNewDirectConnectionWithMicrosoftSessionWithPeeringService()
141+
{
142+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSessionWithPeeringService");
143+
}
144+
145+
/// <summary>
146+
/// The test new direct connection with microsoft ip address
147+
/// </summary>
148+
[Fact]
149+
[Trait(Category.AcceptanceType, Category.CheckIn)]
150+
public void TestNewDirectConnectionWithMicrosoftSessionInvalidV4()
151+
{
152+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSessionInvalidV4");
153+
}
154+
155+
/// <summary>
156+
/// The test new direct connection with microsoft ip address
157+
/// </summary>
158+
[Fact]
159+
[Trait(Category.AcceptanceType, Category.CheckIn)]
160+
public void TestNewDirectConnectionWithMicrosoftSessionInvalidV6()
161+
{
162+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSessionInvalidV6");
163+
}
164+
165+
/// <summary>
166+
/// The test new direct connection with microsoft ip address
167+
/// </summary>
168+
[Fact]
169+
[Trait(Category.AcceptanceType, Category.CheckIn)]
170+
public void TestNewDirectConnectionWithNoPeeringFacility()
171+
{
172+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithNoPeeringFacility");
173+
}
174+
175+
/// <summary>
176+
/// The test new direct connection with microsoft ip address
177+
/// </summary>
178+
[Fact]
179+
[Trait(Category.AcceptanceType, Category.CheckIn)]
180+
public void TestNewDirectConnectionWithNoBgpSession()
181+
{
182+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithNoBgpSession");
183+
}
184+
126185
/// <summary>
127186
/// The test new direct connection with microsoft ip address
128187
/// </summary>

src/Peering/Peering.Test/ScenarioTests/CreateNewDirectConnectionTests.ps1

Lines changed: 144 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ NewDirectConnectionWithV4V6
1717
#>
1818
function Test-NewDirectConnectionWithV4V6
1919
{
20+
$asn = makePeerAsn 65000
2021
#Hard Coded locations becuase of limitations in locations
2122
$kind = isDirect $true;
2223
$loc = "Los Angeles"
@@ -43,13 +44,18 @@ function Test-NewDirectConnectionWithV4V6
4344
Assert-AreEqual $sessionv6 $createdConnection.BgpSession.SessionPrefixV6
4445
Assert-AreEqual $false $createdConnection.UseForPeeringService
4546
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider
47+
48+
removePeerAsn $asn
49+
50+
4651
}
4752
<#
4853
.SYNOPSIS
4954
NewDirectConnectionWithV6 v6 should be null
5055
#>
5156
function Test-NewDirectConnectionWithV4
5257
{
58+
$asn = makePeerAsn 65000
5359
#Hard Coded locations becuase of limitations in locations
5460
$kind = isDirect $true;
5561
$loc = "Amsterdam"
@@ -75,13 +81,17 @@ function Test-NewDirectConnectionWithV4
7581
Assert-Null $createdConnection.BgpSession.SessionPrefixV6
7682
Assert-AreEqual $false $createdConnection.UseForPeeringService
7783
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider
84+
85+
removePeerAsn $asn
86+
7887
}
7988
<#
8089
.SYNOPSIS
8190
NewDirectConnectionWithV6 v4 should be Null
8291
#>
8392
function Test-NewDirectConnectionWithV6
8493
{
94+
$asn = makePeerAsn 65000
8595
#Hard Coded locations becuase of limitations in locations
8696
$kind = isDirect $true;
8797
$loc = "Los Angeles"
@@ -106,13 +116,17 @@ function Test-NewDirectConnectionWithV6
106116
Assert-AreEqual $sessionv6 $createdConnection.BgpSession.SessionPrefixV6
107117
Assert-AreEqual $false $createdConnection.UseForPeeringService
108118
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider
119+
120+
removePeerAsn $asn
121+
109122
}
110123
<#
111124
.SYNOPSIS
112125
NewDirectConnectionNoSession should pass with null value
113126
#>
114127
function Test-NewDirectConnectionNoSession
115128
{
129+
$asn = makePeerAsn 65000
116130
#Hard Coded locations becuase of limitations in locations
117131
$kind = isDirect $true;
118132
$loc = "Ashburn"
@@ -136,13 +150,17 @@ function Test-NewDirectConnectionNoSession
136150
Assert-AreEqual $facilityId $createdConnection.PeeringDBFacilityId
137151
Assert-Null $createdConnection.BgpSession
138152
Assert-AreEqual $true $createdConnection.UseForPeeringService
139-
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider}
153+
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider
154+
155+
removePeerAsn $asn
156+
}
140157
<#
141158
.SYNOPSIS
142159
NewDirectConnectionWithV6 should fail with high BandwidthInMbps message
143160
#>
144161
function Test-NewDirectConnectionHighBandwidth
145162
{
163+
$asn = makePeerAsn 65000
146164
#Hard Coded locations becuase of limitations in locations
147165
$kind = isDirect $true;
148166
$loc = "Los Angeles"
@@ -165,13 +183,17 @@ function Test-NewDirectConnectionHighBandwidth
165183
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
166184
#create Connection
167185
Assert-ThrowsContains { New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV6 $sessionv6 -MaxPrefixesAdvertisedIPv6 $maxv6 -BandwidthInMbps $bandwidth -MD5AuthenticationKey $md5 } "The $bandwidth argument is greater than the maximum allowed range of 100000"
186+
187+
removePeerAsn $asn
188+
168189
}
169190
<#
170191
.SYNOPSIS
171192
NewDirectConnectionWithV6 should fail with low BandwidthInMbps message
172193
#>
173194
function Test-NewDirectConnectionLowBandwidth
174195
{
196+
$asn = makePeerAsn 65000
175197
#Hard Coded locations becuase of limitations in locations
176198
$kind = isDirect $true;
177199
$loc = "Ashburn"
@@ -192,14 +214,18 @@ function Test-NewDirectConnectionLowBandwidth
192214
$maxv6 = maxAdvertisedIpv6
193215
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
194216
#create Connection
195-
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV6 $sessionv6 -MaxPrefixesAdvertisedIPv6 $maxv6 -BandwidthInMbps $wrongBandwidth -MD5AuthenticationKey $md5} "The $wrongBandwidth argument is less than the minimum allowed range of 10000"
217+
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV6 $sessionv6 -MaxPrefixesAdvertisedIPv6 $maxv6 -BandwidthInMbps $wrongBandwidth -MD5AuthenticationKey $md5} "The $wrongBandwidth argument is less than the minimum allowed range of 10000"
218+
219+
removePeerAsn $asn
220+
196221
}
197222
<#
198223
.SYNOPSIS
199224
NewDirectConnectionWithV6 should fail with wrong IP
200225
#>
201226
function Test-NewDirectConnectionWrongV6
202227
{
228+
$asn = makePeerAsn 65000
203229
#Hard Coded locations becuase of limitations in locations
204230
$kind = isDirect $true;
205231
$loc = "Ashburn"
@@ -220,13 +246,17 @@ function Test-NewDirectConnectionWrongV6
220246
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
221247
#create Connection
222248
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV6 $wrongv6 -MaxPrefixesAdvertisedIPv6 $maxv6 -BandwidthInMbps $bandwidth -MD5AuthenticationKey $md5} "Invalid Prefix: $wrongv6, must be"
249+
250+
removePeerAsn $asn
251+
223252
}
224253
<#
225254
.SYNOPSIS
226255
NewDirectConnectionWithV4 with fail on wrong IP
227256
#>
228257
function Test-NewDirectConnectionWrongV4
229258
{
259+
$asn = makePeerAsn 65000
230260
#Hard Coded locations becuase of limitations in locations
231261
$kind = isDirect $true;
232262
$loc = "Ashburn"
@@ -247,6 +277,9 @@ function Test-NewDirectConnectionWrongV4
247277
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
248278
#create Connection
249279
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV4 $wrongv4 -MaxPrefixesAdvertisedIPv4 $maxv4 -BandwidthInMbps $bandwidth -MD5AuthenticationKey $md5.ToString} "Invalid Prefix: $wrongv4, must be "
280+
281+
removePeerAsn $asn
282+
250283
}
251284

252285
<#
@@ -255,6 +288,7 @@ Microsoft Provided IP address
255288
#>
256289
function Test-NewDirectConnectionWithMicrosoftIpProvidedAddress
257290
{
291+
$asn = makePeerAsn 65000
258292
#Hard Coded locations becuase of limitations in locations
259293
$kind = isDirect $true;
260294
$loc = "Los Angeles"
@@ -270,4 +304,112 @@ function Test-NewDirectConnectionWithMicrosoftIpProvidedAddress
270304
Assert-AreEqual $null $createdConnection.BgpSession
271305
Assert-AreEqual $true $createdConnection.UseForPeeringService
272306
Assert-AreEqual "Microsoft" $createdConnection.SessionAddressProvider
307+
removePeerAsn $asn
308+
309+
}
310+
311+
<#
312+
.SYNOPSIS
313+
Microsoft Provided IP address
314+
#>
315+
function Test-NewDirectConnectionWithNoPeeringFacility
316+
{
317+
$asn = makePeerAsn 65000
318+
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId} "Missing an argument for parameter 'PeeringDBFacilityId'"
319+
removePeerAsn $asn
320+
}
321+
322+
<#
323+
.SYNOPSIS
324+
NoBgpSession
325+
#>
326+
function Test-NewDirectConnectionWithNoBgpSession
327+
{
328+
$asn = makePeerAsn 65000
329+
$peeringLocation = Get-AzPeeringLocation -Kind Direct
330+
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
331+
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
332+
$bandwidth = getBandwidth
333+
$connection = New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth
334+
Assert-AreEqual $facilityId $connection.PeeringDBFacilityId
335+
Assert-AreEqual $bandwidth $connection.BandwidthInMbps
336+
Assert-AreEqual "Peer" $connection.SessionAddressProvider
337+
338+
removePeerAsn $asn
339+
340+
}
341+
342+
<#
343+
.SYNOPSIS
344+
NoBgpSession
345+
#>
346+
function Test-NewDirectConnectionWithMicrosoftSession
347+
{
348+
$asn = makePeerAsn 65000
349+
$peeringLocation = Get-AzPeeringLocation -Kind Direct
350+
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
351+
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
352+
$bandwidth = getBandwidth
353+
$connection = New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth -MicrosoftProvidedIPAddress
354+
Assert-AreEqual $facilityId $connection.PeeringDBFacilityId
355+
Assert-AreEqual $bandwidth $connection.BandwidthInMbps
356+
Assert-AreEqual "Microsoft" $connection.SessionAddressProvider
357+
Assert-False {$connection.UseForPeeringService}
358+
359+
removePeerAsn $asn
360+
361+
}
362+
<#
363+
.SYNOPSIS
364+
NoBgpSession
365+
#>
366+
function Test-NewDirectConnectionWithMicrosoftSessionWithPeeringService
367+
{
368+
$asn = makePeerAsn 65000
369+
$peeringLocation = Get-AzPeeringLocation -Kind Direct
370+
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
371+
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
372+
$bandwidth = getBandwidth
373+
$connection = New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth -MicrosoftProvidedIPAddress -UseForPeeringService
374+
Assert-AreEqual $facilityId $connection.PeeringDBFacilityId
375+
Assert-AreEqual $bandwidth $connection.BandwidthInMbps
376+
Assert-AreEqual "Microsoft" $connection.SessionAddressProvider
377+
Assert-True {$connection.UseForPeeringService}
378+
379+
removePeerAsn $asn
380+
381+
}
382+
383+
<#
384+
.SYNOPSIS
385+
NoBgpSession
386+
#>
387+
function Test-NewDirectConnectionWithMicrosoftSessionInvalidV4
388+
{
389+
$asn = makePeerAsn 65000
390+
$peeringLocation = Get-AzPeeringLocation -Kind Direct
391+
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
392+
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
393+
$bandwidth = getBandwidth
394+
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth -SessionPrefixV4 4.4.4.4 -MicrosoftProvidedIPAddress} "Parameter set cannot be resolved using the specified named parameters"
395+
396+
removePeerAsn $asn
397+
398+
}
399+
400+
<#
401+
.SYNOPSIS
402+
NoBgpSession
403+
#>
404+
function Test-NewDirectConnectionWithMicrosoftSessionInvalidV6
405+
{
406+
$asn = makePeerAsn 65000
407+
$peeringLocation = Get-AzPeeringLocation -Kind Direct
408+
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
409+
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
410+
$bandwidth = getBandwidth
411+
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth -SessionPrefixV6 "fe01::40ef" -MicrosoftProvidedIPAddress} "Parameter set cannot be resolved using the specified named parameters"
412+
413+
removePeerAsn $asn
414+
273415
}

src/Peering/Peering.Test/ScenarioTests/GetLocationTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,15 @@ public void TestGetLocationKindDirectSeattle99999()
9999
{
100100
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectSeattle99999");
101101
}
102+
103+
/// <summary>
104+
/// The test get location kind direct ams
105+
/// </summary>
106+
[Fact]
107+
[Trait(Category.AcceptanceType, Category.CheckIn)]
108+
public void TestGetLocationKindDirectAmsterdam()
109+
{
110+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectAmsterdam");
111+
}
102112
}
103113
}

src/Peering/Peering.Test/ScenarioTests/GetLocationTests.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,21 @@ function Test-GetLocationKindDirectSeattle99999 {
108108
finally {
109109
Remove-AzPeerAsn -Name $asnPeerName -Force
110110
}
111+
}
112+
113+
<#
114+
.SYNOPSIS
115+
GetLocationKindDirectSeattle
116+
#>
117+
function Test-GetLocationKindDirectAmsterdam {
118+
try {
119+
$asn = 65000
120+
$asnPeerName = makePeerAsn $asn
121+
$location = Get-AzPeeringLocation -Kind Direct -DirectPeeringType Cdn -PeeringLocation Amsterdam
122+
Assert-NotNull $location
123+
Assert-True { $location.Count -ge 1 }
124+
}
125+
finally {
126+
Remove-AzPeerAsn -Name $asnPeerName -Force
127+
}
111128
}

src/Peering/Peering.Test/ScenarioTests/PeeringCommon.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ function makePeerAsn($asn)
112112
return $created
113113
}
114114

115+
function removePeerAsn($asn){
116+
$asn | Remove-AzPeerAsn -Force
117+
}
118+
115119
function NewExchangeConnectionV4V6($facilityId, $v4, $v6)
116120
{
117121
#Create some data for the object

0 commit comments

Comments
 (0)