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
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ScenarioTests\NamingValidationTests.cs" />
<Compile Include="ScenarioTests\HubTests.cs" />
<Compile Include="UnitTests\GetHubTests.cs" />
<Compile Include="UnitTests\NewDataFactoryEncryptValueTests.cs" />
Expand Down Expand Up @@ -193,6 +194,9 @@
<None Include="ScenarioTests\DataFactoryGatewayTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\NamingValidationTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\HubTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -259,6 +263,21 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.LinkedServiceTests\TestLinkedServiceWithDataFactoryParameter.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.NamingValidationTests\TestInvalidDataFactoryName.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.NamingValidationTests\TestInvalidHubName.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.NamingValidationTests\TestInvalidPipelineName.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.NamingValidationTests\TestInvalidResourceGroupName.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.NamingValidationTests\TestInvalidTableName.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.TableTests\TestGetTableWithEmptyName.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.DataFactories.Test
{
public class NamingValidationTests : DataFactoriesScenarioTestsBase
{
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestInvalidResourceGroupName()
{
RunPowerShellTest("Test-InvalidResourceGroupName");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestInvalidDataFactoryName()
{
RunPowerShellTest("Test-InvalidDataFactoryName");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestInvalidLinkedServiceName()
{
RunPowerShellTest("Test-InvalidLinkedServiceName");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestInvalidTableName()
{
RunPowerShellTest("Test-InvalidTableName");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestInvalidPipelineName()
{
RunPowerShellTest("Test-InvalidPipelineName");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestInvalidHubName()
{
RunPowerShellTest("Test-InvalidHubName");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

# Make sure the naming error contains the below link to ADF naming rules MSDN page
$invalidNameError = "http://msdn.microsoft.com/en-us/library/dn835027.aspx"

<#
.SYNOPSIS
Test naming restriction support.
#>
function Test-InvalidResourceGroupName
{
$rgName = "adf#$%"
$dfName = "adf"

Assert-ThrowsContains { Get-AzureDataFactory -ResourceGroupName $rgName } $invalidNameError

Assert-ThrowsContains { New-AzureDataFactory -ResourceGroupName $rgName -Name $dfName -Location westus -Force } $invalidNameError

Assert-ThrowsContains { Remove-AzureDataFactory -ResourceGroupName $rgName -Name $dfName -Force } $invalidNameError

Assert-ThrowsContains { Get-AzureDataFactoryLinkedService -ResourceGroupName $rgName -DataFactoryName $dfName} $invalidNameError

Assert-ThrowsContains { New-AzureDataFactoryLinkedService -ResourceGroupName $rgName -DataFactoryName $dfName -Name "ls" -File .\Resources\linkedService.json -Force } $invalidNameError

Assert-ThrowsContains { Remove-AzureDataFactoryLinkedService -ResourceGroupName $rgName -DataFactoryName $dfName -Name "ls" -Force } $invalidNameError

Assert-ThrowsContains { Get-AzureDataFactoryTable -ResourceGroupName $rgName -DataFactoryName $dfName} $invalidNameError

Assert-ThrowsContains { New-AzureDataFactoryTable -ResourceGroupName $rgName -DataFactoryName $dfName -Name "table" -File .\Resources\table.json -Force } $invalidNameError

Assert-ThrowsContains { Remove-AzureDataFactoryTable -ResourceGroupName $rgName -DataFactoryName $dfName -Name "table" -Force } $invalidNameError

Assert-ThrowsContains { Get-AzureDataFactoryPipeline -ResourceGroupName $rgName -DataFactoryName $dfName} $invalidNameError

Assert-ThrowsContains { New-AzureDataFactoryPipeline -ResourceGroupName $rgName -DataFactoryName $dfName -Name "pipeline" -File .\Resources\pipeline.json -Force } $invalidNameError

Assert-ThrowsContains { Remove-AzureDataFactoryPipeline -ResourceGroupName $rgName -DataFactoryName $dfName -Name "pipeline" -Force } $invalidNameError

Assert-ThrowsContains { Get-AzureDataFactoryHub -ResourceGroupName $rgName -DataFactoryName $dfName} $invalidNameError

Assert-ThrowsContains { New-AzureDataFactoryHub -ResourceGroupName $rgName -DataFactoryName $dfName -Name "hub" -File .\Resources\hub.json -Force } $invalidNameError

Assert-ThrowsContains { Remove-AzureDataFactoryHub -ResourceGroupName $rgName -DataFactoryName $dfName -Name "hub" -Force } $invalidNameError

Assert-ThrowsContains { Set-AzureDataFactorySliceStatus -ResourceGroupName $rgName -DataFactoryName $rgName -TableName "table" -StartDateTime "2015-01-01" -Status PendingExecution } $invalidNameError

Assert-ThrowsContains { Suspend-AzureDataFactoryPipeline -ResourceGroupName $rgName -DataFactoryName $rgName -Name "pipeline" -Force } $invalidNameError

Assert-ThrowsContains { Resume-AzureDataFactoryPipeline -ResourceGroupName $rgName -DataFactoryName $rgName -Name "pipeline" -Force } $invalidNameError

Assert-ThrowsContains { Set-AzureDataFactoryPipelineActivePeriod -ResourceGroupName $rgName -DataFactoryName $rgName -PipelineName "pipeline" -StartDateTime "2015-01-01" -Force } $invalidNameError

$password = ConvertTo-SecureString "password" -AsPlainText -Force
Assert-ThrowsContains { New-AzureDataFactoryEncryptValue -ResourceGroupName $rgName -DataFactoryName $dfName -Value $password } $invalidNameError

Assert-ThrowsContains { Save-AzureDataFactoryLog -ResourceGroupName $rgName -DataFactoryName $dfName -Id "id" } $invalidNameError
}

<#
.SYNOPSIS
Test naming restriction support.
#>
function Test-InvalidDataFactoryName
{
Assert-ThrowsContains { Get-AzureDataFactory -ResourceGroupName "adf" -Name "adf_invalidname" } $invalidNameError

Assert-ThrowsContains { Remove-AzureDataFactory -ResourceGroupName "adf" -Name "datafactorynameistolongdatafactorynameistolongdatafactorynameistolongdatafactorynameistolong" -Force } $invalidNameError

Assert-ThrowsContains { New-AzureDataFactory -ResourceGroupName "adf" -Name "adf+invalidname" -Location "westus" -Force } $invalidNameError

$password = ConvertTo-SecureString "password" -AsPlainText -Force
Assert-ThrowsContains { New-AzureDataFactoryEncryptValue -ResourceGroupName "adf" -DataFactoryName "adf+invalidname" -Value $password } $invalidNameError

Assert-ThrowsContains { Save-AzureDataFactoryLog -ResourceGroupName "adf" -DataFactoryName "adf+invalidname" -Id "id" } $invalidNameError
}

<#
.SYNOPSIS
Test naming restriction support.
#>
function Test-InvalidLinkedServiceName
{
Assert-ThrowsContains { Get-AzureDataFactoryLinkedService -ResourceGroupName "adf" -DataFactoryName "adf" -Name "linked.service" } $invalidNameError

Assert-ThrowsContains { New-AzureDataFactoryLinkedService -ResourceGroupName "adf" -DataFactoryName "adf" -Name "linked?service" -File .\Resources\linkedService.json -Force } $invalidNameError

Assert-ThrowsContains { Remove-AzureDataFactoryLinkedService -ResourceGroupName "adf" -DataFactoryName "adf" -Name "linked%service" -Force } $invalidNameError
}

<#
.SYNOPSIS
Test naming restriction support.
#>
function Test-InvalidTableName
{
Assert-ThrowsContains { Get-AzureDataFactoryTable -ResourceGroupName "adf" -DataFactoryName "adf" -Name "table+" } $invalidNameError

Assert-ThrowsContains { New-AzureDataFactoryTable -ResourceGroupName "adf" -DataFactoryName "adf" -Name "table&" -File .\Resources\table.json -Force } $invalidNameError

Assert-ThrowsContains { Remove-AzureDataFactoryTable -ResourceGroupName "adf" -DataFactoryName "adf" -Name "table>" -Force } $invalidNameError

Assert-ThrowsContains { Set-AzureDataFactorySliceStatus -ResourceGroupName "adf" -DataFactoryName "adf" -TableName "table<" -StartDateTime "2015-01-01" -Status PendingExecution } $invalidNameError
}

<#
.SYNOPSIS
Test naming restriction support.
#>
function Test-InvalidPipelineName
{
Assert-ThrowsContains { Get-AzureDataFactoryPipeline -ResourceGroupName "adf" -DataFactoryName "adf" -Name "pipeline&" } $invalidNameError

Assert-ThrowsContains { New-AzureDataFactoryPipeline -ResourceGroupName "adf" -DataFactoryName "adf" -Name "pipeline\\" -File .\Resources\pipeline.json -Force } $invalidNameError

Assert-ThrowsContains { Remove-AzureDataFactoryPipeline -ResourceGroupName "adf" -DataFactoryName "adf" -Name "pipeline<" -Force } $invalidNameError

Assert-ThrowsContains { Suspend-AzureDataFactoryPipeline -ResourceGroupName "adf" -DataFactoryName "adf" -Name "pipeline<" -Force } $invalidNameError

Assert-ThrowsContains { Resume-AzureDataFactoryPipeline -ResourceGroupName "adf" -DataFactoryName "adf" -Name "pipeline<" -Force } $invalidNameError

Assert-ThrowsContains { Set-AzureDataFactoryPipelineActivePeriod -ResourceGroupName "adf" -DataFactoryName "adf" -PipelineName "pipeline<" -StartDateTime "2015-01-01" -Force } $invalidNameError
}

<#
.SYNOPSIS
Test naming restriction support.
#>
function Test-InvalidHubName
{
Assert-ThrowsContains { Get-AzureDataFactoryHub -ResourceGroupName "adf" -DataFactoryName "adf" -Name "hub&" } $invalidNameError

Assert-ThrowsContains { New-AzureDataFactoryHub -ResourceGroupName "adf" -DataFactoryName "adf" -Name "hub\\" -File .\Resources\hub.json -Force } $invalidNameError

Assert-ThrowsContains { Remove-AzureDataFactoryHub -ResourceGroupName "adf" -DataFactoryName "adf" -Name "hub<" -Force } $invalidNameError
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"Entries": [
{
"RequestUri": "/subscriptions/8d88dc98-ab0c-4b80-825b-123b2cf8443c/providers/Microsoft.DataFactory/register?api-version=2014-04-01-preview",
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOGQ4OGRjOTgtYWIwYy00YjgwLTgyNWItMTIzYjJjZjg0NDNjL3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YUZhY3RvcnkvcmVnaXN0ZXI/YXBpLXZlcnNpb249MjAxNC0wNC0wMS1wcmV2aWV3",
"RequestMethod": "POST",
"RequestBody": "",
"RequestHeaders": {
"User-Agent": [
"Microsoft.Azure.Management.Resources.ResourceManagementClient/2.0.0.0"
]
},
"ResponseBody": "{\r\n \"id\": \"/subscriptions/8d88dc98-ab0c-4b80-825b-123b2cf8443c/providers/Microsoft.DataFactory\",\r\n \"namespace\": \"Microsoft.DataFactory\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"dataFactories\",\r\n \"locations\": [\r\n \"West US\"\r\n ],\r\n \"apiVersions\": [\r\n \"2014-05-01-preview\",\r\n \"2014-07-01-preview\",\r\n \"2014-08-01-preview\",\r\n \"2014-09-01-preview\",\r\n \"adfgated1\",\r\n \"adfgated2\",\r\n \"adfgated3\",\r\n \"adfgated4\",\r\n \"adfgated5\",\r\n \"adfgated6\",\r\n \"adfbqupgrade\",\r\n \"2014-04-01\",\r\n \"2014-10-01-preview\",\r\n \"2014-12-01-preview\",\r\n \"2015-01-01-preview\"\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"dataFactories/diagnosticSettings\",\r\n \"locations\": [\r\n \"East US\",\r\n \"East US 2\",\r\n \"North Central US\",\r\n \"North Europe\",\r\n \"West Europe\",\r\n \"Brazil South\",\r\n \"West US\",\r\n \"Central US\",\r\n \"South Central US\",\r\n \"Japan East\",\r\n \"Japan West\",\r\n \"East Asia\",\r\n \"Southeast Asia\"\r\n ],\r\n \"apiVersions\": [\r\n \"2014-04-01\"\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"dataFactories/metricDefinitions\",\r\n \"locations\": [\r\n \"East US\",\r\n \"East US 2\",\r\n \"North Central US\",\r\n \"North Europe\",\r\n \"West Europe\",\r\n \"Brazil South\",\r\n \"West US\",\r\n \"Central US\",\r\n \"South Central US\",\r\n \"Japan East\",\r\n \"Japan West\",\r\n \"East Asia\",\r\n \"Southeast Asia\"\r\n ],\r\n \"apiVersions\": [\r\n \"2014-04-01\"\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"checkDataFactoryNameAvailability\",\r\n \"locations\": [],\r\n \"apiVersions\": [\r\n \"2014-09-01-preview\"\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"activityTypes\",\r\n \"locations\": [],\r\n \"apiVersions\": [\r\n \"2015-01-01-preview\"\r\n ]\r\n }\r\n ],\r\n \"registrationState\": \"Registering\"\r\n}",
"ResponseHeaders": {
"Content-Length": [
"1242"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Expires": [
"-1"
],
"Pragma": [
"no-cache"
],
"x-ms-ratelimit-remaining-subscription-writes": [
"1195"
],
"x-ms-request-id": [
"83732d58-3733-443b-9848-f0e46c59a881"
],
"x-ms-correlation-request-id": [
"83732d58-3733-443b-9848-f0e46c59a881"
],
"x-ms-routing-request-id": [
"CENTRALUS:20150115T012300Z:83732d58-3733-443b-9848-f0e46c59a881"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains"
],
"Cache-Control": [
"no-cache"
],
"Date": [
"Thu, 15 Jan 2015 01:23:00 GMT"
]
},
"StatusCode": 200
}
],
"Names": {},
"Variables": {
"SubscriptionId": "8d88dc98-ab0c-4b80-825b-123b2cf8443c"
}
}
Loading