Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ type Entries struct {
}

type Entry struct {
Id string `json:"id,omitempty"`
VaultId string `json:"vaultId,omitempty"`
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"`
SubType string `json:"subType"`
Id string `json:"id,omitempty"`
VaultId string `json:"vaultId,omitempty"`
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"`
SubType string `json:"subType"`
Description string `json:"description"`
Tags []string `json:"tags,omitempty"`

Data EntryData `json:"data,omitempty"`

Description string `json:"description"`
ModifiedBy string `json:"modifiedBy,omitempty"`
ModifiedOn *ServerTime `json:"modifiedOn,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
CreatedOn *ServerTime `json:"createdOn,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
CreatedOn *ServerTime `json:"createdOn,omitempty"`
ModifiedBy string `json:"modifiedBy,omitempty"`
ModifiedOn *ServerTime `json:"modifiedOn,omitempty"`
}

type EntryData any
Expand Down
8 changes: 4 additions & 4 deletions entry_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,16 @@ func (c *EntryCredentialService) New(entry Entry) (string, error) {
Path string `json:"path,omitempty"`
Type string `json:"type"`
SubType string `json:"subType"`
Data EntryData `json:"data"`
Tags []string `json:"tags,omitempty"`
Data EntryData `json:"data"`
}{
Name: entry.Name,
Description: entry.Description,
Path: entry.Path,
Type: entry.GetType(),
SubType: entry.GetSubType(),
Data: entry.Data,
Tags: entry.Tags,
Data: entry.Data,
}

baseEntryEndpoint := entryPublicBaseEndpointReplacer(entry.VaultId)
Expand Down Expand Up @@ -242,14 +242,14 @@ func (c *EntryCredentialService) Update(entry Entry) (Entry, error) {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Path string `json:"path,omitempty"`
Data EntryData `json:"data"`
Tags []string `json:"tags,omitempty"`
Data EntryData `json:"data"`
}{
Name: entry.Name,
Description: entry.Description,
Path: entry.Path,
Data: entry.Data,
Tags: entry.Tags,
Data: entry.Data,
}

entryUri := entryPublicEndpointReplacer(entry.VaultId, entry.Id)
Expand Down
30 changes: 18 additions & 12 deletions entry_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ func test_NewUserEntry(t *testing.T) {
VaultId: testVaultId,
Name: "TestGoDvlsAccessCode",
Path: "go-dvls\\accesscode",
Description: "Test AccessCode entry",
Type: EntryCredentialType,
SubType: EntryCredentialSubTypeAccessCode,
Description: "Test AccessCode entry",
Tags: []string{"accesscode"},

Data: EntryCredentialAccessCodeData{
Password: "abc-123",
},
Tags: []string{"accesscode"},
}

newCredentialAccessCodeEntryId, err := testClient.Entries.Credential.New(testCredentialAccessCodeEntry)
Expand All @@ -81,15 +82,16 @@ func test_NewUserEntry(t *testing.T) {
VaultId: testVaultId,
Name: "TestGoDvlsApiKey",
Path: "go-dvls\\apikey",
Description: "Test ApiKey entry",
Type: EntryCredentialType,
SubType: EntryCredentialSubTypeApiKey,
Description: "Test ApiKey entry",
Tags: []string{"apikey"},

Data: EntryCredentialApiKeyData{
ApiId: "abcd1234-abcd-1234-abcd-1234abcd1234",
ApiKey: "123-abc",
TenantId: "00000000-aaaa-bbbb-cccc-000000000000",
},
Tags: []string{"apikey"},
}

newCredentialApiKeyEntryId, err := testClient.Entries.Credential.New(testCredentialApiKeyEntry)
Expand All @@ -109,15 +111,16 @@ func test_NewUserEntry(t *testing.T) {
VaultId: testVaultId,
Name: "TestGoDvlsAzureServicePrincipal",
Path: "go-dvls\\azureserviceprincipal",
Description: "Test AzureServicePrincipal entry",
Type: EntryCredentialType,
SubType: EntryCredentialSubTypeAzureServicePrincipal,
Description: "Test AzureServicePrincipal entry",
Tags: []string{"azureserviceprincipal"},

Data: EntryCredentialAzureServicePrincipalData{
ClientId: "abcd1234-abcd-1234-abcd-1234abcd1234",
ClientSecret: "123-abc",
TenantId: "00000000-aaaa-bbbb-cccc-000000000000",
},
Tags: []string{"azureserviceprincipal"},
}

newCredentialAzureServicePrincipalEntryId, err := testClient.Entries.Credential.New(testCredentialAzureServicePrincipalEntry)
Expand All @@ -137,13 +140,14 @@ func test_NewUserEntry(t *testing.T) {
VaultId: testVaultId,
Name: "TestGoDvlsConnectionString",
Path: "go-dvls\\connectionstring",
Description: "Test ConnectionString entry",
Type: EntryCredentialType,
SubType: EntryCredentialSubTypeConnectionString,
Description: "Test ConnectionString entry",
Tags: []string{"connectionstring"},

Data: EntryCredentialConnectionStringData{
ConnectionString: "Server=tcp:example.database.windows.net,1433;Initial Catalog=exampledb;Persist Security Info=False;User ID=exampleuser;Password=examplepassword;",
},
Tags: []string{"connectionstring"},
}

newCredentialConnectionStringEntryId, err := testClient.Entries.Credential.New(testCredentialConnectionStringEntry)
Expand All @@ -162,15 +166,16 @@ func test_NewUserEntry(t *testing.T) {
VaultId: testVaultId,
Name: "TestGoDvlsUsernamePassword",
Path: "go-dvls\\usernamepassword",
Description: "Test Username/Password entry",
Type: EntryCredentialType,
SubType: EntryCredentialSubTypeDefault,
Description: "Test Username/Password entry",
Tags: []string{"usernamepassword"},

Data: EntryCredentialDefaultData{
Domain: "www.example.com",
Password: "abc-123",
Username: "john.doe",
},
Tags: []string{"usernamepassword"},
}

newCredentialDefaultEntryId, err := testClient.Entries.Credential.New(testCredentialDefaultEntry)
Expand All @@ -190,16 +195,17 @@ func test_NewUserEntry(t *testing.T) {
VaultId: testVaultId,
Name: "TestGoDvlsPrivateKey",
Path: "go-dvls\\privatekey",
Description: "Test Secret entry",
Type: EntryCredentialType,
SubType: EntryCredentialSubTypePrivateKey,
Description: "Test Secret entry",
Tags: []string{"testtag"},

Data: EntryCredentialPrivateKeyData{
PrivateKey: "-----BEGIN PRIVATE KEY-----\abcdefghijklmnopqrstuvwxyz1234567890...\n-----END PRIVATE",
PublicKey: "-----BEGIN PUBLIC KEY-----\abcdefghijklmnopqrstuvwxyz...\n-----END PUBLIC KEY-----",
OverridePassword: "override-password",
Passphrase: "passphrase",
},
Tags: []string{"testtag"},
}

newCredentialPrivateKeyEntryId, err := testClient.Entries.Credential.New(testCredentialPrivateKeyEntry)
Expand Down
Loading