Skip to content

Conversation

@frumioj
Copy link
Contributor

@frumioj frumioj commented Jan 5, 2026

Description

I filed an issue because Jwks URI not being set during some tests. This PR fixes that.

Contribution Checklist:

  • The pull request does not introduce any breaking changes
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Attach Screenshots (Optional)

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Test Configuration Fix: Explicitly sets the AZURE_PROP_ZTS_RESOURCE_URI, AZURE_PROP_OPENID_CONFIG_URI, and AZURE_PROP_OPENID_JWKS_URI system properties within the testConfirmInstanceAzureSubscriptionIssues and testConfirmInstanceSanDnsMismatch test methods to ensure proper test execution.
  • Test Cleanup: Adds System.clearProperty calls and removeOpenIdConfigFile to clean up the system properties and temporary files after the execution of the affected test methods, preventing side effects on other tests.
  • Test Refactoring: Removes a section of code from testConfirmInstanceAzureSubscriptionIssues that previously handled various Azure subscription ID mismatch validation scenarios.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@frumioj
Copy link
Contributor Author

frumioj commented Jan 5, 2026

Resolves #3168

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +384 to +388
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

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);

Comment on lines +364 to +370
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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant