Skip to content

fix(tests): use in-memory secure storage to eliminate keychain prompts#299

Draft
Super-Genius wants to merge 2 commits into
developfrom
fix/test-memory-secure-storage
Draft

fix(tests): use in-memory secure storage to eliminate keychain prompts#299
Super-Genius wants to merge 2 commits into
developfrom
fix/test-memory-secure-storage

Conversation

@Super-Genius

Copy link
Copy Markdown
Contributor

Summary

Replaces macOS keychain-backed secure storage with in-memory storage for test builds. Eliminates ~20 keychain password prompts per test run.

Changes

  • New: src/local_secure_storage/impl/MemorySecureStorage.hpp — in-memory JSON backend, no OS keychain access
  • Updated: SecureStorage.hpp — respects SGNS_USE_MEMORY_SECURE_STORAGE compile flag
  • Updated: CommonBuildParameters.cmake — adds flag before library build when BUILD_TESTING=ON
  • Updated: secure_storage_test.cpp — uses MemorySecureStorage on macOS

How it works

When BUILD_TESTING=ON, the cmake build adds -DSGNS_USE_MEMORY_SECURE_STORAGE globally. This causes SecureStorageImpl to resolve to MemorySecureStorage (in-memory map) instead of AppleSecureStorage (macOS keychain). Both library and test targets get the flag.

Testing

cd build/OSX/Debug
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug
ninja -j4
ctest --output-on-failure -j4

Zero keychain prompts expected.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 888eeedbe4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread build/CommonBuildParameters.cmake Outdated
Comment on lines +468 to +469
if(BUILD_TESTING)
add_compile_definitions(SGNS_USE_MEMORY_SECURE_STORAGE)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep memory storage out of non-test targets

Because BUILD_TESTING is set to ON by default near the top of this file, this global definition is applied to add_subdirectory(src) in a default build, not just to test executables. Any application/library code that includes SecureStorage.hpp (for example GeniusAccount::CreateSecureStorage) will therefore alias SecureStorageImpl to MemorySecureStorage, so accounts generated by a default build are kept only in process memory while the public-key index is still written to disk; after restart the key cannot be loaded from the OS store. Please restrict this define to test targets or make it opt-in only for the specific tests that need it.

Useful? React with 👍 / 👎.

Split genius_node into two libraries:
- genius_node: production, uses OS keychain (Apple/Windows/Linux)
- genius_node_test: tests, uses MemorySecureStorage (in-memory)

All test targets link against genius_node_test. No global cmake flags.

Also adds MemorySecureStorage implementation and updates secure_storage_test
to use it on macOS.

Addresses Codex review P1: keep memory storage out of non-test targets.
@Super-Genius Super-Genius force-pushed the fix/test-memory-secure-storage branch from 888eeed to 82ac885 Compare June 1, 2026 19:09
@Super-Genius Super-Genius marked this pull request as draft June 1, 2026 20:02
…rompts

Replace compile-time SGNS_USE_MEMORY_SECURE_STORAGE approach with a runtime
DI factory in GeniusAccount. Tests call SetSecureStorageFactory() to inject
MemorySecureStorage, eliminating macOS keychain prompts without relying on
platform-specific compile flags.

Changes:
- Add SecureStorageFactory type and Set/GetSecureStorageFactory() to GeniusAccount
- CreateSecureStorage() uses injected factory when set, falls back to default
- Existing tests inject MemorySecureStorage via factory in SetUp/fixture
- Remove stale test CMakeLists entries from other branches
- Keep genius_node_test library split from previous commit

All 60 tests pass with zero keychain prompts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Super-Genius

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3d1af079e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +124 to +125
add_library(genius_node_test ${GENIUS_NODE_SOURCES})
target_link_libraries(genius_node_test ${GENIUS_NODE_LIBS})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Configure the test target to use memory storage

For test binaries that were switched to link genius_node_test but never call GeniusAccount::SetSecureStorageFactory (for example test/src/processing_nodes/processing_nodes_test.cpp:40 creates a node via GeniusNode::New), this target is compiled from the same sources and link libraries as genius_node and does not define SGNS_USE_MEMORY_SECURE_STORAGE, so CreateSecureStorage still falls back to the platform SecureStorageImpl and can hit the macOS keychain. Please either add the memory-storage compile definition to this target or install the factory in those test binaries; otherwise several tests still prompt despite linking the new target.

Useful? React with 👍 / 👎.

Super-Genius added a commit that referenced this pull request Jun 9, 2026
- 8 new auto-filed test-failure bugs (#300-#307)
- 3 open PRs: #309 bridge_phase5, #308 crdt-3.5-backport, #299 memory-secure-storage
- Updated bridge, consensus perf, and stale-item sections
- Gate violations noted: no PR/issue templates exist in repo

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@EduMenges EduMenges force-pushed the develop branch 3 times, most recently from 128165d to afb4967 Compare June 10, 2026 20:13
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