Skip to content
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

Feature/sdk rework test coverage #23

Merged

Conversation

brettchaldecott
Copy link
Contributor

@brettchaldecott brettchaldecott commented Sep 25, 2024

Explain your changes

Added the required Spring Boot test coverage.

Checklist

🛟 If you need help, consider asking for advice over in the Kinde community.

Brett Chaldecott added 10 commits September 16, 2024 11:55
Working on coverage.
Fixed readme
Implemented beginnings of tests
Updated the kinde test
Continued extending test coverage for Spring starter
Completed load user tests
Increased test coverage
Increased test coverage
Fixed test coverage and correct variable names
Copy link
Contributor

coderabbitai bot commented Sep 25, 2024

Walkthrough

The changes involve updates to several Java classes and test files within the Kinde Spring Boot SDK. Key modifications include adjustments to dependency injection methods, method signatures, and the introduction of new test classes for various components. Additionally, the README file was updated to reflect changes in the command for installing dependencies. The modifications enhance the overall structure and functionality of the SDK.

Changes

Files Change Summary
README.md Updated the command for installing dependencies from mvn clean install to mvn -B clean package.
kinde-springboot-core/src/main/java/com/kinde/spring/KindeOAuth2AutoConfig.java Modified kindeSdkClient injection to use a public setter method and updated the oidcLogoutSuccessHandler method to remove a parameter and retrieve the logout URI directly from the kindeSdkClient.
kinde-springboot-core/src/main/java/com/kinde/spring/ReactiveKindeOAuth2ServerHttpServerAutoConfig.java Changed the parameter name from oktaOAuth2Properties to kindeOAuth2Properties in the oidcClientInitiatedServerLogoutSuccessHandler method.
kinde-springboot-core/src/main/java/com/kinde/spring/env/KindeOAuth2PropertiesMappingEnvironmentPostProcessor.java Changed class visibility from final to public and modified several constants from private static final to public static final.
kinde-springboot-core/src/test/java/com/kinde/spring/KindeJwtAuthenticationConverterTest.java Introduced a new test class with two unit tests for the KindeJwtAuthenticationConverter class.
kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2AutoConfigTest.java Added a new test class for KindeOAuth2AutoConfig with multiple test methods to validate OAuth2 configuration.
kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2ConfigurerTest.java Introduced a new test class with a method to validate the initialization logic of the KindeOAuth2Configurer class.
kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2ResourceServerAutoConfigTest.java Added a new test class for KindeOAuth2ResourceServerAutoConfig, including tests for JWT configuration.
kinde-springboot-core/src/test/java/com/kinde/spring/KindeOidcUserServiceTest.java Added a new test class for the KindeOidcUserService, focusing on the loadUser method.
kinde-springboot-core/src/test/java/com/kinde/spring/KindeTest.java Introduced unit tests for the Kinde class, focusing on OAuth2 PKCE configuration.
kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2AutoConfigTest.java Added a test class for ReactiveKindeOAuth2AutoConfig, validating OAuth2 user service behavior.
kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2ResourceServerAutoConfigTest.java Introduced a test class for the reactive OAuth2 resource server configuration.
kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2ServerHttpServerAutoConfigTest.java Added a test class for ReactiveKindeOAuth2ServerHttpServerAutoConfig, validating its behavior in a Spring Boot application.
kinde-springboot-core/src/test/java/com/kinde/spring/TokenUtilTest.java Introduced unit tests for the TokenUtil class, covering various methods related to token claims and validation.
kinde-springboot-core/src/test/java/com/kinde/spring/UserUtilTest.java Added unit tests for the UserUtil class, specifically testing the decorateUser method for different user types.
kinde-springboot-core/src/test/java/com/kinde/spring/WebClientUtilTest.java Introduced a test class for testing the WebClient instance created by the WebClientUtil class.
.github/workflows/maven.yml Modified the workflow to enhance testing and coverage reporting, including steps to run JaCoCo reports and upload them to Codecov.

Possibly related PRs

  • Feature/sdk rework #21: The changes in the README.md file regarding the installation command for dependencies in a Gradle build process are related to the overall SDK rework, which may include updates to build processes and documentation.
  • Add Codecov reporting #24: The changes in the .github/workflows/maven.yml file regarding the testing and coverage reporting process may relate to the main PR's focus on the build process, as both involve enhancements to the project's build and testing workflows.

Suggested reviewers

  • DaveOrDead
  • rairaman

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 33

🧹 Outside diff range and nitpick comments (27)
kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeJwtAuthenticationConverterTest.java (2)

1-9: Remove unused import.

The HttpSecurity class is imported but not used in the test methods. Consider removing this unused import to keep the code clean.

Apply this diff to remove the unused import:

-import org.springframework.security.config.annotation.web.builders.HttpSecurity;

1-24: Improve overall test coverage for KindeJwtAuthenticationConverter.

While the current tests cover the basic instantiation of the KindeJwtAuthenticationConverter class, they don't provide comprehensive coverage of its functionality. To enhance the test suite, consider adding the following:

  1. Test cases for different input scenarios (e.g., null or empty permission claims).
  2. Tests for any public methods in the KindeJwtAuthenticationConverter class.
  3. Tests to verify the behavior of the converter when processing actual JWT tokens.
  4. Edge case scenarios that might occur during token conversion.

To implement these suggestions, you might need to:

  1. Add more test methods to this class.
  2. Create mock JWT tokens for testing.
  3. Use parameterized tests for testing multiple scenarios efficiently.

Example of a potential additional test:

