From b6e9b414f6acdc3e2f30e3be7a1e0433d15269b8 Mon Sep 17 00:00:00 2001 From: Aviel Segev Date: Tue, 14 Jan 2025 12:51:50 +0200 Subject: [PATCH] update the testVmwareConnection func to return unauthorized both for the test and production environments Signed-off-by: Aviel Segev --- internal/agent/rest.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/agent/rest.go b/internal/agent/rest.go index e7393a0..bb8ff77 100644 --- a/internal/agent/rest.go +++ b/internal/agent/rest.go @@ -171,7 +171,9 @@ func testVmwareConnection(requestCtx context.Context, credentials *config.Creden err = client.Login(ctx, u.User) if err != nil { err = liberr.Wrap(err) - if strings.Contains(err.Error(), "Login failure") { + // Cover both the different error messages returns from the production and test environments in case of incorrect credentials + if strings.Contains(err.Error(), "Login failure") || + strings.Contains(err.Error(), "incorrect") && strings.Contains(err.Error(), "password") { return http.StatusUnauthorized, err } return http.StatusBadRequest, err