MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / TestE2E_ShellModule_Env

Function TestE2E_ShellModule_Env

internal/bridge/modules_test.go:713–745  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

711}
712
713func TestE2E_ShellModule_Env(t *testing.T) {
714 mgr := sessions.NewManager(10 * time.Minute)
715 origGlobal := swapGlobalManager(mgr)
716 defer swapGlobalManager(origGlobal)
717
718 b, stream, sess := setupTestBridge(t, mgr, "codex_cli_rs/0.112.0 (Windows 10.0.26200; x86_64)", testClaudeTools)
719
720 spite := &implantpb.Spite{
721 Name: consts.ModuleEnv,
722 Body: &implantpb.Spite_Request{Request: &implantpb.Request{}},
723 }
724
725 b.taskManager.StartSessionListener(sess.ID)
726 simulateToolResult(mgr, sess.ID, 50, wrapToolOutput(windowsEnvOutput), 50*time.Millisecond)
727 dispatchWithTimeout(t, b, sess.ID, 50, spite, 3*time.Second)
728
729 sent := stream.getSent()
730 if len(sent) == 0 {
731 t.Fatal("expected SpiteResponse")
732 }
733
734 last := sent[len(sent)-1]
735 r := last.Spite.GetResponse()
736 if r == nil {
737 t.Fatal("expected Response body")
738 }
739 if len(r.Kv) == 0 {
740 t.Error("expected non-empty KV map")
741 }
742 if v := r.Kv["USERNAME"]; v != "John" {
743 t.Errorf("expected USERNAME=John, got %q", v)
744 }
745}
746
747// Test that modules with nil buildResponse fall back to ExecResponse in E2E.
748func TestE2E_ShellModule_Kill_FallbackExecResponse(t *testing.T) {

Callers

nothing calls this directly

Calls 9

NewManagerFunction · 0.92
swapGlobalManagerFunction · 0.85
setupTestBridgeFunction · 0.85
simulateToolResultFunction · 0.85
wrapToolOutputFunction · 0.85
dispatchWithTimeoutFunction · 0.85
StartSessionListenerMethod · 0.80
getSentMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected