@@ -1365,7 +1365,7 @@ Describe 'tests for function expressions' {
13651365 }
13661366
13671367 It ' parseCidr fails with invalid CIDR: <cidr>' - TestCases @ (
1368- @ { cidr = ' invalid ' ; errorMatch = ' Invalid CIDR notation' }
1368+ @ { cidr = ' 192.168.1/24 ' ; errorMatch = ' Invalid CIDR notation' }
13691369 @ { cidr = ' 192.168.1.0/33' ; errorMatch = ' Invalid CIDR notation' }
13701370 @ { cidr = ' 192.168.1.256/24' ; errorMatch = ' Invalid CIDR notation' }
13711371 ) {
@@ -1444,7 +1444,7 @@ Describe 'tests for function expressions' {
14441444 @ { testName = ' new CIDR too small' ; network = ' 10.144.0.0/20' ; newCidr = 16 ; index = 0 ; errorMatch = ' equal to or larger' }
14451445 @ { testName = ' invalid IPv4 prefix' ; network = ' 10.144.0.0/20' ; newCidr = 33 ; index = 0 ; errorMatch = ' Invalid IPv4 prefix' }
14461446 @ { testName = ' invalid IPv6 prefix' ; network = ' 2001:db8::/32' ; newCidr = 129 ; index = 0 ; errorMatch = ' Invalid IPv6 prefix' }
1447- @ { testName = ' invalid CIDR format' ; network = ' invalid ' ; newCidr = 24 ; index = 0 ; errorMatch = ' Invalid CIDR notation' }
1447+ @ { testName = ' invalid CIDR format' ; network = ' 10.0.0/16 ' ; newCidr = 24 ; index = 0 ; errorMatch = ' Invalid CIDR notation' }
14481448 ) {
14491449 param ($testName , $network , $newCidr , $index , $errorMatch )
14501450
@@ -1501,30 +1501,23 @@ Describe 'tests for function expressions' {
15011501 $out.results [0 ].result.actualState.output | Should - BeExactly $expected
15021502 }
15031503
1504- It ' cidrHost handles /31 point-to-point' {
1505- $config_yaml = @"
1506- `$ schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
1507- resources:
1508- - name: Echo
1509- type: Microsoft.DSC.Debug/Echo
1510- properties:
1511- output: "[cidrHost('192.168.1.0/31', 0)]"
1512- "@
1513- $out = $config_yaml | dsc config get -f - | ConvertFrom-Json
1514- $LASTEXITCODE | Should - Be 0
1515- $out.results [0 ].result.actualState.output | Should - BeExactly ' 192.168.1.0'
1504+ It ' cidrHost handles /31 point-to-point: index <index>' - TestCases @ (
1505+ @ { network = ' 192.168.1.0/31' ; index = 0 ; expected = ' 192.168.1.0' }
1506+ @ { network = ' 192.168.1.0/31' ; index = 1 ; expected = ' 192.168.1.1' }
1507+ ) {
1508+ param ($network , $index , $expected )
15161509
15171510 $config_yaml = @"
15181511 `$ schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
15191512 resources:
15201513 - name: Echo
15211514 type: Microsoft.DSC.Debug/Echo
15221515 properties:
1523- output: "[cidrHost('192.168.1.0/31 ', 1 )]"
1516+ output: "[cidrHost('$network ', $index )]"
15241517"@
15251518 $out = $config_yaml | dsc config get -f - | ConvertFrom-Json
15261519 $LASTEXITCODE | Should - Be 0
1527- $out.results [0 ].result.actualState.output | Should - BeExactly ' 192.168.1.1 '
1520+ $out.results [0 ].result.actualState.output | Should - BeExactly $expected
15281521 }
15291522
15301523 It ' cidrHost works with IPv6' {
@@ -1546,7 +1539,7 @@ Describe 'tests for function expressions' {
15461539 @ { testName = ' /128 has no usable hosts' ; network = ' 2001:db8::1/128' ; index = 0 ; errorMatch = ' no usable host' }
15471540 @ { testName = ' index out of range' ; network = ' 192.168.1.0/24' ; index = 254 ; errorMatch = ' out of range' }
15481541 @ { testName = ' negative index' ; network = ' 192.168.1.0/24' ; index = -1 ; errorMatch = ' negative' }
1549- @ { testName = ' invalid CIDR' ; network = ' invalid ' ; index = 0 ; errorMatch = ' Invalid CIDR notation' }
1542+ @ { testName = ' invalid CIDR' ; network = ' 192.168.1.0.0/24 ' ; index = 0 ; errorMatch = ' Invalid CIDR notation' }
15501543 ) {
15511544 param ($testName , $network , $index , $errorMatch )
15521545
0 commit comments