From 4feb0edb80709f0c1a7da477556c67e7f0f91a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Larivi=C3=A8re?= Date: Thu, 5 Jun 2025 11:05:08 -0400 Subject: [PATCH] chore: [auto] reorder credential fields to reflect ui presentation --- entries.go | 24 ++++++++++++------------ entry_credential.go | 8 ++++---- entry_credential_test.go | 30 ++++++++++++++++++------------ 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/entries.go b/entries.go index d897bd3..49b0e23 100644 --- a/entries.go +++ b/entries.go @@ -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 diff --git a/entry_credential.go b/entry_credential.go index 1a63ce5..5fd4eef 100644 --- a/entry_credential.go +++ b/entry_credential.go @@ -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) @@ -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) diff --git a/entry_credential_test.go b/entry_credential_test.go index bf84a79..7d1dbbd 100644 --- a/entry_credential_test.go +++ b/entry_credential_test.go @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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)