Skip to content

Commit b14707a

Browse files
committed
Merge pull request Azure#24 from huangpf/crp2
Crp2
2 parents ecce389 + e26389e commit b14707a

File tree

16 files changed

+1022
-6658
lines changed

16 files changed

+1022
-6658
lines changed

setup/azurecmdfiles.wxi

Lines changed: 0 additions & 264 deletions
Large diffs are not rendered by default.

src/AzurePowershell.sln

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ScenarioTest", "Co
3232
EndProjectSection
3333
EndProject
3434
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ServiceManagement", "ServiceManagement\Compute\Commands.ServiceManagement\Commands.ServiceManagement.csproj", "{E1CA72BA-8374-45F6-904D-FD34ECDF5B6F}"
35+
ProjectSection(ProjectDependencies) = postProject
36+
{C60342B1-47D3-4A0E-8081-9B97CE60B7AF} = {C60342B1-47D3-4A0E-8081-9B97CE60B7AF}
37+
EndProjectSection
3538
EndProject
3639
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ServiceManagement.Test", "ServiceManagement\Compute\Commands.ServiceManagement.Test\Commands.ServiceManagement.Test.csproj", "{58A78F29-8C0C-4A5E-893E-3953C0F29C8A}"
3740
ProjectSection(ProjectDependencies) = postProject
@@ -431,12 +434,11 @@ Global
431434
{4AE5705F-62CF-461D-B72E-DD9DCD9B3609} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
432435
{F4ABAD68-64A5-4B23-B09C-42559A7524DE} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
433436
{FDB897BD-FCB4-44A1-8D66-AC99F22EC737} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
434-
{080B0477-7E52-4455-90AB-23BD13D1B1CE} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
435-
{A415F75B-EB6A-49A6-934E-5BA71B83D6EB} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
436437
{9FFC40CC-A341-4D0C-A25D-DC6B78EF6C94} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
437438
{080B0477-7E52-4455-90AB-23BD13D1B1CE} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
438-
{A2DF4FE5-46EE-43E2-B246-E5CDDD47B752} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
439+
{A415F75B-EB6A-49A6-934E-5BA71B83D6EB} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
439440
{7E6683BE-ECFF-4709-89EB-1325E9E70512} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
441+
{A2DF4FE5-46EE-43E2-B246-E5CDDD47B752} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
440442
{37C44181-3F1B-4ABD-8089-26DFAB4B6BA8} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
441443
EndGlobalSection
442444
EndGlobal