@Test
public void testConvertValidJwtToken() {
    // Setup
    KindeJwtAuthenticationConverter converter = new KindeJwtAuthenticationConverter("permissions");
    Jwt mockJwt = Mockito.mock(Jwt.class);
    when(mockJwt.getClaim("permissions")).thenReturn(Arrays.asList("read", "write"));

    // Execute
    Authentication result = converter.convert(mockJwt);

    // Verify
    assertNotNull(result);
    assertTrue(result instanceof JwtAuthenticationToken);
    JwtAuthenticationToken jwtAuth = (JwtAuthenticationToken) result;
    assertEquals(2, jwtAuth.getAuthorities().size());
    assertTrue(jwtAuth.getAuthorities().contains(new SimpleGrantedAuthority("read")));
    assertTrue(jwtAuth.getAuthorities().contains(new SimpleGrantedAuthority("write")));
}

This will help ensure that the KindeJwtAuthenticationConverter is working correctly in various scenarios.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/TokenUtilTest.java (2)

39-43: Improve assertions in testRootIssuer method.

While the testRootIssuer method does include assertions, the way they are written can be improved for better readability and error reporting.

Consider refactoring the test as follows:

@Test
public void testRootIssuer() {
    assertTrue(TokenUtil.isRootOrgIssuer("https://sample.kinde.com"), 
               "https://sample.kinde.com should be recognized as a root org issuer");
    assertFalse(TokenUtil.isRootOrgIssuer("https://sample.kinde.com/oauth2/default"), 
                "https://sample.kinde.com/oauth2/default should not be recognized as a root org issuer");
}

This refactoring:

  1. Uses separate assertTrue and assertFalse statements for clearer intent.
  2. Adds descriptive messages to each assertion for better error reporting.
  3. Removes the unnecessary use of the logical NOT operator in the second assertion.

1-46: Consider improving overall test coverage and structure.

While the TokenUtilTest class provides a good starting point for testing the TokenUtil class, there are several areas where it can be improved:

  1. Ensure all methods in TokenUtil are covered by tests.
  2. Add more test cases to cover different scenarios, including edge cases and error conditions.
  3. Use parameterized tests where appropriate to test multiple inputs efficiently.
  4. Consider adding setup methods (e.g., @BeforeEach) for common test configurations.
  5. Group related tests using nested test classes (e.g., @Nested) for better organization.

Here's an example of how you might structure the tests using nested classes:

class TokenUtilTest {

    @Nested
    class TokenClaimsToAuthoritiesTests {
        @Test
        void withEmptyClaims() { /* ... */ }
        @Test
        void withNonEmptyClaims() { /* ... */ }
        // More tests...
    }

    @Nested
    class TokenScopesToAuthoritiesTests {
        @Test
        void withNullToken() { /* ... */ }
        @Test
        void withEmptyScopes() { /* ... */ }
        @Test
        void withNonEmptyScopes() { /* ... */ }
        // More tests...
    }

    // More nested classes for other methods...
}

This structure improves readability and organization of your tests, making it easier to maintain and extend in the future.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2ConfigurerTest.java (2)

14-17: Consider using a more descriptive test method name.

The current method name testInit is good, but it could be more specific about what aspect of initialization is being tested. Consider renaming it to something like testInitConfiguresHttpSecurity or testInitWithMockedDependencies to provide more context about the test's purpose.


1-31: Summary: Good start, but needs improvements for effective testing.

Overall, this is a good start for testing the KindeOAuth2Configurer class. However, there are several areas that need improvement to ensure effective and comprehensive testing:

  1. Add assertions to verify the expected behavior of the KindeOAuth2Configurer.
  2. Restructure the test to clearly separate different test scenarios.
  3. Enhance test coverage by verifying interactions with mocked objects.
  4. Consider adding more test methods to cover different use cases and edge scenarios.

Implementing these changes will significantly improve the quality and reliability of your tests. Keep up the good work on increasing test coverage for the SDK!

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/WebClientUtilTest.java (2)

1-17: Clean up imports

There are some unused and redundant imports in the class. Consider removing or organizing them:

  1. Remove the unused import:

    -import com.github.tomakehurst.wiremock.junit5.WireMockTest;
  2. Remove the redundant import:

    -import org.springframework.web.reactive.function.client.WebClient;

This will improve code cleanliness and reduce potential confusion.


22-28: Remove empty setUp and tearDown methods

The setUp and tearDown methods are currently empty and unnecessary. Consider removing them to improve code clarity:

-    @BeforeEach
-    public void setUp() throws Exception {
-    }
-
-    @AfterEach
-    public void tearDown() throws Exception {
-    }

If setup or teardown logic is needed in the future, you can add these methods back with the required implementation.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2UserServiceTest.java (2)

10-10: Remove unused import

The java.util.List import is not used in this test class. Consider removing it to keep the imports clean and relevant.

Apply this diff to remove the unused import:

-import java.util.List;

1-31: Overall assessment: Good start, but needs improvements

This new test class for ReactiveKindeOAuth2UserService is a positive step towards improving test coverage for the Spring Boot components of the Kinde Java SDK. However, there are several areas where the test can be enhanced:

  1. Add assertions to verify the expected behavior of the loadUser method.
  2. Improve the test method name and consider adding more test methods for different scenarios.
  3. Correct the mock setup, especially for the reactiveOAuth2UserService.
  4. Add verifications for mock interactions.
  5. Consider setting up expectations for the reactiveOAuth2UserService.loadUser() method.
  6. Remove unused imports.

By addressing these points, you'll create a more robust and effective test suite that better ensures the reliability of the ReactiveKindeOAuth2UserService class.

