-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry_website_test.go
75 lines (61 loc) · 2.06 KB
/
entry_website_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
69
70
71
72
73
74
75
package dvls
import (
"os"
"reflect"
"testing"
)
var (
testWebsiteEntryId string
testWebsiteEntry EntryWebsite = EntryWebsite{
Description: "Test website description",
EntryName: "TestWebsite",
ConnectionType: ServerConnectionWebBrowser,
ConnectionSubType: ServerConnectionSubTypeGoogleChrome,
Tags: []string{"Test tag 1", "Test tag 2", "web"},
}
)
const (
testWebsiteUsername string = "testuser"
testWebsiteURL string = "https://test.example.com"
testWebsiteBrowser string = "GoogleChrome"
)
var testWebsitePassword = "testpass123"
func Test_EntryWebsite(t *testing.T) {
testWebsiteEntryId = os.Getenv("TEST_WEBSITE_ENTRY_ID")
testWebsiteEntry.ID = testWebsiteEntryId
testWebsiteEntry.VaultId = testVaultId
testWebsiteEntry.WebsiteDetails = EntryWebsiteAuthDetails{
Username: testWebsiteUsername,
URL: testWebsiteURL,
WebBrowserApplication: 3,
}
testWebsiteEntry.ConnectionSubType = ServerConnectionSubTypeGoogleChrome
t.Run("GetEntry", test_GetWebsiteEntry)
t.Run("GetEntryWebsite", test_GetWebsiteDetails)
}
func test_GetWebsiteEntry(t *testing.T) {
entry, err := testClient.Entries.Website.Get(testWebsiteEntry.ID)
if err != nil {
t.Fatal(err)
}
testWebsiteEntry.ModifiedDate = entry.ModifiedDate
if !reflect.DeepEqual(entry, testWebsiteEntry) {
t.Fatalf("fetched entry did not match test entry. Expected %#v, got %#v", testWebsiteEntry, entry)
}
}
func test_GetWebsiteDetails(t *testing.T) {
entry, err := testClient.Entries.Website.Get(testWebsiteEntry.ID)
if err != nil {
t.Fatal(err)
}
entryWithSensitiveData, err := testClient.Entries.Website.GetWebsiteDetails(entry)
if err != nil {
t.Fatal(err)
}
entry.WebsiteDetails.Password = entryWithSensitiveData.WebsiteDetails.Password
expectedDetails := testWebsiteEntry.WebsiteDetails
expectedDetails.Password = &testWebsitePassword
if !reflect.DeepEqual(expectedDetails, entry.WebsiteDetails) {
t.Fatalf("fetched secret did not match test secret. Expected %#v, got %#v", expectedDetails, entry.WebsiteDetails)
}
}