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
+ }
0 commit comments