|
59 | 59 | IntegerItemKeyValue = 'Content-Type' |
60 | 60 | IntegerItemPropertyName = 'Sizelimit' |
61 | 61 | IntegerItemPropertyValue = [string](Get-Random -Minimum 11 -Maximum 100) |
| 62 | + SingleItemFilter = 'system.webServer/security/requestFiltering' |
| 63 | + SingleItemCollectionName = 'hiddenSegments' |
| 64 | + SingleItemKeyName = '*' |
| 65 | + SingleItemKeyValue = 'appsettings.json' |
| 66 | + SingleItemPropertyName = 'segment' |
| 67 | + SingleItemPropertyValue = 'appsettings.json' |
62 | 68 | } |
63 | 69 | ) |
64 | 70 | } |
|
78 | 84 | $integerItemKeyValue = $ConfigurationData.AllNodes.IntegerItemKeyValue |
79 | 85 | $integerItemPropertyName = $ConfigurationData.AllNodes.IntegerItemPropertyName |
80 | 86 | $integerItemPropertyValue = $ConfigurationData.AllNodes.IntegerItemPropertyValue |
| 87 | + $singleItemFilter = $ConfigurationData.AllNodes.SingleItemFilter |
| 88 | + $singleItemCollectionName = $ConfigurationData.AllNodes.SingleItemCollectionName |
| 89 | + $singleItemKeyName = $ConfigurationData.AllNodes.SingleItemKeyName |
| 90 | + $singleItemKeyValue = $ConfigurationData.AllNodes.SingleItemKeyValue |
| 91 | + $singleItemPropertyName = $ConfigurationData.AllNodes.SingleItemPropertyName |
| 92 | + $singleItemPropertyValue = $ConfigurationData.AllNodes.SingleItemPropertyValue |
81 | 93 |
|
82 | 94 | $startDscConfigurationParameters = @{ |
83 | 95 | Path = $TestDrive |
|
89 | 101 |
|
90 | 102 | $filterValue = "$($filter)/$($collectionName)/$($itemName)[@$($itemKeyName)='$($itemKeyValue)']/@$itemPropertyName" |
91 | 103 | $integerFilterValue = "$($integerFilter)/$($integerCollectionName)/$($itemName)[@$($integerItemKeyName)='$($integerItemKeyValue)']/@$integerItemPropertyName" |
| 104 | + $singleItemFilterValue = "$($singleItemFilter)/$($singleItemCollectionName)/$($itemName)[@$($singleItemKeyName)='$($singleItemKeyValue)']/@$singleItemPropertyName" |
92 | 105 |
|
93 | 106 | Context 'When Adding Collection item' { |
94 | 107 | It 'Should compile and apply the MOF without throwing' { |
|
183 | 196 | } |
184 | 197 | } |
185 | 198 |
|
| 199 | + Context 'When Adding Single Collection item' { |
| 200 | + It 'Should compile and apply the MOF without throwing' { |
| 201 | + { |
| 202 | + & "$($script:dscResourceName)_SingleItemAdd" -OutputPath $TestDrive -ConfigurationData $configurationData |
| 203 | + Start-DscConfiguration @startDscConfigurationParameters |
| 204 | + } | Should -Not -Throw |
| 205 | + } |
| 206 | + |
| 207 | + It 'Should be able to call Get-DscConfiguration without throwing' { |
| 208 | + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw |
| 209 | + } |
| 210 | + |
| 211 | + It 'Should return $true for Test-DscConfiguration' { |
| 212 | + Test-DscConfiguration | Should Be $true |
| 213 | + } |
| 214 | + |
| 215 | + It 'Should have the correct value of the configuration property collection item' { |
| 216 | + # Get the new value. |
| 217 | + $value = (Get-WebConfigurationProperty -PSPath $websitePath -Filter $singleItemFilterValue -Name "." -ErrorAction SilentlyContinue).Value |
| 218 | + |
| 219 | + $value | Should -Be $singleItemPropertyValue |
| 220 | + } |
| 221 | + } |
| 222 | + |
| 223 | + Context 'When Removing Single Collection item' { |
| 224 | + It 'Should compile and apply the MOF without throwing' { |
| 225 | + { |
| 226 | + & "$($script:dscResourceName)_SingleItemRemove" -OutputPath $TestDrive -ConfigurationData $configurationData |
| 227 | + Start-DscConfiguration @startDscConfigurationParameters |
| 228 | + } | Should -Not -Throw |
| 229 | + } |
| 230 | + |
| 231 | + It 'Should be able to call Get-DscConfiguration without throwing' { |
| 232 | + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw |
| 233 | + } |
| 234 | + |
| 235 | + It 'Should return $true for Test-DscConfiguration' { |
| 236 | + Test-DscConfiguration | Should Be $true |
| 237 | + } |
| 238 | + |
| 239 | + It 'Should remove configuration property' { |
| 240 | + $value = (Get-WebConfigurationProperty -PSPath $websitePath -Filter $singleItemFilterValue -Name "." -ErrorAction SilentlyContinue).Value |
| 241 | + |
| 242 | + $value | Should -BeNullOrEmpty |
| 243 | + } |
| 244 | + } |
| 245 | + |
186 | 246 | # Remove the website we created for testing purposes. |
187 | 247 | if (Get-Website -Name $websiteName) |
188 | 248 | { |
|
0 commit comments