-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update search to enable live testing in sovereign clouds for multiple services #17443
Changes from all commits
adb0b06
d93d240
fdd466a
c3d4778
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,15 @@ export const environmentSetup: RecorderEnvironmentSetup = { | |
}; | ||
|
||
export function createClients<IndexModel>(indexName: string): Clients<IndexModel> { | ||
switch (testEnv.AZURE_AUTHORITY_HOST) { | ||
case "https://login.microsoftonline.us": | ||
process.env.ENDPOINT = process.env.ENDPOINT!.toString().replace(".windows.net", ".azure.us"); | ||
break; | ||
case "https://login.chinacloudapi.cn": | ||
process.env.ENDPOINT = process.env.ENDPOINT!.toString().replace(".windows.net", ".azure.cn"); | ||
break; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not very sure about this solution. The tests should not be in the business of changing endpoints. If the input to the tests is going to use a different authority host in order to target other clouds, then the endpoint that gets passed in should be different too. In #17424, we discuss about updating the cc @benbp There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ramya-rao-a I know I just linked to this, but I agree for test code it should contain as little knowledge as possible about endpoints. They should either be set by the credential builder code, or by the test environment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ramya-rao-a Do you want me to revert, or will you take this as a follow-on? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you can log an issue for search, then @sarangan12 can follow up on that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
const credential = new AzureKeyCredential(testEnv.SEARCH_API_ADMIN_KEY); | ||
const searchClient = new SearchClient<IndexModel>(testEnv.ENDPOINT, indexName, credential); | ||
const indexClient = new SearchIndexClient(testEnv.ENDPOINT, credential); | ||
|
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 authority host is not a reliable way to infer the correct scope/endpoint. You can use an Azure Cloud authority host to authenticate into a sovereign cloud resource.
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.
Yeah. Do you mean that using
audience
option here instead of the authority host to infer the correct endpoint?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.
@benbp Do you have any ideas about deyaaeldeen's suggestion?
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.
@deyaaeldeen and I discussed this offline. We found that the authority host for the public cloud could be used for other clouds for some cognitive services, but that might be a bug and definitely not guaranteed to work with other services. So, you can ignore this comment thread.
For tests, the authority host env variable is set during the ARM template deployment. So, we are good here.