-
Notifications
You must be signed in to change notification settings - Fork 298
potential fix for no Jwks URI specified error in tests #3169
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: John K <[email protected]>
Summary of ChangesHello @frumioj, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a reported issue where the Jwks URI was not being correctly set during certain test executions, leading to test failures. The changes involve explicitly configuring the necessary Azure-related system properties within the relevant test methods and ensuring proper cleanup, thereby stabilizing the testing environment and allowing these tests to pass reliably. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Resolves #3168 |
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.
Code Review
This pull request fixes an issue with missing JWKS URI during tests by adding the necessary setup. However, in the process, it accidentally removes the test logic from testConfirmInstanceAzureSubscriptionIssues, making the test pass without performing any assertions. This change needs to be reverted to ensure test coverage is not lost. Additionally, the new setup and teardown logic is duplicated across several tests and should be refactored into helper methods to improve code maintainability.
| System.clearProperty(InstanceAzureProvider.AZURE_PROP_ZTS_RESOURCE_URI); | ||
| System.clearProperty(InstanceAzureProvider.AZURE_PROP_OPENID_CONFIG_URI); | ||
| System.clearProperty(InstanceAzureProvider.AZURE_PROP_OPENID_JWKS_URI); | ||
|
|
||
| provider.close(); | ||
| removeOpenIdConfigFile(configFile, jwksUri); |
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 original test logic for testConfirmInstanceAzureSubscriptionIssues has been removed. This test is now empty and does not verify any behavior related to Azure subscription issues. The original assertions should be restored to ensure the test remains valid. Additionally, the provider.close() call was removed, which can lead to a resource leak.
AzureAttestationData data = new AzureAttestationData();
data.setVmId("2222-3333");
data.setSubscriptionId("1111-2222");
confirmation.setAttestationData(provider.jsonMapper.writeValueAsString(data));
try {
provider.confirmInstance(confirmation);
fail();
} catch (ProviderResourceException ex) {
assertTrue(ex.getMessage().contains("Unable to extract Azure Subscription id"));
}
// add the subscription but different from what's in the data object
attributes.put(InstanceProvider.ZTS_INSTANCE_AZURE_SUBSCRIPTION, "1111-3333");
try {
provider.confirmInstance(confirmation);
fail();
} catch (ProviderResourceException ex) {
assertTrue(ex.getMessage().contains("Azure Subscription Id mismatch"));
}
provider.close();
System.clearProperty(InstanceAzureProvider.AZURE_PROP_ZTS_RESOURCE_URI);
System.clearProperty(InstanceAzureProvider.AZURE_PROP_OPENID_CONFIG_URI);
System.clearProperty(InstanceAzureProvider.AZURE_PROP_OPENID_JWKS_URI);
removeOpenIdConfigFile(configFile, jwksUri);| File configFile = new File("./src/test/resources/azure-openid.json"); | ||
| File jwksUri = new File("./src/test/resources/azure-jwks.json"); | ||
| createOpenIdConfigFile(configFile, jwksUri, false); | ||
|
|
||
| System.setProperty(InstanceAzureProvider.AZURE_PROP_ZTS_RESOURCE_URI, "https://azure-zts"); | ||
| System.setProperty(InstanceAzureProvider.AZURE_PROP_OPENID_CONFIG_URI, "file://" + configFile.getCanonicalPath()); | ||
| System.setProperty(InstanceAzureProvider.AZURE_PROP_OPENID_JWKS_URI, "file://" + jwksUri.getCanonicalPath()); |
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.
There is significant code duplication across multiple tests for setting up and tearing down the Azure OpenID configuration (creating config files, setting system properties). This makes the tests harder to read and maintain. Consider refactoring this logic into helper methods. For example, you could create setupAzureOpenIdConfig() and tearDownAzureOpenIdConfig() methods and call them from the respective tests. This would also require making configFile and jwksUri class members.
Description
I filed an issue because Jwks URI not being set during some tests. This PR fixes that.
Contribution Checklist:
Attach Screenshots (Optional)