|
|
|
|
@ -3,12 +3,10 @@ package communicator
|
|
|
|
|
import (
|
|
|
|
|
"bytes"
|
|
|
|
|
"context"
|
|
|
|
|
"os"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
|
|
|
|
"github.com/hashicorp/packer/packer"
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestStepConnect_impl(t *testing.T) {
|
|
|
|
|
@ -31,28 +29,6 @@ func TestStepConnect_none(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var noProxyTests = []struct {
|
|
|
|
|
current string
|
|
|
|
|
expected string
|
|
|
|
|
}{
|
|
|
|
|
{"", "foo:1"},
|
|
|
|
|
{"foo:1", "foo:1"},
|
|
|
|
|
{"foo:1,bar:2", "foo:1,bar:2"},
|
|
|
|
|
{"bar:2", "bar:2,foo:1"},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestStepConnect_setNoProxy(t *testing.T) {
|
|
|
|
|
key := "NO_PROXY"
|
|
|
|
|
for _, tt := range noProxyTests {
|
|
|
|
|
if value := os.Getenv(key); value != "" {
|
|
|
|
|
os.Unsetenv(key)
|
|
|
|
|
defer func() { os.Setenv(key, value) }()
|
|
|
|
|
os.Setenv(key, tt.current)
|
|
|
|
|
assert.Equal(t, tt.expected, os.Getenv(key), "env not set correctly.")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testState(t *testing.T) multistep.StateBag {
|
|
|
|
|
state := new(multistep.BasicStateBag)
|
|
|
|
|
state.Put("hook", &packer.MockHook{})
|
|
|
|
|
|