Skip to content

Conversation

strantalis
Copy link
Member

Proposed Changes

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

@strantalis strantalis requested a review from a team as a code owner June 6, 2025 20:31
@github-actions github-actions bot added the size/s label Jun 6, 2025
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.

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

Hello! Gemini here, providing a summary of this pull request. This PR primarily focuses on refining the test fixtures and integration tests related to KAS (Key Access Server) keys and provider configurations. The main intent seems to be to correctly handle cases where a KAS key might not have an associated provider configuration ID and to update the fixture data with more realistic or properly formatted key contexts. Additionally, it includes some minor cleanup and improvements to the test environment setup.

Highlights

  • KAS Key Fixtures Update: The structure for KAS key fixtures (FixtureDataKasRegistryKey) has been updated to make the ProviderConfigID field a pointer (*string), allowing it to be nil. The fixture data itself (policy_fixtures.yaml) has been updated with new key IDs (rsa_key_1, ec_key_1), different algorithms (RSA and EC), and seemingly more complete base64 encoded private and public key contexts.
  • Integration Test Adjustments: Integration tests for the KAS registry key functionality (kas_registry_key_test.go) have been modified to correctly handle the nullable ProviderConfigID. Assertions comparing ProviderConfigID now dereference the pointer (*s.kasKeys[0].ProviderConfigID). The validateListKeysResponse helper function was updated to accept an expected number of keys and check for nil ProviderConfigID in the response. Some ListKeys test assertions were adjusted for expected counts and pagination offsets.
  • Test Environment Setup Improvement: The main test setup (main_test.go) for the Postgres test container has been improved by adding a random suffix to the container name using uuid to prevent naming conflicts during parallel test runs. The explicit host port binding has been removed, allowing testcontainers to assign a dynamic port. The SQL wait timeout has been increased from 5s to 60s, and the wait query simplified to SELECT 1.
  • Configuration File Tweaks: Minor configuration changes were made in opentdf-dev.yaml and opentdf-kas-mode.yaml, adding preview and root_key settings under the kas section and changing single quotes to double quotes for string values in opentdf-kas-mode.yaml.

Changelog

Click here to see the changelog
  • opentdf-dev.yaml
    • Added preview and root_key configuration under the kas service.
    • Adjusted spacing in commented-out sections.
  • opentdf-kas-mode.yaml
    • Added preview and root_key configuration under the kas service.
    • Changed single quotes to double quotes for audience and allowedorigins values.
  • service/integration/kas_registry_key_test.go
    • Updated assertions in Test_GetKasKeyById_Success, Test_GetKasKeyByKeyId_Success, Test_GetKasKey_WithKasName_Success, and Test_GetKasKey_WithKasUri_Success to dereference the ProviderConfigID pointer.
    • Adjusted expected key counts in Test_ListKeys_KasID_Success, Test_ListKeys_KasName_Success, Test_ListKeys_KasURI_Success, and Test_ListKeys_FilterAlgo_TwoKeys_Success.
    • Corrected the expected NextOffset in Test_ListKeys_KasID_Limit_Success.
    • Modified validateListKeysResponse function signature to accept expected number of keys and updated the assertion.
    • Added a check for nil ProviderConfigID in the validateListKeysResponse helper.
  • service/integration/main_test.go
    • Removed unused import github.com/docker/docker/api/types/container.
    • Added import github.com/google/uuid.
    • Added a random suffix to the Postgres test container name using uuid.
    • Removed explicit HostConfigModifier for port binding.
    • Increased the SQL wait timeout from 5s to 60s and simplified the wait query to SELECT 1.
  • service/internal/fixtures/fixtures.go
    • Changed the type of ProviderConfigID in FixtureDataKasRegistryKey struct from string to *string (pointer).
    • Updated the provisionKasRegistryKeys function to handle nil ProviderConfigID pointers by inserting 'NULL' into the SQL.
  • service/internal/fixtures/policy_fixtures.yaml
    • Removed some empty lines for cleaner formatting.
    • Updated the key_id for kas_key_1 to rsa_key_1.
    • Updated the key_algorithm for kas_key_2 to ALGORITHM_EC_P256 and its key_id to ec_key_1.
    • Updated the private_key_ctx and public_key_ctx values for both KAS keys with new base64 encoded data.
    • Implicitly made provider_config_id optional for KAS keys by changing the struct field to a pointer.
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.


Fixtures fine-tuned,
Keys now nullable, tests pass,
Code review awaits.

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.

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 correctly addresses the PEM formatting in test fixtures and introduces several related improvements, such as making ProviderConfigID optional and enhancing test container stability. The changes are generally positive. However, there are a few areas that need attention, particularly concerning a hardcoded root_key in development configurations and some test assertions that could be more robust or might indicate a misunderstanding of the underlying logic.

