MCPcopy Index your code
hub / github.com/ContainerSSH/ContainerSSH / TestShell

Function TestShell

internal/security/handler_session_test.go:105–138  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

103}
104
105func TestShell(t *testing.T) {
106 backend := &dummyBackend{}
107 session := &sessionHandler{
108 config: config.SecurityConfig{},
109 backend: backend,
110 sshConnection: &sshConnectionHandler{
111 lock: &sync.Mutex{},
112 },
113 logger: log.NewTestLogger(t),
114 }
115
116 session.config.Shell.Mode = config.ExecutionPolicyDisable
117 assert.Error(t, session.OnShell(1))
118
119 session.config.Shell.Mode = config.ExecutionPolicyFilter
120 assert.Error(t, session.OnShell(1))
121
122 session.config.Shell.Mode = config.ExecutionPolicyEnable
123 assert.NoError(t, session.OnShell(1))
124
125 session.config.Shell.Mode = config.ExecutionPolicyEnable
126 backend.commandsExecuted = []string{}
127 backend.env = map[string]string{}
128 assert.NoError(t, session.OnShell(1))
129 assert.Equal(t, []string{"shell"}, backend.commandsExecuted)
130 assert.Equal(t, map[string]string{}, backend.env)
131
132 session.config.Shell.Mode = config.ExecutionPolicyEnable
133 session.config.ForceCommand = "/bin/wrapper"
134 backend.commandsExecuted = []string{}
135 backend.env = map[string]string{}
136 assert.NoError(t, session.OnShell(1))
137 assert.Equal(t, []string{"/bin/wrapper"}, backend.commandsExecuted)
138}
139
140func TestSubsystem(t *testing.T) {
141 backend := &dummyBackend{}

Callers

nothing calls this directly

Calls 3

OnShellMethod · 0.95
NewTestLoggerFunction · 0.92
ErrorMethod · 0.65

Tested by

no test coverage detected