9
9
const testEntryId string = "76a4fcf6-fec1-4297-bc1e-a327841055ad"
10
10
const testVaultId string = "e0f4f35d-8cb5-40d9-8b2b-35c96ea1c9b5"
11
11
12
- var testPassword string = "TestK8sPassword"
13
12
var testNewEntry DvlsEntry
14
13
var testEntry DvlsEntry = DvlsEntry {
15
14
ID : testEntryId ,
@@ -19,21 +18,18 @@ var testEntry DvlsEntry = DvlsEntry{
19
18
ConnectionType : ServerConnectionCredential ,
20
19
ConnectionSubType : ServerConnectionSubTypeDefault ,
21
20
Tags : []string {"Test tag 1" , "Test tag 2" , "testtag" },
22
- Credentials : DvlsEntryCredentials {
23
- Username : "TestK8s" ,
24
- Password : & testPassword ,
25
- },
21
+ Credentials : NewEntryCredentials ("TestK8s" , "TestK8sPassword" ),
26
22
}
27
23
28
24
var testClient Client
29
25
30
26
func Test_NewClient (t * testing.T ) {
31
- c , user , err := NewClient (os .Getenv ("TEST_USER" ), os .Getenv ("TEST_PASSWORD" ), os .Getenv ("TEST_INSTANCE" ))
27
+ c , err := NewClient (os .Getenv ("TEST_USER" ), os .Getenv ("TEST_PASSWORD" ), os .Getenv ("TEST_INSTANCE" ))
32
28
if err != nil {
33
29
t .Fatal (err )
34
30
}
35
- if user .UserType != UserAuthenticationApplication {
36
- t .Fatalf ("user credentials is not an Application. User type %s" , user .UserType )
31
+ if c . ClientUser .UserType != UserAuthenticationApplication {
32
+ t .Fatalf ("user credentials is not an Application. User type %s" , c . ClientUser .UserType )
37
33
}
38
34
39
35
testClient = c
@@ -42,15 +38,13 @@ func Test_NewClient(t *testing.T) {
42
38
t .Run ("GetEntryCredentialsPassword" , test_GetEntryCredentialsPassword )
43
39
t .Run ("GetEntry" , test_GetEntry )
44
40
t .Run ("NewEntry" , test_NewEntry )
41
+ t .Run ("UpdateEntry" , test_UpdateEntry )
45
42
t .Run ("DeleteEntry" , test_DeleteEntry )
46
43
t .Run ("GetServerInfo" , test_GetServerInfo )
47
44
}
48
45
49
46
func test_GetEntryCredentialsPassword (t * testing.T ) {
50
- testSecret := DvlsEntryCredentials {
51
- Username : "TestK8s" ,
52
- Password : & testPassword ,
53
- }
47
+ testSecret := testEntry .Credentials
54
48
secret , err := testClient .GetEntryCredentialsPassword (testEntry )
55
49
if err != nil {
56
50
t .Fatal (err )
@@ -96,6 +90,28 @@ func test_NewEntry(t *testing.T) {
96
90
if ! reflect .DeepEqual (entry , testNewEntry ) {
97
91
t .Fatalf ("fetched entry did not match test entry. Expected %#v, got %#v" , testNewEntry , entry )
98
92
}
93
+
94
+ testNewEntry = entry
95
+ }
96
+
97
+ func test_UpdateEntry (t * testing.T ) {
98
+ testUpdatedEntry := testNewEntry
99
+ testUpdatedEntry .EntryName = "TestK8sUpdatedEntry"
100
+ testUpdatedEntry .Credentials = NewEntryCredentials ("TestK8sUpdatedUser" , "TestK8sUpdatedPassword" )
101
+
102
+ entry , err := testClient .UpdateEntry (testUpdatedEntry )
103
+ if err != nil {
104
+ t .Fatal (err )
105
+ }
106
+
107
+ testUpdatedEntry .ModifiedDate = entry .ModifiedDate
108
+ testUpdatedEntry .Tags = entry .Tags
109
+
110
+ if ! reflect .DeepEqual (entry , testUpdatedEntry ) {
111
+ t .Fatalf ("fetched entry did not match test entry. Expected %#v, got %#v" , testUpdatedEntry , entry )
112
+ }
113
+
114
+ testNewEntry = entry
99
115
}
100
116
101
117
func test_DeleteEntry (t * testing.T ) {
0 commit comments