Skip to content

Commit

Permalink
fix: solve minnor issues and linting issues (#30)
Browse files Browse the repository at this point in the history
Co-authored-by: EPAM\Felipe_Hernandez <[email protected]>
  • Loading branch information
btfhernandez and gitahernandez authored Feb 26, 2024
1 parent b8ab9e7 commit 788e2ab
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 13 deletions.
6 changes: 4 additions & 2 deletions api/managed_account/managed_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ func (managedAccounObj *ManagedAccountstObj) GetSecrets(secretPaths []string, se
}

// GetSecret returns secret value for a specific System Name and Account Name.
func (managedAccounObj *ManagedAccountstObj) GetSecret(secretPath string, separator string) (map[string]string, error) {
func (managedAccounObj *ManagedAccountstObj) GetSecret(secretPath string, separator string) (string, error) {
managedAccountList := []string{}
return managedAccounObj.ManageAccountFlow(append(managedAccountList, secretPath), separator, make(map[string]string))
secrets, _ := managedAccounObj.ManageAccountFlow(append(managedAccountList, secretPath), separator, make(map[string]string))
secretValue := secrets[secretPath]
return secretValue, nil
}

// ManageAccountFlow is responsible for creating a dictionary of managed account system/name and secret key-value pairs.
Expand Down
37 changes: 28 additions & 9 deletions api/managed_account/managed_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package managed_accounts

import (
"fmt"
"go-client-library-passwordsafe/api/authentication"
"go-client-library-passwordsafe/api/entities"
"go-client-library-passwordsafe/api/logging"
Expand Down Expand Up @@ -247,7 +246,6 @@ func TestManageAccountFlow(t *testing.T) {

func TestManageAccountFlowNotFound(t *testing.T) {
logger, _ := zap.NewDevelopment()
defer logger.Sync()

// create a zap logger wrapper
zapLogger := logging.NewZapLogger(logger)
Expand All @@ -262,23 +260,44 @@ func TestManageAccountFlowNotFound(t *testing.T) {
switch r.URL.Path {

case "/Auth/SignAppin":
w.Write([]byte(`{"UserId":1, "EmailAddress":"Felipe"}`))
_, err := w.Write([]byte(`{"UserId":1, "EmailAddress":"Felipe"}`))
if err != nil {
t.Error("Test case Failed")
}

case "/Auth/Signout":
w.Write([]byte(``))
_, err := w.Write([]byte(``))
if err != nil {
t.Error("Test case Failed")
}

case fmt.Sprintf("/ManagedAccounts"):
case "/ManagedAccounts":
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(`"Managed Account not found"`))
_, err := w.Write([]byte(`"Managed Account not found"`))
if err != nil {
t.Error("Test case Failed")
}

case "/Requests":
w.Write([]byte(`124`))
_, err := w.Write([]byte(`124`))

if err != nil {
t.Error("Test case Failed")
}

case "/Credentials/124":
w.Write([]byte(`"fake_credential"`))
_, err := w.Write([]byte(`"fake_credential"`))

if err != nil {
t.Error("Test case Failed")
}

case "/Requests/124/checkin":
w.Write([]byte(``))
_, err := w.Write([]byte(``))

if err != nil {
t.Error("Test case Failed")
}

default:
http.NotFound(w, r)
Expand Down
6 changes: 4 additions & 2 deletions api/secrets/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ func (secretObj *SecretObj) GetSecrets(secretsList []string, separator string) (
}

// GetSecret returns secret value for a specific path and title.
func (secretObj *SecretObj) GetSecret(secretPath string, separator string) (map[string]string, error) {
func (secretObj *SecretObj) GetSecret(secretPath string, separator string) (string, error) {
secretList := []string{}
return secretObj.GetSecretFlow(append(secretList, secretPath), separator)
secrets, _ := secretObj.GetSecretFlow(append(secretList, secretPath), separator)
secretValue := secrets[secretPath]
return secretValue, nil
}

// GetSecretFlow is responsible for creating a dictionary of secrets safe secret paths and secret key-value pairs.
Expand Down

0 comments on commit 788e2ab

Please sign in to comment.