[AD] Support special characters in object names#22739
Merged
Conversation
Collaborator
|
Graph |
jiasli
commented
Jun 7, 2022
Comment on lines
+190
to
+191
| Theoretically, GeneralNameReplacer should also follow this pattern, but since we haven't seen any ARM name that | ||
| is percent-encoded, we only replace percent-encoded names for MS Graph for better test performance. |
Member
Author
There was a problem hiding this comment.
The test framework of Azure CLI and SDK never supports special characters in resource names, as GeneralNameReplacer doesn't take special characters into consideration.
I tried to change GeneralNameReplacer's logic to also replace encoded names, but it turns out to be an overdo since ARM resource names usually don't need to be encoded, so we only do it specially for MS Graph.
Member
There was a problem hiding this comment.
Do we have any test to cover the changes?
Member
Author
There was a problem hiding this comment.
test_special_characters is exactly for that purpose.
Member
Author
|
Luckily, VCRPY can also match URLs that are percent-encoded, so we don't need to re-record all tests. |
evelyn-ys
approved these changes
Jun 13, 2022
calvinhzy
approved these changes
Jun 13, 2022
jsntcy
approved these changes
Jun 13, 2022
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related command
az ad group showClose #22700
Graph service
Even though Graph service recommends encoding query parameters (https://docs.microsoft.com/en-us/graph/query-parameters#encoding-query-parameters), it is not explicit on which characters should be encoded:
In the above example, only a subset of reserved characters defined by rfc3986 are encoded, like
,<SPACE>, but()'are not (considered "safe"). Instead,startswith(givenName, 'J')should be encoded asGraph service SHOULD explicitly specify which characters should be encoded (https://github.com/microsoftgraph/microsoft-graph-docs-contrib/issues/2085).
CLI
GraphClientusesrequeststo make HTTP requests.requestsusesurllib3's encoding mechanism which treats,+as "safe" and doesn't encode them.https://github.com/urllib3/urllib3/blob/342aff50ff300d96a58e9be22f27fcee771ce98d/src/urllib3/util/url.py#L73-L79
Even though Azure CLI 2.37.0 doesn't encode
,, the API still works:SDK
Previously,
graphrbacSDK encodes all special characters, including(),'.https://github.com/Azure/msrest-for-python/blob/9c719385a1939ae840124838131a09002c123298/msrest/serialization.py#L699
This is consistent with the Graph document, but inconsistent with Graph document's example.
Change
This PR encodes all special characters, like the old SDK does, in order to support special characters such as
+/in object names.