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

build: fix mocks #181

Merged
merged 1 commit into from
Dec 8, 2024
Merged

build: fix mocks #181

merged 1 commit into from
Dec 8, 2024

Conversation

james-d-elliott
Copy link
Member

No description provided.

@james-d-elliott james-d-elliott requested a review from a team as a code owner December 8, 2024 06:40
Copy link

coderabbitai bot commented Dec 8, 2024

Warning

Rate limit exceeded

@james-d-elliott has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 20 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 28ed23e and ee48852.

⛔ Files ignored due to path filters (3)
  • .github/workflows/format.yml is excluded by !**/*.yml
  • .github/workflows/generate.yml is excluded by !**/*.yml
  • .github/workflows/test.yml is excluded by !**/*.yml
📒 Files selected for processing (38)
  • access_request_handler_test.go (8 hunks)
  • generate-mocks.sh (1 hunks)
  • generate.go (1 hunks)
  • testing/mock/access_request.go (3 hunks)
  • testing/mock/access_response.go (4 hunks)
  • testing/mock/access_token_storage.go (2 hunks)
  • testing/mock/access_token_strategy.go (2 hunks)
  • testing/mock/authorize_code_storage.go (2 hunks)
  • testing/mock/authorize_code_strategy.go (2 hunks)
  • testing/mock/authorize_handler.go (2 hunks)
  • testing/mock/authorize_request.go (4 hunks)
  • testing/mock/authorize_response.go (2 hunks)
  • testing/mock/client.go (1 hunks)
  • testing/mock/client_secret.go (2 hunks)
  • testing/mock/device_authorization_request.go (3 hunks)
  • testing/mock/device_handler.go (3 hunks)
  • testing/mock/device_oauth2_handler.go (3 hunks)
  • testing/mock/hash.go (0 hunks)
  • testing/mock/id_token_strategy.go (2 hunks)
  • testing/mock/introspector.go (2 hunks)
  • testing/mock/oauth2_auth_jwt_storage.go (2 hunks)
  • testing/mock/oauth2_client_storage.go (2 hunks)
  • testing/mock/oauth2_device_auth_storage.go (2 hunks)
  • testing/mock/oauth2_owner_storage.go (2 hunks)
  • testing/mock/oauth2_revoke_storage.go (2 hunks)
  • testing/mock/oauth2_storage.go (2 hunks)
  • testing/mock/oauth2_strategy.go (2 hunks)
  • testing/mock/openid_id_token_storage.go (2 hunks)
  • testing/mock/pkce_storage.go (3 hunks)
  • testing/mock/pushed_authorize_handler.go (2 hunks)
  • testing/mock/refresh_token_storage.go (2 hunks)
  • testing/mock/refresh_token_strategy.go (2 hunks)
  • testing/mock/request.go (3 hunks)
  • testing/mock/revoke_handler.go (2 hunks)
  • testing/mock/rw.go (2 hunks)
  • testing/mock/storage.go (2 hunks)
  • testing/mock/token_handler.go (2 hunks)
  • testing/mock/transactional.go (2 hunks)

Walkthrough

The changes involve modifications to several test and generation files within the codebase. The access_request_handler_test.go file simplifies mock function signatures by removing unnecessary parameters. The generate-mocks.sh and generate.go scripts update the mock generation for the PKCERequestStorage interface to include a custom mock name. Additionally, the testing/mock/hash.go file has been deleted, removing the MockHasher implementation, while testing/mock/pkce_storage.go reflects updates to accommodate the new mock naming conventions and interface references.

Changes

File Change Summary
access_request_handler_test.go Updated mock function signatures in TestNewAccessRequest and TestNewAccessRequestWithoutClientAuth to remove hasher *mock.MockHasher.
generate-mocks.sh Modified mock generation command for PKCERequestStorage to include -mock_names flag for custom naming.
generate.go Updated mock generation command for PKCERequestStorage to include custom mock name MockPKCERequestStorage.
testing/mock/hash.go Deleted file containing MockHasher implementation, including struct and methods for the Hasher interface.
testing/mock/pkce_storage.go Updated mock struct to represent the Storage interface instead of PKCERequestStorage, retaining method signatures.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Cases
    participant Handler as Access Request Handler
    participant Storage as Storage Interface
    participant Mock as Mock Objects

    Test->>Mock: Setup mock expectations
    Mock->>Handler: Call NewAccessRequest()
    Handler->>Storage: Validate request
    Storage-->>Handler: Return validation result
    Handler-->>Test: Return access request result
Loading

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

@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)
generate.go (1)

Line range hint 14-14: Fix typo in RefreshTokenStrategy mock generation

There's a typo in the interface name: ReyfreshTokenStrategy should be RefreshTokenStrategy.

-//go:generate go run go.uber.org/mock/mockgen -package internal -destination internal/refresh_token_strategy.go authelia.com/provider/oauth2/handler/oauth2 ReyfreshTokenStrategy
+//go:generate go run go.uber.org/mock/mockgen -package internal -destination internal/refresh_token_strategy.go authelia.com/provider/oauth2/handler/oauth2 RefreshTokenStrategy
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6bcd25c and 28ed23e.

📒 Files selected for processing (5)
  • access_request_handler_test.go (8 hunks)
  • generate-mocks.sh (1 hunks)
  • generate.go (1 hunks)
  • testing/mock/hash.go (0 hunks)
  • testing/mock/pkce_storage.go (2 hunks)
💤 Files with no reviewable changes (1)
  • testing/mock/hash.go
🔇 Additional comments (6)
testing/mock/pkce_storage.go (2)

2-2: LGTM: Source comment accurately reflects mock generation command

The source comment and mock generation command are properly aligned, indicating that this is a mock of the Storage interface from the pkce package with a custom mock name MockPKCERequestStorage.

Also applies to: 6-6


Line range hint 20-24: LGTM: Mock struct maintains consistent naming

The mock struct definition and its documentation correctly reflect that this is a mock of the Storage interface while maintaining the custom name MockPKCERequestStorage for backward compatibility.

generate-mocks.sh (1)

20-20: LGTM: Mock generation command follows established pattern

The updated command follows the same pattern used for other storage mocks (e.g., RFC8628Storage) by using the -mock_names flag to maintain a consistent naming convention while referencing the correct interface.

generate.go (1)

22-22: LGTM: Internal mock generation maintains consistency

The mock generation command properly aligns with the changes in generate-mocks.sh, ensuring consistent mock naming while generating into the internal package.

access_request_handler_test.go (2)

29-29: LGTM! Mock function signatures simplified consistently

The removal of the hasher parameter from mock function signatures has been implemented consistently across all test cases while maintaining the same test coverage and functionality.

Also applies to: 52-54, 80-82, 110-114, 130-135, 149-154, 176-179, 219-219


Line range hint 1-450: Verify complete removal of MockHasher

Let's verify that all references to MockHasher have been removed from the codebase.

✅ Verification successful

Based on the search results, I can see that there are no remaining references to MockHasher in the codebase. The comprehensive search through the mock directory and the entire codebase using both rg and ast-grep shows no occurrences of MockHasher.

MockHasher has been completely removed

The removal of MockHasher is complete and consistent across the codebase. The test cases in access_request_handler_test.go continue to function correctly as they rely on bcrypt's direct functionality rather than a mock hasher.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to MockHasher

# Search for any remaining references to MockHasher
echo "Searching for remaining MockHasher references..."
rg "MockHasher"

# Search for any remaining references to mock.MockHasher
echo "Searching for remaining mock.MockHasher references..."
rg "mock\.MockHasher"

Length of output: 263


Script:

#!/bin/bash
# Let's try a more comprehensive search for any hash-related mocks or references

# Search for hash-related mock types and interfaces
echo "Searching for hash-related mock types..."
ast-grep --pattern 'type Mock$_Hash$_ $_'

# Search for hash-related imports and uses
echo "Searching for hash-related imports and uses..."
rg -i "hash" --type go

# Search specifically in mock directory
echo "Searching in mock directory..."
fd . -t f -e go "testing/mock" --exec cat {}

Length of output: 72595

@james-d-elliott james-d-elliott merged commit d78a7cd into master Dec 8, 2024
7 checks passed
@james-d-elliott james-d-elliott deleted the build-gen branch December 8, 2024 06:52
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