mirror of
https://github.com/logos-co/logos-cpp-sdk.git
synced 2026-08-31 09:41:06 +00:00
fix: F-002: only allow core and capability module to call informTokenModule (#78)
* only allow core and capability module to call informTokenModule * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI
parent
42a8b9ed5c
commit
448aa9002c
@@ -169,8 +169,19 @@ TEST_F(ModuleProxyTest, InformModuleTokenDelegatesToProvider)
|
||||
m_provider->init(&api);
|
||||
ModuleProxy proxy(m_provider);
|
||||
|
||||
bool result = proxy.informModuleToken("auth", "target_mod", "tok123");
|
||||
// informModuleToken is privileged: only the trusted core/capability_module
|
||||
// channel may plant tokens (F-002). The host seeds the module's own auth
|
||||
// secret under "core"/"capability_module" at init; the legitimate caller
|
||||
// presents that secret. Seed it and present it so this exercises the
|
||||
// delegation path rather than the (now-enforced) authz rejection.
|
||||
TokenManager::instance().clearAllTokens();
|
||||
TokenManager::instance().saveToken("capability_module", "trusted-secret");
|
||||
|
||||
bool result = proxy.informModuleToken("trusted-secret", "target_mod", "tok123");
|
||||
EXPECT_TRUE(result);
|
||||
// Provider's informModuleToken saves via TokenManager
|
||||
EXPECT_EQ(TokenManager::instance().getToken("target_mod"), "tok123");
|
||||
|
||||
// Don't leak the seeded secret into sibling tests sharing the singleton.
|
||||
TokenManager::instance().clearAllTokens();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user