As you continue to improve test coverage for the Spring Boot components of the SDK, consider the following architectural advice:

  1. Aim for high test coverage, but focus on testing critical paths and edge cases.
  2. Use parameterized tests to cover multiple scenarios efficiently.
  3. Consider using a test fixture or a test helper class to reduce duplication in test setup across multiple test methods.
  4. As the test suite grows, organize tests into logical groups using nested classes or separate test classes for different aspects of the service.
  5. Implement integration tests in addition to unit tests to ensure that the ReactiveKindeOAuth2UserService works correctly with other components of the system.
kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOidcUserServiceTest.java (1)

1-34: Summary: Good start, but needs improvements for effective testing.

This test class is a good start for testing the ReactiveKindeOidcUserService. However, to ensure robust and effective testing, please implement the suggested improvements:

  1. Add the Mockito extension to the class.
  2. Rename the test method to be more descriptive.
  3. Implement proper assertions to verify the behavior of the loadUser method.
  4. Utilize all mocked dependencies in the test and verify their interactions.

Remember, thorough testing is crucial for maintaining code quality and preventing regressions, especially in security-related components like this OAuth service. Ensure that all possible scenarios and edge cases are covered in your tests.

Consider adding more test methods to cover different scenarios, such as:

  • Error handling when the OAuth2 service fails
  • Behavior with different types of client registrations
  • Edge cases with various user info endpoints

This will help ensure the robustness of your ReactiveKindeOidcUserService implementation.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2ResourceServerHttpServerAutoConfigTest.java (2)

15-24: LGTM: Class annotations and declaration are correct.

The test class is properly set up with the necessary annotations for a Spring Boot test. The @TestPropertySource provides the required Kinde OAuth2 configuration properties.

Consider shortening the class name for improved readability. For example:

public class ReactiveKindeOAuth2ResourceServerAutoConfigTest {

This maintains clarity while slightly reducing the length.


25-34: LGTM: Test configuration is correctly set up.

The nested @TestConfiguration class is properly implemented to provide the necessary bean for the test.

Remove the System.out.println("Hello 3"); statement on line 29. It appears to be a debugging artifact and should not be present in the final test code.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2AutoConfigTest.java (3)

19-28: LGTM: Test class setup looks good, with a minor suggestion.

The test class is well-configured with appropriate annotations and test properties. The use of @TestPropertySource, @SpringBootTest, and @Import is correct for setting up the test environment.

Consider extracting the test property values into constants for better maintainability. For example:

private static final String TEST_OAUTH_DOMAIN = "https://test.kinde.com";
private static final String TEST_CLIENT_ID = "test_client_id";
// ... other constants

@TestPropertySource(properties = {
    KindeOAuth2PropertiesMappingEnvironmentPostProcessor.KINDE_OAUTH_DOMAIN + "=" + TEST_OAUTH_DOMAIN,
    KindeOAuth2PropertiesMappingEnvironmentPostProcessor.KINDE_OAUTH_CLIENT_ID + "=" + TEST_CLIENT_ID,
    // ... other properties
})

This approach makes it easier to update test values and improves code readability.


29-47: LGTM: Test configuration is well-structured, with room for minor improvements.

The MyTestConfig class is correctly set up with @TestConfiguration and provides necessary bean definitions for the test environment. Mocking KindeSdkClient and KindeOAuth2Properties is a good practice for unit testing.

Consider the following improvements:

  1. Remove the System.out.println statement from the reactiveKindeOAuth2AutoConfig bean method. If logging is necessary, use a proper logging framework.
@Bean
public ReactiveKindeOAuth2AutoConfig reactiveKindeOAuth2AutoConfig() {
-   System.out.println("Hello 3");
    return new ReactiveKindeOAuth2AutoConfig();
}
  1. The reactiveKindeOAuth2AutoConfig bean method can be simplified:
@Bean
public ReactiveKindeOAuth2AutoConfig reactiveKindeOAuth2AutoConfig() {
-   ReactiveKindeOAuth2AutoConfig reactiveKindeOAuth2AutoConfig = new ReactiveKindeOAuth2AutoConfig();
-   return reactiveKindeOAuth2AutoConfig;
+   return new ReactiveKindeOAuth2AutoConfig();
}

These changes will improve code quality and readability.


1-64: Summary: Good test structure with room for improvement in test methods.

Overall, the ReactiveKindeOAuth2AutoConfigTest class provides a good foundation for testing the ReactiveKindeOAuth2AutoConfig. The test setup, including annotations and configuration, is well-structured. However, there are several areas where the test coverage and quality can be improved:

  1. Enhance both test methods (testOauth2UserService and testOidcUserService) by adding assertions and testing various scenarios.
  2. Remove debug print statements and simplify bean creation in the MyTestConfig class.
  3. Consider extracting test property values into constants for better maintainability.

Implementing these suggestions will result in more robust and comprehensive tests, ensuring better code quality and reliability for the Kinde Java SDK.

As you continue to develop the test suite for the Spring Boot components of the SDK, consider the following architectural advice:

  1. Implement integration tests that cover the interaction between different components of the SDK.
  2. Use test fixtures or factories to create common test objects, reducing duplication across test methods.
  3. Consider implementing a custom test slice for Kinde-specific configurations to speed up test execution and isolate Kinde-related beans.
  4. As the test suite grows, organize tests into different classes based on functionality or component being tested to maintain clarity and manageability.

These practices will help ensure the long-term maintainability and effectiveness of your test suite as the SDK evolves.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOidcUserServiceTest.java (1)

22-22: Add Mockito extension annotation to the test class.

To properly integrate Mockito with JUnit 5, add the @ExtendWith(MockitoExtension.class) annotation to the class declaration. This will enable better handling of mocks and reduce boilerplate code.

Apply this change:

+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;

+@ExtendWith(MockitoExtension.class)
 public class KindeOidcUserServiceTest {
kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2ResourceServerAutoConfigTest.java (2)

29-37: Remove unnecessary System.out.println statement.

The System.out.println("Hello 3"); statement in the kindeOAuth2ResourceServerAutoConfig() method is unnecessary and should be removed. It doesn't contribute to the test and may clutter the console output.

Apply this diff to remove the print statement:

