|
| 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 | +########################################################################### Gateway tests ################################################################### |
| 16 | + |
| 17 | +<# |
| 18 | +.SYNOPSIS |
| 19 | + Tests for local network gateway right now |
| 20 | +#> |
| 21 | + |
| 22 | +function Test-LocalNetworkGateway |
| 23 | +{ |
| 24 | + # Setup |
| 25 | + $lngname = getAssetName |
| 26 | + $location="West US" |
| 27 | + |
| 28 | + $subscription = Get-AzureSubscription -Current |
| 29 | + Set-AzureSubscription -SubscriptionId $subscription.SubscriptionId |
| 30 | + |
| 31 | + # Create a local network gateway |
| 32 | + $ipAddr = "1.2.3.4" |
| 33 | + $addrSpace = "10.0.0.0/8" |
| 34 | + New-AzureLocalNetworkGateway -GatewayName $lngname -IpAddress $ipAddr -AddressSpace $addrSpace |
| 35 | + |
| 36 | + # Retrieve a list of local network gateways, and get the one created above by name |
| 37 | + $lnglist = Get-AzureLocalNetworkGateway |
| 38 | + $lng = $lnglist | Where-Object { $_.GatewayName -eq $lngname } |
| 39 | + Assert-AreEqual $lng.IpAddress $ipAddr |
| 40 | + Assert-AreEqual $lng.AddressSpace $addrSpace |
| 41 | + |
| 42 | + # Retrieve the local network gateway by ID |
| 43 | + $lng = Get-AzureLocalNetworkGateway -GatewayId $lng.GatewayId |
| 44 | + Assert-AreEqual $lng.IpAddress $ipAddr |
| 45 | + Assert-AreEqual $lng.AddressSpace $addrSpace |
| 46 | + |
| 47 | + # Delete the local network gateway |
| 48 | + Remove-AzureLocalNetworkGateway -GatewayId $lng.GatewayId |
| 49 | +} |
| 50 | + |
| 51 | +function Test-LocalNetworkGatewayBgp |
| 52 | +{ |
| 53 | +# Setup |
| 54 | + $lngname = getAssetName |
| 55 | + $location="West US" |
| 56 | + |
| 57 | + $subscription = Get-AzureSubscription -Current |
| 58 | + Set-AzureSubscription -SubscriptionId $subscription.SubscriptionId |
| 59 | + |
| 60 | + # Create a local network gateway |
| 61 | + $ipAddr = "1.2.3.4" |
| 62 | + $addrSpace = "10.0.0.0/8" |
| 63 | + $asn = "1234" |
| 64 | + $bgpaddr = "10.0.0.1" |
| 65 | + New-AzureLocalNetworkGateway -GatewayName $lngname -IpAddress $ipAddr -AddressSpace $addrSpace -Asn $asn -BgpPeeringAddress $bgpaddr |
| 66 | + |
| 67 | + # Retrieve a list of local network gateways, and get the one created above by name |
| 68 | + $lnglist = Get-AzureLocalNetworkGateway |
| 69 | + $lng = $lnglist | Where-Object { $_.GatewayName -eq $lngname } |
| 70 | + Assert-AreEqual $lng.IpAddress $ipAddr |
| 71 | + Assert-AreEqual $lng.AddressSpace $addrSpace |
| 72 | + Assert-AreEqual $lng.Asn $asn |
| 73 | + Assert-AreEqual $lng.BgpPeeringAddress $bgpaddr |
| 74 | + |
| 75 | + # Retrieve the local network gateway by ID |
| 76 | + $lng = Get-AzureLocalNetworkGateway -GatewayId $lng.GatewayId |
| 77 | + Assert-AreEqual $lng.IpAddress $ipAddr |
| 78 | + Assert-AreEqual $lng.AddressSpace $addrSpace |
| 79 | + Assert-AreEqual $lng.Asn $asn |
| 80 | + Assert-AreEqual $lng.BgpPeeringAddress $bgpaddr |
| 81 | + |
| 82 | + # Delete the local network gateway |
| 83 | + Remove-AzureLocalNetworkGateway -GatewayId $lng.GatewayId |
| 84 | +} |
0 commit comments