src/ResourceManager/DataFactories/Commands.DataFactories.Test/Commands.DataFactories.Test.csproj

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
</Reference>
141141
</ItemGroup>
142142
<ItemGroup>
143+
<Compile Include="ScenarioTests\NamingValidationTests.cs" />
143144
<Compile Include="ScenarioTests\HubTests.cs" />
144145
<Compile Include="UnitTests\GetHubTests.cs" />
145146
<Compile Include="UnitTests\NewDataFactoryEncryptValueTests.cs" />
@@ -193,6 +194,9 @@
193194
<None Include="ScenarioTests\DataFactoryGatewayTests.ps1">
194195
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
195196
</None>
197+
<None Include="ScenarioTests\NamingValidationTests.ps1">
198+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
199+
</None>
196200
<None Include="ScenarioTests\HubTests.ps1">
197201
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
198202
</None>
@@ -259,6 +263,21 @@
259263
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.LinkedServiceTests\TestLinkedServiceWithDataFactoryParameter.json">
260264
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
261265
</None>
266+
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.NamingValidationTests\TestInvalidDataFactoryName.json">
267+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
268+
</None>
269+
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.NamingValidationTests\TestInvalidHubName.json">
270+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
271+
</None>
272+
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.NamingValidationTests\TestInvalidPipelineName.json">
273+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
274+
</None>
275+
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.NamingValidationTests\TestInvalidResourceGroupName.json">
276+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
277+
</None>
278+
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.NamingValidationTests\TestInvalidTableName.json">
279+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
280+
</None>
262281
<None Include="SessionRecords\Microsoft.Azure.Commands.DataFactories.Test.TableTests\TestGetTableWithEmptyName.json">
263282
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
264283
</None>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.Commands.DataFactories.Test
19+
{
20+
public class NamingValidationTests : DataFactoriesScenarioTestsBase
21+
{
22+
[Fact]
23+
[Trait(Category.AcceptanceType, Category.CheckIn)]
24+
public void TestInvalidResourceGroupName()
25+
{
26+
RunPowerShellTest("Test-InvalidResourceGroupName");
27+
}
28+
29+
[Fact]
30+
[Trait(Category.AcceptanceType, Category.CheckIn)]
31+
public void TestInvalidDataFactoryName()
32+
{
33+
RunPowerShellTest("Test-InvalidDataFactoryName");
34+
}
35+
36+
[Fact]
37+
[Trait(Category.AcceptanceType, Category.CheckIn)]
38+
public void TestInvalidLinkedServiceName()
39+
{
40+
RunPowerShellTest("Test-InvalidLinkedServiceName");
41+
}
42+
43+
[Fact]
44+
[Trait(Category.AcceptanceType, Category.CheckIn)]
45+
public void TestInvalidTableName()
46+
{
47+
RunPowerShellTest("Test-InvalidTableName");
48+
}
49+
50+
[Fact]
51+
[Trait(Category.AcceptanceType, Category.CheckIn)]
52+
public void TestInvalidPipelineName()
53+
{
54+
RunPowerShellTest("Test-InvalidPipelineName");
55+
}
56+
57+
[Fact]
58+
[Trait(Category.AcceptanceType, Category.CheckIn)]
59+
public void TestInvalidHubName()
60+
{
61+
RunPowerShellTest("Test-InvalidHubName");
62+
}
63+
}
64+
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
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+
# Make sure the naming error contains the below link to ADF naming rules MSDN page
16+
$invalidNameError = "http://msdn.microsoft.com/en-us/library/dn835027.aspx"
17+
18+
<#
19+
.SYNOPSIS
20+
Test naming restriction support.
21+
#>
22+
function Test-InvalidResourceGroupName
23+
{
24+
$rgName = "adf#$%"
25+
$dfName = "adf"
26+
27+
Assert-ThrowsContains { Get-AzureDataFactory -ResourceGroupName $rgName } $invalidNameError
28+
29+
Assert-ThrowsContains { New-AzureDataFactory -ResourceGroupName $rgName -Name $dfName -Location westus -Force } $invalidNameError
30+
31+
Assert-ThrowsContains { Remove-AzureDataFactory -ResourceGroupName $rgName -Name $dfName -Force } $invalidNameError
32+
33+
Assert-ThrowsContains { Get-AzureDataFactoryLinkedService -ResourceGroupName $rgName -DataFactoryName $dfName} $invalidNameError
34+
35+
Assert-ThrowsContains { New-AzureDataFactoryLinkedService -ResourceGroupName $rgName -DataFactoryName $dfName -Name "ls" -File .\Resources\linkedService.json -Force } $invalidNameError
36+
37+
Assert-ThrowsContains { Remove-AzureDataFactoryLinkedService -ResourceGroupName $rgName -DataFactoryName $dfName -Name "ls" -Force } $invalidNameError
38+
39+
Assert-ThrowsContains { Get-AzureDataFactoryTable -ResourceGroupName $rgName -DataFactoryName $dfName} $invalidNameError
40+
41+
Assert-ThrowsContains { New-AzureDataFactoryTable -ResourceGroupName $rgName -DataFactoryName $dfName -Name "table" -File .\Resources\table.json -Force } $invalidNameError
42+
43+
Assert-ThrowsContains { Remove-AzureDataFactoryTable -ResourceGroupName $rgName -DataFactoryName $dfName -Name "table" -Force } $invalidNameError
44+
45+
Assert-ThrowsContains { Get-AzureDataFactoryPipeline -ResourceGroupName $rgName -DataFactoryName $dfName} $invalidNameError
46+
47+
Assert-ThrowsContains { New-AzureDataFactoryPipeline -ResourceGroupName $rgName -DataFactoryName $dfName -Name "pipeline" -File .\Resources\pipeline.json -Force } $invalidNameError
48+
49+
Assert-ThrowsContains { Remove-AzureDataFactoryPipeline -ResourceGroupName $rgName -DataFactoryName $dfName -Name "pipeline" -Force } $invalidNameError
50+
51+
Assert-ThrowsContains { Get-AzureDataFactoryHub -ResourceGroupName $rgName -DataFactoryName $dfName} $invalidNameError
52+
53+
Assert-ThrowsContains { New-AzureDataFactoryHub -ResourceGroupName $rgName -DataFactoryName $dfName -Name "hub" -File .\Resources\hub.json -Force } $invalidNameError
54+
55+
Assert-ThrowsContains { Remove-AzureDataFactoryHub -ResourceGroupName $rgName -DataFactoryName $dfName -Name "hub" -Force } $invalidNameError
56+
57+
Assert-ThrowsContains { Set-AzureDataFactorySliceStatus -ResourceGroupName $rgName -DataFactoryName $rgName -TableName "table" -StartDateTime "2015-01-01" -Status PendingExecution } $invalidNameError
58+
59+
Assert-ThrowsContains { Suspend-AzureDataFactoryPipeline -ResourceGroupName $rgName -DataFactoryName $rgName -Name "pipeline" -Force } $invalidNameError
60+
61+
Assert-ThrowsContains { Resume-AzureDataFactoryPipeline -ResourceGroupName $rgName -DataFactoryName $rgName -Name "pipeline" -Force } $invalidNameError
62+
63+
Assert-ThrowsContains { Set-AzureDataFactoryPipelineActivePeriod -ResourceGroupName $rgName -DataFactoryName $rgName -PipelineName "pipeline" -StartDateTime "2015-01-01" -Force } $invalidNameError
64+
65+
$password = ConvertTo-SecureString "password" -AsPlainText -Force
66+
Assert-ThrowsContains { New-AzureDataFactoryEncryptValue -ResourceGroupName $rgName -DataFactoryName $dfName -Value $password } $invalidNameError
67+
68+
Assert-ThrowsContains { Save-AzureDataFactoryLog -ResourceGroupName $rgName -DataFactoryName $dfName -Id "id" } $invalidNameError
69+
}
70+
71+
<#
72+
.SYNOPSIS
73+
Test naming restriction support.
74+
#>
75+
function Test-InvalidDataFactoryName
76+
{
77+
Assert-ThrowsContains { Get-AzureDataFactory -ResourceGroupName "adf" -Name "adf_invalidname" } $invalidNameError
78+
79+
Assert-ThrowsContains { Remove-AzureDataFactory -ResourceGroupName "adf" -Name "datafactorynameistolongdatafactorynameistolongdatafactorynameistolongdatafactorynameistolong" -Force } $invalidNameError
80+
81+
Assert-ThrowsContains { New-AzureDataFactory -ResourceGroupName "adf" -Name "adf+invalidname" -Location "westus" -Force } $invalidNameError
82+
83+
$password = ConvertTo-SecureString "password" -AsPlainText -Force
84+
Assert-ThrowsContains { New-AzureDataFactoryEncryptValue -ResourceGroupName "adf" -DataFactoryName "adf+invalidname" -Value $password } $invalidNameError
85+
86+
Assert-ThrowsContains { Save-AzureDataFactoryLog -ResourceGroupName "adf" -DataFactoryName "adf+invalidname" -Id "id" } $invalidNameError
87+
}
88+
89+
<#
90+
.SYNOPSIS
91+
Test naming restriction support.
92+
#>
93+
function Test-InvalidLinkedServiceName
94+
{
95+
Assert-ThrowsContains { Get-AzureDataFactoryLinkedService -ResourceGroupName "adf" -DataFactoryName "adf" -Name "linked.service" } $invalidNameError
96+
97+
Assert-ThrowsContains { New-AzureDataFactoryLinkedService -ResourceGroupName "adf" -DataFactoryName "adf" -Name "linked?service" -File .\Resources\linkedService.json -Force } $invalidNameError
98+
99+
Assert-ThrowsContains { Remove-AzureDataFactoryLinkedService -ResourceGroupName "adf" -DataFactoryName "adf" -Name "linked%service" -Force } $invalidNameError
100+
}
101+
102+
<#
103+
.SYNOPSIS
104+
Test naming restriction support.
105+
#>
106+
function Test-InvalidTableName
107+
{
108+
Assert-ThrowsContains { Get-AzureDataFactoryTable -ResourceGroupName "adf" -DataFactoryName "adf" -Name "table+" } $invalidNameError
109+
110+
Assert-ThrowsContains { New-AzureDataFactoryTable -ResourceGroupName "adf" -DataFactoryName "adf" -Name "table&" -File .\Resources\table.json -Force } $invalidNameError
111+
112+
Assert-ThrowsContains { Remove-AzureDataFactoryTable -ResourceGroupName "adf" -DataFactoryName "adf" -Name "table>" -Force } $invalidNameError
113+
114+
Assert-ThrowsContains { Set-AzureDataFactorySliceStatus -ResourceGroupName "adf" -DataFactoryName "adf" -TableName "table<" -StartDateTime "2015-01-01" -Status PendingExecution } $invalidNameError
115+
}
116+
117+
<#
118+
.SYNOPSIS
119+
Test naming restriction support.
120+
#>
121+
function Test-InvalidPipelineName
122+
{
123+
Assert-ThrowsContains { Get-AzureDataFactoryPipeline -ResourceGroupName "adf" -DataFactoryName "adf" -Name "pipeline&" } $invalidNameError
124+
125+
Assert-ThrowsContains { New-AzureDataFactoryPipeline -ResourceGroupName "adf" -DataFactoryName "adf" -Name "pipeline\\" -File .\Resources\pipeline.json -Force } $invalidNameError
126+
127+
Assert-ThrowsContains { Remove-AzureDataFactoryPipeline -ResourceGroupName "adf" -DataFactoryName "adf" -Name "pipeline<" -Force } $invalidNameError
128+
129+
Assert-ThrowsContains { Suspend-AzureDataFactoryPipeline -ResourceGroupName "adf" -DataFactoryName "adf" -Name "pipeline<" -Force } $invalidNameError
130+
131+
Assert-ThrowsContains { Resume-AzureDataFactoryPipeline -ResourceGroupName "adf" -DataFactoryName "adf" -Name "pipeline<" -Force } $invalidNameError
132+
133+
Assert-ThrowsContains { Set-AzureDataFactoryPipelineActivePeriod -ResourceGroupName "adf" -DataFactoryName "adf" -PipelineName "pipeline<" -StartDateTime "2015-01-01" -Force } $invalidNameError
134+
}
135+
136+
<#
137+
.SYNOPSIS
138+
Test naming restriction support.
139+
#>
140+
function Test-InvalidHubName
141+
{
142+
Assert-ThrowsContains { Get-AzureDataFactoryHub -ResourceGroupName "adf" -DataFactoryName "adf" -Name "hub&" } $invalidNameError
143+
144+
Assert-ThrowsContains { New-AzureDataFactoryHub -ResourceGroupName "adf" -DataFactoryName "adf" -Name "hub\\" -File .\Resources\hub.json -Force } $invalidNameError
145+
146+
Assert-ThrowsContains { Remove-AzureDataFactoryHub -ResourceGroupName "adf" -DataFactoryName "adf" -Name "hub<" -Force } $invalidNameError
147+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/subscriptions/8d88dc98-ab0c-4b80-825b-123b2cf8443c/providers/Microsoft.DataFactory/register?api-version=2014-04-01-preview",
5+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOGQ4OGRjOTgtYWIwYy00YjgwLTgyNWItMTIzYjJjZjg0NDNjL3Byb3ZpZGVycy9NaWNyb3NvZnQuRGF0YUZhY3RvcnkvcmVnaXN0ZXI/YXBpLXZlcnNpb249MjAxNC0wNC0wMS1wcmV2aWV3",
6+
"RequestMethod": "POST",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"User-Agent": [
10+
"Microsoft.Azure.Management.Resources.ResourceManagementClient/2.0.0.0"
11+
]
12+
},
13+
"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}",
14+
"ResponseHeaders": {
15+
"Content-Length": [
16+
"1242"
17+
],
18+
"Content-Type": [
19+
"application/json; charset=utf-8"
20+
],
21+
"Expires": [
22+
"-1"
23+
],
24+
"Pragma": [
25+
"no-cache"
26+
],
27+
"x-ms-ratelimit-remaining-subscription-writes": [
28+
"1195"
29+
],
30+
"x-ms-request-id": [
31+
"83732d58-3733-443b-9848-f0e46c59a881"
32+
],
33+
"x-ms-correlation-request-id": [
34+
"83732d58-3733-443b-9848-f0e46c59a881"
35+
],
36+
"x-ms-routing-request-id": [
37+
"CENTRALUS:20150115T012300Z:83732d58-3733-443b-9848-f0e46c59a881"
38+
],
39+
"Strict-Transport-Security": [
40+
"max-age=31536000; includeSubDomains"
41+
],
42+
"Cache-Control": [
43+
"no-cache"
44+
],
45+
"Date": [
46+
"Thu, 15 Jan 2015 01:23:00 GMT"
47+
]
48+
},
49+
"StatusCode": 200
50+
}
51+
],
52+
"Names": {},
53+
"Variables": {
54+
"SubscriptionId": "8d88dc98-ab0c-4b80-825b-123b2cf8443c"
55+
}
56+
}

0 commit comments

Comments
 (0)