Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Tests finished
Browse files Browse the repository at this point in the history
Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br>
  • Loading branch information
henriquemoraeszup committed Jan 7, 2021
1 parent 3415622 commit 079e381
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 257 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/delete_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func TestDeleteCredentialFormula(t *testing.T) {
dirManager := stream.NewDirManager(fileManager)

ctxFinder := env.NewFinder(ritHomeDir, fileManager)
credDeleter := credential.NewCredDelete(ritHomeDir, ctxFinder, fileManager)
credDeleter := credential.NewCredDelete(ritHomeDir, ctxFinder)
credSettings := credential.NewSettings(fileManager, dirManager, homeDir)

tests := []struct {
Expand Down
34 changes: 7 additions & 27 deletions pkg/cmd/set_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package cmd
import (
"errors"
"fmt"
"io/ioutil"
"os"
"reflect"
"strings"
Expand Down Expand Up @@ -181,39 +180,20 @@ func (s *setCredentialCmd) resolvePrompt() (credential.Detail, error) {

inputs := credentials[providerChoose]

inputWayChoose, _ := s.List("Want to enter your credential typing or through a file?", inputWay)
for _, i := range inputs {
var value string
if inputWayChoose == inputWay[1] {
path, err := s.Text("Enter the credential file path for "+prompt.Cyan(i.Name)+":", true)
if i.Type == inputTypes[1] {
value, err = s.Password(i.Name + ":")
if err != nil {
return credential.Detail{}, err
}

byteValue, err := ioutil.ReadFile(path)
if err != nil {
return credential.Detail{}, err
}
if len(byteValue) == 0 {
return credential.Detail{}, prompt.NewError("Empty credential file!")
return credDetail, err
}

cred[i.Name] = string(byteValue)

} else {
if i.Type == inputTypes[1] {
value, err = s.Password(i.Name + ":")
if err != nil {
return credDetail, err
}
} else {
value, err = s.Text(i.Name+":", true)
if err != nil {
return credDetail, err
}
value, err = s.Text(i.Name+":", true)
if err != nil {
return credDetail, err
}
cred[i.Name] = value
}
cred[i.Name] = value
}
credDetail.Service = providerChoose
credDetail.Credential = cred
Expand Down
Loading

0 comments on commit 079e381

Please sign in to comment.