Skip to content

Commit

Permalink
test: improve code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gitahernandez committed Mar 8, 2024
1 parent 91a1d8d commit ee2d25b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion TestClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func main() {
//certificateKey = os.Getenv("CERTIFICATE_KEY")

// validate inputs
errorsInInputs := utils.ValidateInputs(clientId, clientSecret, apiUrl, clientTimeOutInSeconds, &separator, verifyCa, zapLogger, certificate, certificateKey, &retryMaxElapsedTimeMinutes, &maxFileSecretSizeBytes)
errorsInInputs := utils.ValidateInputs(clientId, clientSecret, &apiUrl, clientTimeOutInSeconds, &separator, verifyCa, zapLogger, certificate, certificateKey, &retryMaxElapsedTimeMinutes, &maxFileSecretSizeBytes)

if errorsInInputs != nil {
return
Expand Down
8 changes: 5 additions & 3 deletions api/utils/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type UserInputValidaton struct {
var validate *validator.Validate

// ValidateInputs is responsible for validating end-user inputs.
func ValidateInputs(clientId string, clientSecret string, apiUrl string, clientTimeOutinSeconds int, separator *string, verifyCa bool, logger logging.Logger, certificate string, certificate_key string, retryMaxElapsedTimeMinutes *int, maxFileSecretSizeBytes *int) error {
func ValidateInputs(clientId string, clientSecret string, apiUrl *string, clientTimeOutinSeconds int, separator *string, verifyCa bool, logger logging.Logger, certificate string, certificate_key string, retryMaxElapsedTimeMinutes *int, maxFileSecretSizeBytes *int) error {

if clientTimeOutinSeconds == 0 {
clientTimeOutinSeconds = 30
Expand All @@ -45,7 +45,9 @@ func ValidateInputs(clientId string, clientSecret string, apiUrl string, clientT
*separator = "/"
}

err := ValidateURL(apiUrl)
*apiUrl = strings.TrimSpace(*apiUrl)

err := ValidateURL(*apiUrl)
if err != nil {
logger.Error(err.Error())
return err
Expand All @@ -56,7 +58,7 @@ func ValidateInputs(clientId string, clientSecret string, apiUrl string, clientT
userInput := &UserInputValidaton{
ClientId: clientId,
ClientSecret: clientSecret,
ApiUrl: apiUrl,
ApiUrl: *apiUrl,
ClientTimeOutinSeconds: clientTimeOutinSeconds,
Separator: *separator,
VerifyCa: verifyCa,
Expand Down

0 comments on commit ee2d25b

Please sign in to comment.