Summary of Findings

  • Hardcoded Root Key: The root_key is hardcoded in opentdf-dev.yaml and opentdf-kas-mode.yaml. This could be a security risk if these configurations are used in environments beyond isolated local development. It's recommended to clarify its purpose and consider using environment variables or secrets management.
  • Test Robustness for Optional Fields: In service/integration/kas_registry_key_test.go, ProviderConfigID (which is now a pointer) is dereferenced in several test assertions without a prior nil check. While current fixtures might prevent a panic, this is not robust. The pattern in validateListKeysResponse (checking for nil) should be applied more broadly.
  • Pagination Logic in Test: An assertion for next_offset in Test_ListKeys_KasID_Limit_Success in kas_registry_key_test.go appears to contradict typical pagination logic where more items are available. This needs clarification.
  • YAML Formatting: Minor stylistic changes were made to YAML files (spacing around comments, quote style). These improve consistency but were not commented on directly due to severity settings.
  • Testcontainer Setup Improvements: Changes in service/integration/main_test.go (randomized container names, dynamic port mapping for PostgreSQL, increased startup timeout) are good improvements for test stability and CI compatibility.
  • Fixture Data Handling: The change to make ProviderConfigID in FixtureDataKasRegistryKey a pointer and the corresponding update in provisionKasRegistryKeys to handle SQL NULL values are correctly implemented.

Merge Readiness

The pull request addresses the intended fix for PEM formatting in test fixtures and includes several beneficial updates. However, before merging, I recommend addressing the concerns raised, particularly:

  1. Clarifying the nature of the hardcoded root_key in YAML configurations.
  2. Improving the robustness of test assertions in kas_registry_key_test.go by adding nil checks before dereferencing optional fields.
  3. Reviewing the pagination logic or test assertion for next_offset in Test_ListKeys_KasID_Limit_Success.

Once these medium-severity issues are addressed, the PR should be in a much better state for merging. As an AI, I am not authorized to approve pull requests; please ensure further review and approval from team members.

@strantalis strantalis requested a review from a team as a code owner June 9, 2025 12:24
@strantalis strantalis enabled auto-merge June 9, 2025 12:45
@dmihalcik-virtru dmihalcik-virtru self-requested a review June 9, 2025 17:14
@strantalis strantalis added this pull request to the merge queue Jun 9, 2025
Merged via the queue into opentdf:main with commit 54ffd23 Jun 9, 2025
29 checks passed
@strantalis strantalis deleted the dspx-1162/update-key-fixtures branch June 9, 2025 17:29
github-merge-queue bot pushed a commit that referenced this pull request Jun 24, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.7.0](service/v0.6.0...service/v0.7.0)
(2025-06-24)


### ⚠ BREAKING CHANGES

* **policy:** disable kas grants in favor of key mappings
([#2220](#2220))

### Features

* **authz:** Add caching to keycloak ERS
([#2466](#2466))
([f5b0a06](f5b0a06))
* **authz:** auth svc registered resource GetDecision support
([#2392](#2392))
([5405674](5405674))
* **authz:** authz v2 GetBulkDecision
([#2448](#2448))
([0da3363](0da3363))
* **authz:** cache entitlement policy within authorization service
([#2457](#2457))
([c16361c](c16361c))
* **authz:** ensure logging parity between authz v2 and v1
([#2443](#2443))
([ef68586](ef68586))
* **core:** add cache manager
([#2449](#2449))
([2b062c5](2b062c5))
* **core:** consume RPC interceptor request context metadata in logging
([#2442](#2442))
([2769c48](2769c48))
* **core:** DSPX-609 - add cli-client to keycloak provisioning
([#2396](#2396))
([48e7489](48e7489))
* **core:** ERS cache setup, fix cache initialization
([#2458](#2458))
([d0c6938](d0c6938))
* inject logger and cache manager to key managers
([#2461](#2461))
([9292162](9292162))
* **kas:** expose provider config from key details.
([#2459](#2459))
([0e7d39a](0e7d39a))
* **main:** Add Close() method to cache manager
([#2465](#2465))
([32630d6](32630d6))
* **policy:** disable kas grants in favor of key mappings
([#2220](#2220))
([30f8cf5](30f8cf5))
* **policy:** Restrict deletion of pc with used key.
([#2414](#2414))
([3b40a46](3b40a46))
* **sdk:** allow Connect-Protocol-Version RPC header for cors
([#2437](#2437))
([4bf241e](4bf241e))


### Bug Fixes

* **core:** remove generics on new platform cache manager and client
([#2456](#2456))
([98c3c16](98c3c16))
* **core:** replace opentdf-public client with cli-client
([#2422](#2422))
([fb18525](fb18525))
* **deps:** bump github.com/casbin/casbin/v2 from 2.106.0 to 2.107.0 in
/service in the external group
([#2416](#2416))
([43afd48](43afd48))
* **deps:** bump github.com/opentdf/platform/protocol/go from 0.4.0 to
0.5.0 in /service
([#2470](#2470))
([3a73fc9](3a73fc9))
* **deps:** bump github.com/opentdf/platform/sdk from 0.4.7 to 0.5.0 in
/service ([#2473](#2473))
([ad37476](ad37476))
* **deps:** bump the external group across 1 directory with 2 updates
([#2450](#2450))
([9d8d1f1](9d8d1f1))
* **deps:** bump the external group across 1 directory with 2 updates
([#2472](#2472))
([d45b3c8](d45b3c8))
* only request a token when near expiration
([#2370](#2370))
([556d95e](556d95e))
* **policy:** fix casing bug and get provider config on update.
([#2403](#2403))
([a52b8f9](a52b8f9))
* **policy:** properly formatted pem in test fixtures
([#2409](#2409))
([54ffd23](54ffd23))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants