Skip to content

Fixed bug and added more tests #10257

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
Oct 28, 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
Expand Up @@ -15,7 +15,6 @@
namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
{
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Microsoft.WindowsAzure.Commands.ScenarioTest;

using Xunit;
Expand Down Expand Up @@ -123,6 +122,66 @@ public void TestNewDirectConnectionWrongV6()
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWrongV6");
}

/// <summary>
/// The test new direct connection with microsoft ip address
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithMicrosoftSession()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSession");
}

/// <summary>
/// The test new direct connection with microsoft ip address
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithMicrosoftSessionWithPeeringService()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSessionWithPeeringService");
}

/// <summary>
/// The test new direct connection with microsoft ip address
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithMicrosoftSessionInvalidV4()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSessionInvalidV4");
}

/// <summary>
/// The test new direct connection with microsoft ip address
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithMicrosoftSessionInvalidV6()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSessionInvalidV6");
}

/// <summary>
/// The test new direct connection with microsoft ip address
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithNoPeeringFacility()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithNoPeeringFacility");
}

/// <summary>
/// The test new direct connection with microsoft ip address
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithNoBgpSession()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithNoBgpSession");
}

/// <summary>
/// The test new direct connection with microsoft ip address
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ NewDirectConnectionWithV4V6
#>
function Test-NewDirectConnectionWithV4V6
{
$asn = makePeerAsn 65000
#Hard Coded locations becuase of limitations in locations
$kind = isDirect $true;
$loc = "Los Angeles"
Expand All @@ -43,13 +44,18 @@ function Test-NewDirectConnectionWithV4V6
Assert-AreEqual $sessionv6 $createdConnection.BgpSession.SessionPrefixV6
Assert-AreEqual $false $createdConnection.UseForPeeringService
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider

removePeerAsn $asn


}
<#
.SYNOPSIS
NewDirectConnectionWithV6 v6 should be null
#>
function Test-NewDirectConnectionWithV4
{
$asn = makePeerAsn 65000
#Hard Coded locations becuase of limitations in locations
$kind = isDirect $true;
$loc = "Amsterdam"
Expand All @@ -75,13 +81,17 @@ function Test-NewDirectConnectionWithV4
Assert-Null $createdConnection.BgpSession.SessionPrefixV6
Assert-AreEqual $false $createdConnection.UseForPeeringService
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider

removePeerAsn $asn

}
<#
.SYNOPSIS
NewDirectConnectionWithV6 v4 should be Null
#>
function Test-NewDirectConnectionWithV6
{
$asn = makePeerAsn 65000
#Hard Coded locations becuase of limitations in locations
$kind = isDirect $true;
$loc = "Los Angeles"
Expand All @@ -106,13 +116,17 @@ function Test-NewDirectConnectionWithV6
Assert-AreEqual $sessionv6 $createdConnection.BgpSession.SessionPrefixV6
Assert-AreEqual $false $createdConnection.UseForPeeringService
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider

removePeerAsn $asn

}
<#
.SYNOPSIS
NewDirectConnectionNoSession should pass with null value
#>
function Test-NewDirectConnectionNoSession
{
$asn = makePeerAsn 65000
#Hard Coded locations becuase of limitations in locations
$kind = isDirect $true;
$loc = "Ashburn"
Expand All @@ -136,13 +150,17 @@ function Test-NewDirectConnectionNoSession
Assert-AreEqual $facilityId $createdConnection.PeeringDBFacilityId
Assert-Null $createdConnection.BgpSession
Assert-AreEqual $true $createdConnection.UseForPeeringService
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider}
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider

removePeerAsn $asn
}
<#
.SYNOPSIS
NewDirectConnectionWithV6 should fail with high BandwidthInMbps message
#>
function Test-NewDirectConnectionHighBandwidth
{
$asn = makePeerAsn 65000
#Hard Coded locations becuase of limitations in locations
$kind = isDirect $true;
$loc = "Los Angeles"
Expand All @@ -165,13 +183,17 @@ function Test-NewDirectConnectionHighBandwidth
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
#create Connection
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"

removePeerAsn $asn

}
<#
.SYNOPSIS
NewDirectConnectionWithV6 should fail with low BandwidthInMbps message
#>
function Test-NewDirectConnectionLowBandwidth
{
$asn = makePeerAsn 65000
#Hard Coded locations becuase of limitations in locations
$kind = isDirect $true;
$loc = "Ashburn"
Expand All @@ -192,14 +214,18 @@ function Test-NewDirectConnectionLowBandwidth
$maxv6 = maxAdvertisedIpv6
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
#create Connection
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"
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"

removePeerAsn $asn

}
<#
.SYNOPSIS
NewDirectConnectionWithV6 should fail with wrong IP
#>
function Test-NewDirectConnectionWrongV6
{
$asn = makePeerAsn 65000
#Hard Coded locations becuase of limitations in locations
$kind = isDirect $true;
$loc = "Ashburn"
Expand All @@ -220,13 +246,17 @@ function Test-NewDirectConnectionWrongV6
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
#create Connection
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV6 $wrongv6 -MaxPrefixesAdvertisedIPv6 $maxv6 -BandwidthInMbps $bandwidth -MD5AuthenticationKey $md5} "Invalid Prefix: $wrongv6, must be"

removePeerAsn $asn

}
<#
.SYNOPSIS
NewDirectConnectionWithV4 with fail on wrong IP
#>
function Test-NewDirectConnectionWrongV4
{
$asn = makePeerAsn 65000
#Hard Coded locations becuase of limitations in locations
$kind = isDirect $true;
$loc = "Ashburn"
Expand All @@ -247,6 +277,9 @@ function Test-NewDirectConnectionWrongV4
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
#create Connection
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV4 $wrongv4 -MaxPrefixesAdvertisedIPv4 $maxv4 -BandwidthInMbps $bandwidth -MD5AuthenticationKey $md5.ToString} "Invalid Prefix: $wrongv4, must be "

