-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[AD] Support special characters in object names #22739
Conversation
Graph |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any test to cover the changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_special_characters
is exactly for that purpose.
Luckily, VCRPY can also match URLs that are percent-encoded, so we don't need to re-record all tests. |
Related command
az ad group show
Close #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
GraphClient
usesrequests
to make HTTP requests.requests
usesurllib3
'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,
graphrbac
SDK 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.