(t *testing.T)
| 103 | } |
| 104 | |
| 105 | func 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 | |
| 140 | func TestSubsystem(t *testing.T) { |
| 141 | backend := &dummyBackend{} |
nothing calls this directly
no test coverage detected