 @Bean
 public KindeOAuth2ResourceServerAutoConfig kindeOAuth2ResourceServerAutoConfig() {
-    System.out.println("Hello 3");
     KindeOAuth2ResourceServerAutoConfig kindeOAuth2ResourceServerAutoConfig = new KindeOAuth2ResourceServerAutoConfig();
     return kindeOAuth2ResourceServerAutoConfig;
 }

1-62: Overall test class structure is good, but consider expanding test coverage.

The KindeOAuth2ResourceServerAutoConfigTest class provides a good foundation for testing the KindeOAuth2ResourceServerAutoConfig class. However, there are a few areas where the test coverage and quality could be improved:

  1. Consider adding more test methods to cover different scenarios and edge cases for the KindeOAuth2ResourceServerAutoConfig class.
  2. Ensure that all public methods of the KindeOAuth2ResourceServerAutoConfig class are tested.
  3. Add comments to explain the purpose of each test method and any complex setup or assertions.
  4. Consider using parameterized tests for scenarios that require testing with multiple input values.

To improve the overall test architecture:

  1. Consider creating a separate test class for each major functionality of KindeOAuth2ResourceServerAutoConfig if it becomes too large.
  2. Use a constants class or static final variables for commonly used test values (e.g., URLs, client IDs) to improve maintainability.
  3. If there are common setup steps across multiple test methods, consider using @BeforeEach to extract this setup.

These improvements will help ensure that the KindeOAuth2ResourceServerAutoConfig class is thoroughly tested and that the tests remain maintainable as the codebase evolves.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2ResourceServerAutoConfigTest.java (1)

32-50: Remove unnecessary println statement in reactiveKindeOAuth2AutoConfig method.

The MyTestConfig inner class is well-structured and provides the necessary beans for testing. However, there's an unnecessary println statement in the reactiveKindeOAuth2AutoConfig method that should be removed.

Please apply the following change:

@Bean
public ReactiveKindeOAuth2ResourceServerAutoConfig reactiveKindeOAuth2AutoConfig() {
-   System.out.println("Hello 3");
    ReactiveKindeOAuth2ResourceServerAutoConfig reactiveKindeOAuth2ResourceServerAutoConfig = new ReactiveKindeOAuth2ResourceServerAutoConfig();
    return reactiveKindeOAuth2ResourceServerAutoConfig;
}
kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2ServerHttpServerAutoConfigTest.java (3)

20-29: LGTM: Class annotations and declaration are well-structured.

The class annotations and declaration are appropriate for setting up the test environment. The @TestPropertySource annotation correctly sets up the necessary properties for the Kinde OAuth2 configuration, and the @SpringBootTest annotation is properly used to load the application context for testing.

Consider extracting the property values into constants to improve maintainability and readability. For example:

private static final String TEST_OAUTH_DOMAIN = "https://test.kinde.com";
private static final String TEST_CLIENT_ID = "test_client_id";
// ... other constants

@TestPropertySource(properties = {
    KindeOAuth2PropertiesMappingEnvironmentPostProcessor.KINDE_OAUTH_DOMAIN + "=" + TEST_OAUTH_DOMAIN,
    KindeOAuth2PropertiesMappingEnvironmentPostProcessor.KINDE_OAUTH_CLIENT_ID + "=" + TEST_CLIENT_ID,
    // ... other properties
})

31-40: LGTM: Nested configuration class is properly set up, but contains unnecessary debug statement.

The nested configuration class MyTestConfig is correctly annotated with @TestConfiguration and provides a bean for ReactiveKindeOAuth2ServerHttpServerAutoConfig. This setup is appropriate for the test environment.

Remove the System.out.println("Hello 3"); statement on line 35. Debug statements should not be present in test code. If logging is necessary, consider using a proper logging framework.

Consider simplifying the bean method by directly returning the new instance:

@Bean
public ReactiveKindeOAuth2ServerHttpServerAutoConfig reactiveKindeOAuth2ServerHttpServerAutoConfig() {
    return new ReactiveKindeOAuth2ServerHttpServerAutoConfig();
}

1-65: Overall assessment: Good test structure with room for improvement in test methods.

The ReactiveKindeOAuth2ServerHttpServerAutoConfigTest class is well-structured and provides a good foundation for testing the ReactiveKindeOAuth2ServerHttpServerAutoConfig. The use of @SpringBootTest, @TestPropertySource, and the nested configuration class demonstrates a good understanding of Spring Boot testing practices.

However, to fully leverage the potential of these tests and ensure robust coverage, consider implementing the following improvements:

