Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update client.go #260

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,9 @@ func (c *Client) Start() (addr net.Addr, err error) {
cmd := c.config.Cmd
cmd.Env = append(cmd.Env, os.Environ()...)
cmd.Env = append(cmd.Env, env...)
cmd.Stdin = os.Stdin
if cmd.Stdin == nil {
cmd.Stdin = os.Stdin
}

cmdStdout, err := cmd.StdoutPipe()
if err != nil {
Expand Down
27 changes: 27 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,34 @@ func TestClient_Stdin(t *testing.T) {
t.Fatal("process didn't exit cleanly")
}
}
func TestClient_StdinBuffer(t *testing.T) {
Comment on lines 821 to +822
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
func TestClient_StdinBuffer(t *testing.T) {
}
func TestClient_StdinBuffer(t *testing.T) {


process := helperProcess("stdin")
process.Stdin = bytes.NewBufferString("hello")
c := NewClient(&ClientConfig{
Cmd: process,
HandshakeConfig: testHandshake,
Plugins: testPluginMap,
})
defer c.Kill()

_, err := c.Start()
if err != nil {
t.Fatalf("error: %s", err)
}

for {
if c.Exited() {
break
}

time.Sleep(50 * time.Millisecond)
}

if !process.ProcessState.Success() {
t.Fatal("process didn't exit cleanly")
}
}
func TestClient_SecureConfig(t *testing.T) {
Comment on lines +849 to 850
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
func TestClient_SecureConfig(t *testing.T) {
}
func TestClient_SecureConfig(t *testing.T) {

// Test failure case
secureConfig := &SecureConfig{
Expand Down