Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: solve minnor issues and linting issues #30

Merged
merged 1 commit into from
Feb 26, 2024
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
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,9 +246,8 @@

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

// create a zap logger wrapper

Check failure on line 250 in api/managed_account/managed_account_test.go

View workflow job for this annotation

GitHub Actions / golint

Error return value of `logger.Sync` is not checked (errcheck)
zapLogger := logging.NewZapLogger(logger)

httpClientObj, _ := utils.GetHttpClient(5, false, "", "", zapLogger)
Expand All @@ -262,23 +260,44 @@
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")

Check failure on line 265 in api/managed_account/managed_account_test.go

View workflow job for this annotation

GitHub Actions / golint

Error return value of `w.Write` is not checked (errcheck)
}

case "/Auth/Signout":

Check failure on line 268 in api/managed_account/managed_account_test.go

View workflow job for this annotation

GitHub Actions / golint

Error return value of `w.Write` is not checked (errcheck)
w.Write([]byte(``))
_, err := w.Write([]byte(``))
if err != nil {

Check failure on line 270 in api/managed_account/managed_account_test.go

View workflow job for this annotation

GitHub Actions / golint

S1039: unnecessary use of fmt.Sprintf (gosimple)
t.Error("Test case Failed")
}

Check failure on line 272 in api/managed_account/managed_account_test.go

View workflow job for this annotation

GitHub Actions / golint

Error return value of `w.Write` is not checked (errcheck)

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
Loading