@@ -7,6 +7,62 @@ describe("buzzSetupContract", () => {
77 vi . unstubAllEnvs ( ) ;
88 } ) ;
99
10+ it . each ( [
11+ {
12+ name : "plaintext private key" ,
13+ privateKey : "11" . repeat ( 32 ) ,
14+ } ,
15+ {
16+ name : "private-key SecretRef" ,
17+ privateKey : { source : "env" as const , provider : "default" , id : "BUZZ_EXISTING_KEY" } ,
18+ } ,
19+ ] ) ( "rejects named account setup without changing the existing $name" , ( { privateKey } ) => {
20+ const buzz = {
21+ enabled : false ,
22+ relayUrl : "wss://original.example.com" ,
23+ privateKey,
24+ authTag : '["auth","owner","kind=9","signature"]' ,
25+ } ;
26+ const cfg = { channels : { buzz } } as OpenClawConfig ;
27+ const input = {
28+ relayUrl : "wss://new.example.com" ,
29+ privateKey : "22" . repeat ( 32 ) ,
30+ } ;
31+ const requestedAccountId = "ada" ;
32+ const resolvedAccountId =
33+ buzzSetupContract . resolveAccountId ?.( { cfg, accountId : requestedAccountId , input } ) ??
34+ requestedAccountId ;
35+
36+ expect ( resolvedAccountId ) . toBe ( requestedAccountId ) ;
37+ expect ( buzzSetupContract . validateInput ?.( { cfg, accountId : resolvedAccountId , input } ) ) . toBe (
38+ "Buzz currently supports only the default account." ,
39+ ) ;
40+ expect ( cfg . channels ?. buzz ) . toEqual ( buzz ) ;
41+ } ) ;
42+
43+ it ( "rejects named environment-backed setup without changing the existing bot identity" , ( ) => {
44+ const existingPrivateKey = "11" . repeat ( 32 ) ;
45+ vi . stubEnv ( "BUZZ_PRIVATE_KEY" , existingPrivateKey ) ;
46+ const buzz = {
47+ enabled : false ,
48+ relayUrl : "wss://original.example.com" ,
49+ authTag : '["auth","owner","kind=9","signature"]' ,
50+ } ;
51+ const cfg = { channels : { buzz } } as OpenClawConfig ;
52+ const input = { relayUrl : "wss://new.example.com" , useEnv : true } ;
53+ const requestedAccountId = "ada" ;
54+ const resolvedAccountId =
55+ buzzSetupContract . resolveAccountId ?.( { cfg, accountId : requestedAccountId , input } ) ??
56+ requestedAccountId ;
57+
58+ expect ( resolvedAccountId ) . toBe ( requestedAccountId ) ;
59+ expect ( buzzSetupContract . validateInput ?.( { cfg, accountId : resolvedAccountId , input } ) ) . toBe (
60+ "Buzz currently supports only the default account." ,
61+ ) ;
62+ expect ( cfg . channels ?. buzz ) . toEqual ( buzz ) ;
63+ expect ( process . env . BUZZ_PRIVATE_KEY ) . toBe ( existingPrivateKey ) ;
64+ } ) ;
65+
1066 it ( "validates and applies BUZZ_PRIVATE_KEY setup without storing the key" , ( ) => {
1167 expect ( buzzSetupContract . metadata . fields . find ( ( field ) => field . key === "useEnv" ) ) . toMatchObject (
1268 {
0 commit comments