  1. Add assertions and verifications to both test methods to validate the expected behavior.
  2. Remove debug statements (e.g., System.out.println) from the test configuration.
  3. Consider extracting test property values into constants for better maintainability.
  4. Enhance exception handling in the testOidcClientInitiatedServerLogoutSuccessHandler method.

By addressing these points, you'll significantly improve the reliability and effectiveness of your test suite.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2UserServiceTest.java (1)

25-57: LGTM: Setup and teardown methods are well-structured.

The class name and setup/teardown methods follow best practices for test isolation. The WireMock server is correctly configured with a stub for the user profile endpoint.

Consider extracting the hardcoded port number (8089) to a constant at the class level for better maintainability:

+private static final int WIREMOCK_PORT = 8089;

-wireMockServer = new WireMockServer(8089);
+wireMockServer = new WireMockServer(WIREMOCK_PORT);
-WireMock.configureFor("localhost", 8089);
+WireMock.configureFor("localhost", WIREMOCK_PORT);
kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/KindeOAuth2AutoConfig.java (1)

Line range hint 1-91: Summary: Positive changes, consider broader refactoring impact.

The changes in this file represent a shift towards better dependency injection practices and more centralized configuration management through KindeSdkClient. While these changes are improvements, they may be part of a larger refactoring effort.

To ensure consistency across the codebase:

  1. Review other classes that might still be using field injection for KindeSdkClient and consider updating them to use setter injection.
  2. Check for any remaining usages of KindeOAuth2Properties for OAuth2 and logout configurations, and consider updating them to use KindeSdkClient where appropriate.
  3. Update any documentation or developer guidelines to reflect these new practices.

Consider creating a task or issue to review the entire codebase for consistency with these new patterns, ensuring that all related components are updated accordingly.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2AutoConfigTest.java (2)

50-94: Remove debug print statements and LGTM for the rest.

The MyTestConfig class is well-structured and provides all necessary mocked beans for the test. However, there are a few System.out.println statements that should be removed:

Please remove the following debug print statements:

