forked from bmatcuk/go-vagrant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand_sshconfig_response_test.go
68 lines (62 loc) · 2.25 KB
/
command_sshconfig_response_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package vagrant
import (
"testing"
)
func TestSSHConfigResponse_handleOutput(t *testing.T) {
parser := MockOutputParser{}
data := newSSHConfigResponse()
parser.Run(successfulOutput["ssh-config"], &data)
if data.Error != nil {
t.Errorf("Successful vagrant ssh-config should not have set an error: %v", data.Error)
}
if len(data.Configs) != 1 {
t.Fatalf("Expecting 1 config; got %v", len(data.Configs))
}
config, ok := data.Configs["default"]
if !ok {
t.Fatalf("Expecting a config for 'default' but didn't get it")
}
if config.Host != "default" {
t.Errorf("Expecting Host to be 'default'; got %v", config.Host)
}
if config.HostName != "127.0.0.1" {
t.Errorf("Expecting HostName to be '127.0.0.1'; got %v", config.HostName)
}
if config.User != "core" {
t.Errorf("Expecting User to be 'core'; got %v", config.User)
}
if config.Port != 2222 {
t.Errorf("Expecting Port to be '2222'; got %v", config.Port)
}
if config.UserKnownHostsFile != "/dev/null" {
t.Errorf("Expecting UserKnownHostsFile to be '/dev/null'; got %v", config.UserKnownHostsFile)
}
if config.StrictHostKeyChecking != "no" {
t.Errorf("Expecting StrictHostKeyChecking to be 'no'; got %v", config.StrictHostKeyChecking)
}
if config.PasswordAuthentication != "no" {
t.Errorf("Expecting PasswordAuthentication to be 'no'; got %v", config.PasswordAuthentication)
}
if config.IdentityFile != "/Users/user/.vagrant.d/insecure_private_key" {
t.Errorf("Expecting IdentityFile to be '/Users/user/.vagrant.d/insecure_private_key'; got %v", config.IdentityFile)
}
if config.IdentitiesOnly != "yes" {
t.Errorf("Expecting IdentitiesOnly to be 'yes'; got %v", config.IdentitiesOnly)
}
if config.LogLevel != "FATAL" {
t.Errorf("Expecting LogLevel to be 'FATAL'; got %v", config.LogLevel)
}
if config.ForwardAgent != "yes" {
t.Errorf("Expecting ForwardAgent to be 'yes'; got %v", config.ForwardAgent)
}
if len(config.AdditionalFields) == 0 {
t.Errorf("Expecting len(AdditionalFields) to be >0; got %v", len(config.AdditionalFields))
} else {
field, ok := config.AdditionalFields["UnknownField"]
if !ok {
t.Errorf("Expecting AdditionalFields to have an 'UnknownField'")
} else if field != "no" {
t.Errorf("Expecting 'UnknownField' to have a value of 'no'; got %v", field)
}
}
}