Skip to content

Addmoretests #3

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Addmoretests #3

wants to merge 6 commits into from

Conversation

phbnf
Copy link
Owner

@phbnf phbnf commented Apr 8, 2025

No description provided.

phbnf added 5 commits April 8, 2025 09:03
# Conflicts:
#	internal/scti/handlers_test.go

# Conflicts:
#	internal/scti/handlers_test.go
# Conflicts:
#	internal/scti/handlers_test.go
Copy link

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

Hello @phbnf, 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!

Summary of Changes

This pull request focuses on adding more tests to the internal/scti/handlers_test.go file, enhancing the test coverage for the AddChain and AddPreChain handlers. The changes include setting up a temporary directory for storage during tests, creating subdirectories for logs and issuers, and verifying the content of the leaf bundle after adding a chain or pre-chain. Additionally, there are minor updates to the internal/scti/handlers.go file, such as adding TODO comments for future improvements.

Highlights

  • Test Coverage: Extensive tests added for AddChain and AddPreChain handlers, including checks for successful additions, duplicates, and chains without root certificates.
  • Storage Setup: Introduced temporary directories for test storage, ensuring a clean testing environment and preventing conflicts.
  • Leaf Bundle Verification: Added verification steps to confirm the content of the leaf bundle after adding a chain or pre-chain, ensuring data integrity.

Changelog

Click here to see the changelog
  • internal/scti/handlers.go
    • Added TODO comments to verifyAddChain function, suggesting the addition of tests and moving the function to chain_validation.go.
    • Added TODO comments to entryFromChain function, suggesting moving it to ct.go and adding tests.
  • internal/scti/handlers_test.go
    • Added imports for crypto/x509, os, path, github.com/transparency-dev/trillian-tessera/api/layout, and github.com/transparency-dev/trillian-tessera/ctonly.
    • Introduced logDir and issDir constants for POSIX subdirectories.
    • Modified setupTestLog function to create a temporary directory for storage.
    • Modified newPosixStorageFunc to use the temporary directory for creating POSIX Tessera storage driver, issuer storage, and BBolt deduplication database.
    • Added parseChain function to parse a chain of certificates and create a ctonly.Entry.
    • Enhanced TestAddChain and TestAddPreChain to verify the content of the leaf bundle after adding a chain or pre-chain.
  • internal/types/staticct/staticct.go
    • Added Entry struct to represent a CT log entry, including fields for timestamp, precert status, certificate data, issuer key hash, fingerprints, extensions, and leaf index.
    • Implemented UnmarshalText method for the Entry struct to decode entry bundles from the Static CT API spec.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


In code we trust, tests we must,
To verify each handler's gust.
Chains and trees,
Put minds at ease,
Ensuring logs are free from rust.

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.

@phbnf
Copy link
Owner Author

phbnf commented Apr 8, 2025

/gemini review

Copy link

@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

The pull request adds more tests to the scti package, focusing on handlers and data types. The changes include adding new test cases for AddChain and AddPreChain handlers, improving the newPosixStorageFunc to handle temporary directories, and introducing a new Entry type with UnmarshalText method for parsing CT log entries. Overall, the changes seem to improve the test coverage and data handling within the scti package.

Summary of Findings

  • Missing tests for verifyAddChain: The verifyAddChain function lacks dedicated tests, as indicated by the TODO comment. Adding tests for this function is crucial to ensure its correctness and reliability.
  • Potential for code duplication: The entryFromChain function might be better placed in ct.go to avoid potential code duplication and improve code organization.
  • Incomplete checks in TestAddChain and TestAddPreChain: The tests for AddChain and AddPreChain are missing checks for the issuer chain fingerprint and inclusion proof. Implementing these checks would enhance the test coverage and ensure the integrity of the log entries.
  • TODO comments: There are a number of TODO comments that should be addressed to improve the code quality.

Merge Readiness

The pull request introduces valuable tests and data handling improvements. However, addressing the missing tests for verifyAddChain, considering the relocation of entryFromChain, and completing the checks in TestAddChain and TestAddPreChain would significantly enhance the quality and reliability of the code. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. Given the medium and high severity issues identified, I recommend that the pull request not be merged until these are addressed.

t.Errorf("Logged entry mismatch (-want +got):\n%s", diff)
}
// TODO(phbnf): check the issuer chain fingerprint
// TODO(phbnf): check inclusion proof
// TODO(phboneff): add a test with a backend write failure