  • Line 56: System.out.println("Hello 1");
  • Line 76: System.out.println("Hello 2");
  • Line 89: System.out.println("Hello 3");

These statements are likely used for debugging but should not be present in the final test code.


96-107: Consider removing the empty setUp method.

The autowired fields are correctly set up for the test class. However, there's an empty setUp method that doesn't serve any purpose in its current state.

If you don't plan to use the setUp method, consider removing it to keep the code clean:

-    @BeforeEach
-    public void setUp() {
-    }

If you intend to use it later, you may want to add a TODO comment explaining its future use.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 90a2a13 and ba6f9f8.

🔇 Files ignored due to path filters (1)
  • kinde-springboot/kinde-springboot-core/pom.xml is excluded by !**/*.xml
📒 Files selected for processing (22)
  • README.md (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/KindeOAuth2AutoConfig.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/ReactiveKindeOAuth2ServerHttpServerAutoConfig.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/TokenUtil.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/env/KindeOAuth2PropertiesMappingEnvironmentPostProcessor.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeJwtAuthenticationConverterTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2AutoConfigTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2ConfigurerTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2ResourceServerAutoConfigTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2UserServiceTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOidcUserServiceTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2AutoConfigTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2ResourceServerAutoConfigTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2ResourceServerHttpServerAutoConfigTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2ServerHttpServerAutoConfigTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2UserServiceTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOidcUserServiceTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/TokenUtilTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/UserUtilTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/WebClientUtilTest.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/token/jwt/JwtGenerator.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/TokenUtil.java
🧰 Additional context used
📓 Learnings (1)
kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/token/jwt/JwtGenerator.java (2)
Learnt from: brettchaldecott
PR: kinde-oss/kinde-java-sdk#21
File: kinde-core/src/test/java/com/kinde/token/jwt/JwtGenerator.java:82-110
Timestamp: 2024-08-19T09:42:12.291Z
Learning: Hardcoded claims and key IDs in the `refreshToken` method are acceptable for testing purposes.
Learnt from: brettchaldecott
PR: kinde-oss/kinde-java-sdk#21
File: kinde-core/src/test/java/com/kinde/token/jwt/JwtGenerator.java:19-48
Timestamp: 2024-08-19T09:41:56.859Z
Learning: The `generateAccessToken` method in `JwtGenerator` is used for testing purposes, and hardcoded values are acceptable in this context.
🔇 Additional comments not posted (22)
kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/TokenUtilTest.java (1)

1-15: LGTM: Class structure and imports are appropriate.

The test class is well-structured with the correct package and necessary imports for JUnit 5, Mockito, and Spring Security classes.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2ConfigurerTest.java (1)

1-13: LGTM: Package declaration and imports are correct.

The package declaration and imports are appropriate for the test class. All necessary dependencies are imported, and there are no unused imports.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2UserServiceTest.java (1)

16-30: ⚠️ Potential issue

Enhance test method with assertions and improve method name

The current test method lacks assertions, which are crucial for verifying the expected behavior of the loadUser method. Additionally, the test method name could be more descriptive.

Consider the following improvements:

  1. Add assertions to verify the expected outcome of the loadUser method call.
  2. Use a more descriptive name for the test method, following the given-when-then pattern.
  3. Consider breaking down the test into multiple methods to test different scenarios.

Here's an example of how you could improve the test:

@Test
public void givenValidUserRequest_whenLoadUser_thenReturnsExpectedOidcUser() {
    // ... existing setup code ...

    // When
    OidcUser result = reactiveKindeOidcUserService.loadUser(userRequest).block();

    // Then
    assertNotNull(result);
    // Add more specific assertions based on the expected behavior
    // For example:
    // assertEquals(expectedUsername, result.getUsername());
    // assertTrue(result.getAuthorities().contains(new SimpleGrantedAuthority("ROLE_USER")));
}

Also, consider adding more test methods to cover different scenarios, such as:

  • givenInvalidUserRequest_whenLoadUser_thenThrowsException()
  • givenUserRequestWithCustomClaims_whenLoadUser_thenReturnsUserWithCustomAttributes()

To ensure comprehensive test coverage, let's analyze the ReactiveKindeOidcUserService class:

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOidcUserServiceTest.java (1)

1-15: LGTM: Package declaration and imports are correct.

The package declaration and imports are appropriate for the test class. All necessary classes are imported, and there are no unused imports.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2ResourceServerHttpServerAutoConfigTest.java (2)

1-14: LGTM: Package declaration and imports are appropriate.

The package declaration and imports are correct and relevant for a Spring Boot test class testing the Kinde OAuth2 configuration.


1-44: Summary: Good test coverage, minor improvements suggested

This new test class provides coverage for the ReactiveKindeOAuth2ResourceServerHttpServerAutoConfig as intended, aligning with the PR objective of enhancing test coverage for the Spring Boot framework within the Kinde Java SDK.

Key points:

  1. The test setup and configuration are well-structured.
  2. Minor improvements have been suggested, including shortening the class name, removing a debug print statement, and adding assertions to the test method.

These changes will further enhance the quality and effectiveness of the test coverage. Overall, this addition contributes positively to the SDK's test suite.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeTest.java (1)

1-16: LGTM: Package declaration and imports are appropriate.

The package declaration and imports are well-organized and relevant to the test class. All imported classes are used within the test methods.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2AutoConfigTest.java (1)

1-18: LGTM: Imports and package declaration are appropriate.

The package declaration and imports are well-organized and relevant for a Spring Boot test class. All imported classes are used within the test file.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOidcUserServiceTest.java (1)

1-20: LGTM: Package declaration and imports are appropriate.

The package declaration and imports are well-organized and relevant to the test class. All necessary classes for JUnit 5, Mockito, and Spring Security are correctly imported.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2ResourceServerAutoConfigTest.java (2)

1-31: LGTM: Class structure and annotations are well-defined.

The test class is properly structured with appropriate annotations (@TestPropertySource and @SpringBootTest) and necessary imports. The package declaration and import statements are correct for the test's purpose.


1-70: Overall, good test structure with room for minor improvements.

The ReactiveKindeOAuth2ResourceServerAutoConfigTest class is well-structured and follows good practices for Spring Boot testing. Here's a summary of the strengths and areas for improvement:

Strengths:

  1. Proper use of @SpringBootTest and @TestPropertySource annotations.
  2. Well-structured inner TestConfiguration class for providing test beans.
  3. Good use of mocking for dependencies.

Areas for improvement:

  1. Remove unnecessary println statement in the reactiveKindeOAuth2AutoConfig method.
  2. Enhance the test method with assertions and correct naming.
  3. Consider adding more test methods to cover different scenarios and increase test coverage.

To ensure comprehensive test coverage, please run the following command to check the test coverage for the ReactiveKindeOAuth2ResourceServerAutoConfig class:

This script will help identify all public methods in the ReactiveKindeOAuth2ResourceServerAutoConfig class, allowing you to verify that each method is adequately tested in the corresponding test class.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/ReactiveKindeOAuth2ServerHttpServerAutoConfigTest.java (1)

1-17: LGTM: Package declaration and imports are appropriate.

The package declaration and imports are well-organized and relevant to the test class. All necessary classes are imported, and there are no unused imports.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2UserServiceTest.java (1)

1-23: LGTM: Package declaration and imports are correct.

The package declaration matches the file location, and all necessary imports for WireMock, JUnit, Mockito, and Spring Security are present. There are no unused imports.

kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/KindeOAuth2AutoConfig.java (2)

42-45: Excellent improvement in dependency injection approach.

The addition of this setter method for kindeSdkClient is a positive change. It shifts from field injection to setter injection, which is considered a best practice in Spring for several reasons:

  1. It improves testability by allowing the dependency to be easily mocked or stubbed in unit tests.
  2. It increases flexibility by enabling the dependency to be changed at runtime if needed.
  3. It makes the dependency more explicit and easier to manage.

49-53: Approve changes to oidcLogoutSuccessHandler, but verify impact.

The modifications to the oidcLogoutSuccessHandler method are logical and align with the new approach of using KindeSdkClient for configuration. This centralization can lead to better consistency in managing OAuth2 configurations.

However, it's important to ensure that this change doesn't negatively impact other parts of the codebase that might expect KindeOAuth2Properties to be used for logout configuration.

To verify the impact of this change, please run the following script:

This script will help identify any remaining usages of KindeOAuth2Properties for logout configuration in other parts of the codebase, which might need to be updated to align with this new approach.

✅ Verification successful

Please proceed with additional verification to ensure no remaining references to KindeOAuth2Properties exist.


Approve removal of KindeOAuth2Properties from oidcLogoutSuccessHandler.

The change effectively eliminates the dependency on KindeOAuth2Properties within the oidcLogoutSuccessHandler method. Comprehensive searches confirmed that no other parts of the main codebase rely on KindeOAuth2Properties, ensuring that this modification does not introduce regressions.

[Test configurations and related classes continue to utilize KindeOAuth2Properties as expected.]

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usages of KindeOAuth2Properties for logout configuration

# Search for KindeOAuth2Properties usage related to logout
echo "Searching for KindeOAuth2Properties usage related to logout..."
rg --type java "KindeOAuth2Properties.*logout" -g '!**/KindeOAuth2AutoConfig.java'

# Search for other methods that might be impacted by this change
echo "Searching for other methods that might be impacted..."
rg --type java "oidcLogoutSuccessHandler.*KindeOAuth2Properties" -g '!**/KindeOAuth2AutoConfig.java'

Length of output: 439


Script:

#!/bin/bash
# Description: Comprehensive check for any usages of KindeOAuth2Properties

# Search for any usage of KindeOAuth2Properties
echo "Searching for all usages of KindeOAuth2Properties..."
rg --type java "KindeOAuth2Properties" 

# Check for imports of KindeOAuth2Properties
echo "Searching for imports of KindeOAuth2Properties..."
rg --type java "import .*KindeOAuth2Properties;" 

# Search for instantiations or method calls involving KindeOAuth2Properties
echo "Searching for instantiations or method calls with KindeOAuth2Properties..."
rg --type java "new KindeOAuth2Properties\(" 
rg --type java "\.kindeOAuth2Properties\."

Length of output: 22331

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2AutoConfigTest.java (1)

1-48: LGTM: Test setup and imports look good.

The class-level annotations and imports are well-structured and appropriate for this test class. The @TestPropertySource is correctly used to set up test properties, and the @SpringBootTest and @Import annotations properly configure the test context.

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/UserUtilTest.java (1)

1-26: LGTM: Import statements are appropriate and concise.

The import statements cover all necessary classes for the test implementation, including Spring Security components, Mockito for mocking, and JUnit for testing. There are no apparent unused imports.

kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/ReactiveKindeOAuth2ServerHttpServerAutoConfig.java (1)

Line range hint 1-134: Summary: Approve the change and suggest broader verification.

The change from Okta to Kinde OAuth2 properties in the oidcClientInitiatedServerLogoutSuccessHandler method is appropriate and consistent with the rest of the file. The implementation appears to be correctly adapted for Kinde OAuth2.

To ensure a complete transition from Okta to Kinde OAuth2, please run the following script to verify that no Okta-specific configurations or dependencies remain in the project:

If the script returns any results, review those occurrences to ensure they have been properly transitioned to Kinde OAuth2 equivalents.

README.md (2)

56-56: Approve the build command change with suggestions.

The update from mvn clean install to mvn -B clean package is a good improvement for CI/CD compatibility and consistency. However, I have a few suggestions:

