-
Notifications
You must be signed in to change notification settings - Fork 54
Encode name part of resourceId() function to allow name to accept any characters
#1188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e59d9e4
Change `resourceId()` to url encode the name
SteveL-MSFT 21aee44
Change `resourceId()` to url encode name so names can contain arbitra…
SteveL-MSFT 224d6bf
fix unit test
SteveL-MSFT 299babb
fix dependsOn
SteveL-MSFT 920da86
remove unused text
SteveL-MSFT c0a5a91
fix expected generation of resource id into helper function
SteveL-MSFT 8d169db
remove unused text
SteveL-MSFT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,7 +123,7 @@ Describe 'tests for function expressions' { | |
| @{ expression = "[intersection(parameters('nestedObject1'), parameters('nestedObject2'))]"; expected = [pscustomobject]@{ | ||
| shared = [pscustomobject]@{ value = 42; flag = $true } | ||
| level = 1 | ||
| } | ||
| } | ||
| } | ||
| @{ expression = "[intersection(parameters('nestedObject1'), parameters('nestedObject3'))]"; expected = [pscustomobject]@{ level = 1 } } | ||
| @{ expression = "[intersection(parameters('nestedObject1'), parameters('nestedObject2'), parameters('nestedObject4'))]"; expected = [pscustomobject]@{ level = 1 } } | ||
|
|
@@ -948,10 +948,10 @@ Describe 'tests for function expressions' { | |
| @{ testInput = ' ' } | ||
| ) { | ||
| param($testInput) | ||
|
|
||
| $expected = [Uri]::EscapeDataString($testInput) | ||
| $expression = "[uriComponent('$($testInput -replace "'", "''")')]" | ||
|
|
||
| $config_yaml = @" | ||
| `$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
| resources: | ||
|
|
@@ -963,13 +963,13 @@ Describe 'tests for function expressions' { | |
| $out = $config_yaml | dsc config get -f - | ConvertFrom-Json | ||
| $out.results[0].result.actualState.output | Should -BeExactly $expected | ||
| } | ||
|
|
||
| It 'uriComponent function works with concat' { | ||
| $input1 = 'hello' | ||
| $input2 = ' ' | ||
| $input3 = 'world' | ||
| $expected = [Uri]::EscapeDataString($input1 + $input2 + $input3) | ||
|
|
||
| $config_yaml = @" | ||
| `$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
| resources: | ||
|
|
@@ -995,10 +995,10 @@ Describe 'tests for function expressions' { | |
| @{ testInput = '100%25' } | ||
| ) { | ||
| param($testInput) | ||
|
|
||
| $expected = [Uri]::UnescapeDataString($testInput) | ||
| $expression = "[uriComponentToString('$($testInput -replace "'", "''")')]" | ||
|
|
||
| $config_yaml = @" | ||
| `$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
| resources: | ||
|
|
@@ -1010,11 +1010,11 @@ Describe 'tests for function expressions' { | |
| $out = $config_yaml | dsc config get -f - | ConvertFrom-Json | ||
| $out.results[0].result.actualState.output | Should -BeExactly $expected | ||
| } | ||
|
|
||
| It 'uriComponentToString function works with round-trip encoding' { | ||
| $original = 'hello world' | ||
| $expected = $original | ||
|
|
||
| $config_yaml = @" | ||
| `$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
| resources: | ||
|
|
@@ -1026,11 +1026,11 @@ Describe 'tests for function expressions' { | |
| $out = $config_yaml | dsc config get -f - | ConvertFrom-Json | ||
| $out.results[0].result.actualState.output | Should -BeExactly $expected | ||
| } | ||
|
|
||
| It 'uriComponentToString function works with nested round-trip' { | ||
| $original = '[email protected]' | ||
| $expected = $original | ||
|
|
||
| $config_yaml = @" | ||
| `$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
| resources: | ||
|
|
@@ -1042,13 +1042,13 @@ Describe 'tests for function expressions' { | |
| $out = $config_yaml | dsc config get -f - | ConvertFrom-Json | ||
| $out.results[0].result.actualState.output | Should -BeExactly $expected | ||
| } | ||
|
|
||
| It 'uriComponentToString function works with concat' { | ||
| $input1 = 'hello' | ||
| $input2 = '%20' | ||
| $input3 = 'world' | ||
| $expected = [Uri]::UnescapeDataString($input1 + $input2 + $input3) | ||
|
|
||
| $config_yaml = @" | ||
| `$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
| resources: | ||
|
|
@@ -1077,7 +1077,7 @@ Describe 'tests for function expressions' { | |
| @{ data = @{ nested = @{ value = 123 } }; accessor = '.nested.value'; expected = 123 } | ||
| ) { | ||
| param($data, $accessor, $expected) | ||
|
|
||
| $jsonString = ConvertTo-Json -Compress -InputObject $data | ||
| $expression = "[json(''$($jsonString)'')$accessor]" | ||
|
|
||
|
|
@@ -1152,7 +1152,7 @@ Describe 'tests for function expressions' { | |
| @{ base = 'http://192.168.1.1/'; relative = 'api/v1'; expected = 'http://192.168.1.1/api/v1' } | ||
| ) { | ||
| param($base, $relative, $expected) | ||
|
|
||
| $expression = "[uri('$($base -replace "'", "''")','$($relative -replace "'", "''")')]" | ||
| $config_yaml = @" | ||
| `$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
|
|
@@ -1188,4 +1188,20 @@ Describe 'tests for function expressions' { | |
| $errorContent = Get-Content $TestDrive/error.log -Raw | ||
| $errorContent | Should -Match ([regex]::Escape($expectedError)) | ||
| } | ||
|
|
||
| It 'resourceId allows for arbitrary characters in names including unicode' { | ||
| $name = 'My Resource @123/!#$%^&*()[]{}-+=;`~' | ||
| $config_yaml = @" | ||
| `$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
| resources: | ||
| - name: "$name" | ||
| type: Microsoft.DSC.Debug/Echo | ||
| properties: | ||
| output: "[resourceId('Microsoft.DSC.Debug/Echo', '$name')]" | ||
| "@ | ||
| $out = dsc config get -i $config_yaml | ConvertFrom-Json | ||
| $LASTEXITCODE | Should -Be 0 | ||
| $expected = "Microsoft.DSC.Debug/Echo:$([Uri]::EscapeDataString($name))" | ||
| $out.results[0].result.actualState.output | Should -BeExactly $expected | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.