Fix winrm default ssl port (#19540)
* Update provisioner.go Changed the default port used for winrm when https is specified
This commit is contained in:
parent
541143ddce
commit
d1c301bc2d
|
@ -19,6 +19,9 @@ const (
|
||||||
// DefaultPort is used if there is no port given
|
// DefaultPort is used if there is no port given
|
||||||
DefaultPort = 5985
|
DefaultPort = 5985
|
||||||
|
|
||||||
|
// DefaultHTTPSPort is used if there is no port given and HTTPS is true
|
||||||
|
DefaultHTTPSPort = 5986
|
||||||
|
|
||||||
// DefaultScriptPath is used as the path to copy the file to
|
// DefaultScriptPath is used as the path to copy the file to
|
||||||
// for remote execution if not provided otherwise.
|
// for remote execution if not provided otherwise.
|
||||||
DefaultScriptPath = "C:/Temp/terraform_%RAND%.cmd"
|
DefaultScriptPath = "C:/Temp/terraform_%RAND%.cmd"
|
||||||
|
@ -80,8 +83,12 @@ func parseConnectionInfo(s *terraform.InstanceState) (*connectionInfo, error) {
|
||||||
connInfo.Host = shared.IpFormat(connInfo.Host)
|
connInfo.Host = shared.IpFormat(connInfo.Host)
|
||||||
|
|
||||||
if connInfo.Port == 0 {
|
if connInfo.Port == 0 {
|
||||||
|
if connInfo.HTTPS {
|
||||||
|
connInfo.Port = DefaultHTTPSPort
|
||||||
|
} else {
|
||||||
connInfo.Port = DefaultPort
|
connInfo.Port = DefaultPort
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if connInfo.ScriptPath == "" {
|
if connInfo.ScriptPath == "" {
|
||||||
connInfo.ScriptPath = DefaultScriptPath
|
connInfo.ScriptPath = DefaultScriptPath
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,31 @@ import (
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestProvisioner_defaultHTTPSPort(t *testing.T) {
|
||||||
|
r := &terraform.InstanceState{
|
||||||
|
Ephemeral: terraform.EphemeralState{
|
||||||
|
ConnInfo: map[string]string{
|
||||||
|
"type": "winrm",
|
||||||
|
"user": "Administrator",
|
||||||
|
"password": "supersecret",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"https": "true",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
conf, err := parseConnectionInfo(r)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %v", err)
|
||||||
|
}
|
||||||
|
if conf.Port != 5986 {
|
||||||
|
t.Fatalf("expected: %v: got: %v", 5986, conf)
|
||||||
|
}
|
||||||
|
if conf.HTTPS != true {
|
||||||
|
t.Fatalf("expected: %v: got: %v", true, conf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestProvisioner_connInfo(t *testing.T) {
|
func TestProvisioner_connInfo(t *testing.T) {
|
||||||
r := &terraform.InstanceState{
|
r := &terraform.InstanceState{
|
||||||
Ephemeral: terraform.EphemeralState{
|
Ephemeral: terraform.EphemeralState{
|
||||||
|
|
Loading…
Reference in New Issue