  1. Consider adding a brief note explaining the implications of this change, especially for developers who might have been using the install command for local development.

  2. The -B flag (batch mode) is a good addition for non-interactive environments, but it might be worth mentioning this in a comment for clarity.

Could you confirm if this change is intentional and how it aligns with the PR objectives of "Feature/sdk rework test coverage"? While it's a good change, it doesn't seem directly related to improving test coverage.


Line range hint 1-1: Overall README review

The README appears to be comprehensive and up-to-date. It covers installation, usage, configuration, and contribution guidelines effectively. The single change made improves the build process description.

However, given that the PR is titled "Feature/sdk rework test coverage", it's worth noting that:

  1. The README doesn't mention any specific improvements to test coverage.
  2. There are no visible changes to the testing section or documentation about new tests.

Could you clarify if there should be any updates to the README regarding improved test coverage for the Spring Boot components, as mentioned in the PR description? If so, consider adding a section about the enhanced test coverage and any new testing practices or requirements.

kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/env/KindeOAuth2PropertiesMappingEnvironmentPostProcessor.java (1)

20-20: Verify the intention behind making the class public and non-final.

The class KindeOAuth2PropertiesMappingEnvironmentPostProcessor has been changed from final to public. While this change allows for better testability, it also opens up the possibility for external use and extension of this class.

Please confirm if this change is intentional and necessary for the test coverage improvements mentioned in the PR objectives. If so, consider adding Javadoc comments to document the class's purpose and usage for potential external consumers.

To verify the impact of this change, you can run the following script:

✅ Verification successful

Change Verified: Class Visibility Adjustment is Appropriate

The modification of KindeOAuth2PropertiesMappingEnvironmentPostProcessor from final to public is justified based on its usage in test cases. To enhance clarity and maintainability, please consider adding Javadoc comments to document the class's purpose and intended usage.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any new usages or extensions of KindeOAuth2PropertiesMappingEnvironmentPostProcessor

# Test: Search for new usages of the class
echo "Searching for new usages of KindeOAuth2PropertiesMappingEnvironmentPostProcessor:"
rg --type java "KindeOAuth2PropertiesMappingEnvironmentPostProcessor" -g '!**/KindeOAuth2PropertiesMappingEnvironmentPostProcessor.java'

# Test: Search for any extensions of the class
echo "Searching for extensions of KindeOAuth2PropertiesMappingEnvironmentPostProcessor:"
rg --type java "extends\s+KindeOAuth2PropertiesMappingEnvironmentPostProcessor"

Length of output: 7124

kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/token/jwt/JwtGenerator.java (1)

16-46: 🛠️ Refactor suggestion

Consider refactoring to reduce code duplication

The methods generateAccessToken, generateIDToken, and refreshToken contain duplicated code for RSA key generation, signer initialization, claim construction, and token signing.

To enhance maintainability and readability, consider extracting the common functionality into helper methods or utility classes.

Also applies to: 48-85, 87-116

⛔ Skipped due to learnings
Learnt from: brettchaldecott
PR: kinde-oss/kinde-java-sdk#21
File: kinde-core/src/test/java/com/kinde/token/jwt/JwtGenerator.java:82-110
Timestamp: 2024-08-19T09:42:12.291Z
Learning: Hardcoded claims and key IDs in the `refreshToken` method are acceptable for testing purposes.
Learnt from: brettchaldecott
PR: kinde-oss/kinde-java-sdk#21
File: kinde-core/src/test/java/com/kinde/token/jwt/JwtGenerator.java:19-48
Timestamp: 2024-08-19T09:41:56.859Z
Learning: The `generateAccessToken` method in `JwtGenerator` is used for testing purposes, and hardcoded values are acceptable in this context.

Brett Chaldecott added 3 commits September 26, 2024 06:32
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/KindeOAuth2Configurer.java (1)

Line range hint 47-70: Consider adding a comment explaining the removal of opaque token validation.

To improve code maintainability and help future developers understand the changes made, consider adding a comment explaining why the opaque token validation was removed. This will provide context for the simplification and help prevent accidental reintroduction of unnecessary complexity.

Here's a suggested comment to add:

// Opaque token validation has been removed to simplify the resource server configuration process.
// JWT validation is now the primary method for token validation in this SDK.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ba6f9f8 and 59a824d.

⛔ Files ignored due to path filters (2)
  • kinde-core/pom.xml is excluded by !**/*.xml
  • kinde-springboot/kinde-springboot-core/pom.xml is excluded by !**/*.xml
📒 Files selected for processing (2)
  • kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/KindeOAuth2Configurer.java (1 hunks)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2ConfigurerTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • kinde-springboot/kinde-springboot-core/src/test/java/com/kinde/spring/KindeOAuth2ConfigurerTest.java
🔇 Additional comments (2)
kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/KindeOAuth2Configurer.java (2)

47-47: LGTM: Updated comment reflects the shift to Kinde.

The comment change from "configure Okta user services" to "configure kinde user services" accurately reflects the transition from Okta to Kinde in the SDK. This change improves code clarity and aligns with the PR objectives.


Line range hint 47-70: Verify the impact of removing opaque token validation.

The removal of the opaque token validation logic simplifies the code, but it may impact existing implementations that rely on this feature. Please ensure that this change doesn't break any existing functionality and that all use cases are still covered.

To verify the impact, please run the following script:

This script will help identify any remaining references to opaque token validation in the codebase, potential custom implementations, and related tests that might need to be updated or removed.

DanielRivers and others added 11 commits September 26, 2024 13:28
Working on coverage.
Fixed readme
Implemented beginnings of tests
Updated the kinde test
Continued extending test coverage for Spring starter
Completed load user tests
Increased test coverage
Increased test coverage
Brett Chaldecott added 5 commits September 26, 2024 14:35
Fixed test coverage and correct variable names
Corrected test coverage
Corrected pom file
…aldecott/kinde-java-sdk into feature/sdk-rework-test-coverage
Copy link

codecov bot commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@90a2a13). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...n/java/com/kinde/spring/KindeOAuth2AutoConfig.java 0.00% 3 Missing ⚠️
...ReactiveKindeOAuth2ServerHttpServerAutoConfig.java 0.00% 1 Missing ⚠️
...uth2PropertiesMappingEnvironmentPostProcessor.java 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #23   +/-   ##
=======================================
  Coverage        ?   42.44%           
  Complexity      ?      175           
=======================================
  Files           ?       53           
  Lines           ?      959           
  Branches        ?       77           
=======================================
  Hits            ?      407           
  Misses          ?      515           
  Partials        ?       37           
Files with missing lines Coverage Δ
...n/java/com/kinde/spring/KindeOAuth2Configurer.java 0.00% <ø> (ø)
...core/src/main/java/com/kinde/spring/TokenUtil.java 0.00% <ø> (ø)
...ReactiveKindeOAuth2ServerHttpServerAutoConfig.java 0.00% <0.00%> (ø)
...uth2PropertiesMappingEnvironmentPostProcessor.java 0.00% <0.00%> (ø)
...n/java/com/kinde/spring/KindeOAuth2AutoConfig.java 0.00% <0.00%> (ø)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
.github/workflows/maven.yml (2)

31-38: Excellent addition of test coverage reporting

The introduction of JaCoCo for test coverage reporting is a significant improvement. Running separate reports for different modules provides more detailed insights into the test coverage across the project structure.

Consider adding a step to combine the coverage reports from both modules for a unified project-wide coverage view. This could be achieved using JaCoCo's report aggregation feature.

Example:

- name: Aggregate JaCoCo reports
  run: mvn jacoco:report-aggregate

40-45: Great addition of Codecov integration

The integration with Codecov will greatly improve the visibility of test coverage and help track coverage changes over time. The configuration looks correct and follows security best practices by using a secret for the Codecov token.

Consider adding a fail_ci_if_error: true option to the Codecov action. This will cause the CI to fail if there's an issue with uploading the coverage report, ensuring that coverage data is always successfully uploaded.

Example:

- name: Upload coverage to Codecov
  uses: codecov/codecov-action@v4
  with:
    files: '**/target/site/jacoco/jacoco.xml'
    fail_ci_if_error: true
  env:
    CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 59a824d and 493a575.

⛔ Files ignored due to path filters (2)
  • playground/springboot-pkce-client-example/pom.xml is excluded by !**/*.xml
  • pom.xml is excluded by !**/*.xml
📒 Files selected for processing (1)
  • .github/workflows/maven.yml (2 hunks)
🔇 Additional comments (2)
.github/workflows/maven.yml (2)

20-20: LGTM: Improved readability

The addition of this blank line enhances the readability of the workflow file by clearly separating the job configuration from the steps.


Line range hint 20-45: Excellent enhancements to the CI workflow

The changes made to this workflow file significantly improve the CI process by introducing detailed test coverage reporting and integration with Codecov. These enhancements align perfectly with the PR objectives of improving test coverage for the SDK.

Key improvements:

  1. Introduction of JaCoCo for generating test coverage reports.
  2. Separate coverage reporting for different modules, allowing for more granular insights.
  3. Integration with Codecov for easy visualization and tracking of coverage metrics.

These changes will contribute to maintaining high code quality and will provide valuable insights for future development. Great work on enhancing the CI pipeline!

@DanielRivers DanielRivers merged commit 0224847 into kinde-oss:main Sep 26, 2024
4 checks passed
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.

2 participants