removePeerAsn $asn

}

<#
Expand All @@ -255,6 +288,7 @@ Microsoft Provided IP address
#>
function Test-NewDirectConnectionWithMicrosoftIpProvidedAddress
{
$asn = makePeerAsn 65000
#Hard Coded locations becuase of limitations in locations
$kind = isDirect $true;
$loc = "Los Angeles"
Expand All @@ -270,4 +304,112 @@ function Test-NewDirectConnectionWithMicrosoftIpProvidedAddress
Assert-AreEqual $null $createdConnection.BgpSession
Assert-AreEqual $true $createdConnection.UseForPeeringService
Assert-AreEqual "Microsoft" $createdConnection.SessionAddressProvider
removePeerAsn $asn

}

<#
.SYNOPSIS
Microsoft Provided IP address
#>
function Test-NewDirectConnectionWithNoPeeringFacility
{
$asn = makePeerAsn 65000
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId} "Missing an argument for parameter 'PeeringDBFacilityId'"
removePeerAsn $asn
}

<#
.SYNOPSIS
NoBgpSession
#>
function Test-NewDirectConnectionWithNoBgpSession
{
$asn = makePeerAsn 65000
$peeringLocation = Get-AzPeeringLocation -Kind Direct
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
$bandwidth = getBandwidth
$connection = New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth
Assert-AreEqual $facilityId $connection.PeeringDBFacilityId
Assert-AreEqual $bandwidth $connection.BandwidthInMbps
Assert-AreEqual "Peer" $connection.SessionAddressProvider

removePeerAsn $asn

}

<#
.SYNOPSIS
NoBgpSession
#>
function Test-NewDirectConnectionWithMicrosoftSession
{
$asn = makePeerAsn 65000
$peeringLocation = Get-AzPeeringLocation -Kind Direct
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
$bandwidth = getBandwidth
$connection = New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth -MicrosoftProvidedIPAddress
Assert-AreEqual $facilityId $connection.PeeringDBFacilityId
Assert-AreEqual $bandwidth $connection.BandwidthInMbps
Assert-AreEqual "Microsoft" $connection.SessionAddressProvider
Assert-False {$connection.UseForPeeringService}

removePeerAsn $asn

}
<#
.SYNOPSIS
NoBgpSession
#>
function Test-NewDirectConnectionWithMicrosoftSessionWithPeeringService
{
$asn = makePeerAsn 65000
$peeringLocation = Get-AzPeeringLocation -Kind Direct
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
$bandwidth = getBandwidth
$connection = New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth -MicrosoftProvidedIPAddress -UseForPeeringService
Assert-AreEqual $facilityId $connection.PeeringDBFacilityId
Assert-AreEqual $bandwidth $connection.BandwidthInMbps
Assert-AreEqual "Microsoft" $connection.SessionAddressProvider
Assert-True {$connection.UseForPeeringService}

removePeerAsn $asn

}

<#
.SYNOPSIS
NoBgpSession
#>
function Test-NewDirectConnectionWithMicrosoftSessionInvalidV4
{
$asn = makePeerAsn 65000
$peeringLocation = Get-AzPeeringLocation -Kind Direct
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
$bandwidth = getBandwidth
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth -SessionPrefixV4 4.4.4.4 -MicrosoftProvidedIPAddress} "Parameter set cannot be resolved using the specified named parameters"

removePeerAsn $asn

}

<#
.SYNOPSIS
NoBgpSession
#>
function Test-NewDirectConnectionWithMicrosoftSessionInvalidV6
{
$asn = makePeerAsn 65000
$peeringLocation = Get-AzPeeringLocation -Kind Direct
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
$bandwidth = getBandwidth
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth -SessionPrefixV6 "fe01::40ef" -MicrosoftProvidedIPAddress} "Parameter set cannot be resolved using the specified named parameters"

removePeerAsn $asn

}
10 changes: 10 additions & 0 deletions src/Peering/Peering.Test/ScenarioTests/GetLocationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,15 @@ public void TestGetLocationKindDirectSeattle99999()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectSeattle99999");
}

/// <summary>
/// The test get location kind direct ams
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLocationKindDirectAmsterdam()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectAmsterdam");
}
}
}
17 changes: 17 additions & 0 deletions src/Peering/Peering.Test/ScenarioTests/GetLocationTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,21 @@ function Test-GetLocationKindDirectSeattle99999 {
finally {
Remove-AzPeerAsn -Name $asnPeerName -Force
}
}

<#
.SYNOPSIS
GetLocationKindDirectSeattle
#>
function Test-GetLocationKindDirectAmsterdam {
try {
$asn = 65000
$asnPeerName = makePeerAsn $asn
$location = Get-AzPeeringLocation -Kind Direct -DirectPeeringType Cdn -PeeringLocation Amsterdam
Assert-NotNull $location
Assert-True { $location.Count -ge 1 }
}
finally {
Remove-AzPeerAsn -Name $asnPeerName -Force
}
}
4 changes: 4 additions & 0 deletions src/Peering/Peering.Test/ScenarioTests/PeeringCommon.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ function makePeerAsn($asn)
return $created
}

function removePeerAsn($asn){
$asn | Remove-AzPeerAsn -Force
}

function NewExchangeConnectionV4V6($facilityId, $v4, $v6)
{
#Create some data for the object
Expand Down
Loading