-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathentry_host_test.go
More file actions
76 lines (61 loc) · 1.8 KB
/
entry_host_test.go
File metadata and controls
76 lines (61 loc) · 1.8 KB
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
69
70
71
72
73
74
75
76
//go:build integration
package dvls
import (
"os"
"reflect"
"testing"
)
var (
testHostEntryId string
testHostPassword = "testpass123"
testHostEntry EntryHost = EntryHost{
Description: "Test host description",
EntryName: "TestHost",
ConnectionType: ServerConnectionHost,
Tags: []string{"Test tag 1", "Test tag 2", "host"},
}
)
const (
testHostUsername string = "testuser"
testHost string = "host1234"
)
func Test_EntryHost(t *testing.T) {
if testVaultId == "" {
t.Skip("Skipping legacy API test: TEST_VAULT_ID not set")
}
testHostEntryId = os.Getenv("TEST_HOST_ENTRY_ID")
testHostEntry.Id = testHostEntryId
testHostEntry.VaultId = testVaultId
testHostEntry.HostDetails = EntryHostAuthDetails{
Username: testHostUsername,
Host: testHost,
}
t.Run("GetEntry", test_GetHostEntry)
t.Run("GetEntryHost", test_GetHostDetails)
}
func test_GetHostEntry(t *testing.T) {
entry, err := testClient.Entries.Host.Get(testHostEntry.Id)
if err != nil {
t.Fatal(err)
}
testHostEntry.ModifiedDate = entry.ModifiedDate
if !reflect.DeepEqual(entry, testHostEntry) {
t.Fatalf("fetched entry did not match test entry. Expected %#v, got %#v", testHostEntry, entry)
}
}
func test_GetHostDetails(t *testing.T) {
entry, err := testClient.Entries.Host.Get(testHostEntry.Id)
if err != nil {
t.Fatal(err)
}
entryWithSensitiveData, err := testClient.Entries.Host.GetHostDetails(entry)
if err != nil {
t.Fatal(err)
}
entry.HostDetails.Password = entryWithSensitiveData.HostDetails.Password
expectedDetails := testHostEntry.HostDetails
expectedDetails.Password = &testHostPassword
if !reflect.DeepEqual(expectedDetails, entry.HostDetails) {
t.Fatalf("fetched secret did not match test secret. Expected %#v, got %#v", expectedDetails, entry.HostDetails)
}
}