Skip to content
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
56 changes: 56 additions & 0 deletions src/Synapse/Synapse.Test/ScenarioTests/FirewallTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.Synapse.Test.ScenarioTests
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using ServiceManagement.Common.Models;
using Xunit;

public class FirewallTests : SynapseTestBase
{
public XunitTracingInterceptor _logger;

public FirewallTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSynapseFirewall()
{
string testResourceGroupName = SynapseTestBase.TestResourceGroupName;
if (string.IsNullOrEmpty(testResourceGroupName))
{
testResourceGroupName = nameof(TestResourceGroupName);
}

string testWorkspaceName = SynapseTestBase.TestWorkspaceName;
if (string.IsNullOrEmpty(testWorkspaceName))
{
testWorkspaceName = nameof(TestWorkspaceName);
}

SynapseTestBase.NewInstance.RunPsTest(
_logger,
string.Format(
"Test-SynapseFirewall -resourceGroupName '{0}' -workspaceName '{1}'",
"testResourceGroupName",
"testWorkspaceName"
));
}
}
}
56 changes: 56 additions & 0 deletions src/Synapse/Synapse.Test/ScenarioTests/FirewallTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<#
.SYNOPSIS
Tests Synapse Firewall Lifecycle (Create, Update, Get, List, Delete).
#>
function Test-SynapseFirewall
{
param
(
$resourceGroupName = (Get-ResourceGroupName),
$workspaceName = (Get-SynapseWorkspaceName)
)

try
{
$resourceGroupName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("resourceGroupName", $resourceGroupName)
$workspaceName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("workspaceName", $workspaceName)
$workspace = Get-AzSynapseWorkspace -resourceGroupName $resourceGroupName -Name $workspaceName
$firewallRuleName = "originRuleName"
$StartIpAddress = "0.0.0.0"
$NewStartIpAddress = "10.0.0.0"
$EndIpAddress = "255.255.255.255"
$NewEndIpAddress = "255.0.0.0"
$SucessState = "Succeeded"

# create firewall
$firewallCreated = New-AzSynapseFirewallRule -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $firewallRuleName -StartIpAddress $StartIpAddress -EndIpAddress $EndIpAddress

Assert-AreEqual $StartIpAddress $firewallCreated.StartIpAddress
Assert-AreEqual $EndIpAddress $firewallCreated.EndIpAddress

# Wait for 10 seconds for the create completion
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(10000)

# List firewall
$firewallList = Get-AzSynapseFirewallRule -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName
Assert-NotNull $firewallList

# Get firewall
$firewallGet = Get-AzSynapseFirewallRule -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $firewallRuleName
Assert-AreEqual $SucessState $firewallGet.ProvisioningState
Assert-AreEqual $StartIpAddress $firewallGet.StartIpAddress
Assert-AreEqual $EndIpAddress $firewallGet.EndIpAddress

# Update firewall
$firewallUpdate = Update-AzSynapseFirewallRule -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $firewallRuleName -StartIpAddress $NewStartIpAddress -EndIpAddress $NewEndIpAddress
Assert-AreEqual $NewStartIpAddress $firewallUpdate.StartIpAddress
Assert-AreEqual $NewEndIpAddress $firewallUpdate.EndIpAddress

# Delete firewall
Assert-True {Remove-AzSynapseFirewallRule -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $firewallRuleName -PassThru} "Remove firewall rule failed"
}
finally
{
# cleanup the firewallRuleName created by test code.
}
}
1 change: 1 addition & 0 deletions src/Synapse/Synapse.Test/ScenarioTests/SparkJobTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void TestSynapseSparkJob()
_logger,
string.Format(
"Test-SynapseSparkJob -resourceGroupname '{0}' -workspaceName '{1}' -sparkPoolName {2}",
resourceGroupName,
testWorkspaceName,
testSparkPoolName));
}
Expand Down
Loading