Choose a reason for hiding this comment

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

high

Consider adding a test with a backend write failure to ensure the system handles such failures gracefully. This could involve simulating a disk full scenario or a permission error.

Comment on lines +396 to +397
// TODO(phbnf): add tests
// TODO(phbnf): move to chain_validation.go

Choose a reason for hiding this comment

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

medium

It's great that you've added TODOs for tests and moving this function. Consider adding a brief description of what these tests should cover, or what the motivation is for moving the function.

Comment on lines +457 to +458
// TODO(phboneff): move to ct.go
// TODO(phboneff): add tests

Choose a reason for hiding this comment

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

medium

Consider adding a brief description of what these tests should cover, or what the motivation is for moving the function.

Comment on lines +560 to +561
// TODO(phbnf): check the issuer chain fingerprint
// TODO(phbnf): check inclusion proof

Choose a reason for hiding this comment

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

medium

These TODOs are great. It would be helpful to add a brief description of what these checks should entail.

Comment on lines +560 to +561
// TODO(phbnf): check the issuer chain fingerprint
// TODO(phbnf): check inclusion proof

Choose a reason for hiding this comment

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

medium

These TODOs are great. It would be helpful to add a brief description of what these checks should entail.

Comment on lines +686 to +687
// TODO(phbnf): check the issuer chain fingerprint
// TODO(phbnf): check inclusion proof

Choose a reason for hiding this comment

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

medium

These TODOs are great. It would be helpful to add a brief description of what these checks should entail.

Comment on lines +686 to +687
// TODO(phbnf): check the issuer chain fingerprint
// TODO(phbnf): check inclusion proof

Choose a reason for hiding this comment

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

medium

These TODOs are great. It would be helpful to add a brief description of what these checks should entail.

Copy link

@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

The pull request adds more tests to the scti package, focusing on handlers and staticct types. The changes include adding new test cases for AddChain and AddPreChain handlers, as well as refactoring some test setup code for better reusability. The addition of tests for reading leaf bundles and comparing entries is a significant improvement. However, there are some areas where the code can be improved, particularly in terms of TODO comments and code clarity.

Summary of Findings

  • Missing tests: The verifyAddChain function lacks dedicated tests, and it's recommended to add them for better coverage.
  • Code placement: The entryFromChain function could be moved to ct.go for better organization.
  • TODO comments: Several TODO comments exist in the code, indicating areas that need further attention, such as checking issuer chain fingerprints and inclusion proofs.

Merge Readiness

The pull request introduces valuable tests and improves the overall test coverage. However, the presence of TODO comments and the lack of tests for verifyAddChain indicate that there's still work to be done. I recommend addressing the TODO comments and adding tests for verifyAddChain before merging. I am unable to approve this pull request, and users should have others review and approve this code before merging.

Comment on lines +396 to +397
// TODO(phbnf): add tests
// TODO(phbnf): move to chain_validation.go

Choose a reason for hiding this comment

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

medium

Consider adding tests for verifyAddChain to ensure it handles various scenarios correctly. Also, moving this function to chain_validation.go would improve code organization.

Comment on lines +457 to +458
// TODO(phboneff): move to ct.go
// TODO(phboneff): add tests

Choose a reason for hiding this comment

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

medium

Moving entryFromChain to ct.go would align it with related functionality and improve modularity. Adding tests for this function is also recommended.

Comment on lines +560 to +561
// TODO(phbnf): check the issuer chain fingerprint
// TODO(phbnf): check inclusion proof

Choose a reason for hiding this comment

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

medium

Consider adding checks for the issuer chain fingerprint and inclusion proof to ensure the integrity of the logged entry.

Comment on lines +561 to +562
// TODO(phbnf): check inclusion proof
// TODO(phbnf): add a test with a backend write failure

Choose a reason for hiding this comment

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

medium

Adding a test case with a backend write failure would improve the robustness of the test suite.

Comment on lines +686 to +687
// TODO(phbnf): check the issuer chain fingerprint
// TODO(phbnf): check inclusion proof

Choose a reason for hiding this comment

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

medium

Consider adding checks for the issuer chain fingerprint and inclusion proof to ensure the integrity of the logged entry.

Comment on lines +687 to 688
// TODO(phbnf): check inclusion proof
// TODO(phboneff): add a test with a backend write failure

Choose a reason for hiding this comment

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

medium

Adding a test case with a backend write failure would improve the robustness of the test suite.

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