From fd53144d64006a623e3b2faf30e1f765c2e5869d Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Tue, 26 Mar 2024 17:26:15 +0100 Subject: [PATCH] unit-tests: minor cleanups Signed-off-by: Francesco Giudici --- pkg/plainauth/plainauth.go | 2 +- pkg/server/api_registration_test.go | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/plainauth/plainauth.go b/pkg/plainauth/plainauth.go index 341245dbd..dfe95e3c7 100644 --- a/pkg/plainauth/plainauth.go +++ b/pkg/plainauth/plainauth.go @@ -55,7 +55,7 @@ func (a *AuthServer) Authenticate(_ *websocket.Conn, req *http.Request, regNames log.Info("Authentication: PLAIN") idToken := strings.TrimPrefix(header, "Bearer PLAIN") if idToken == "" { - return nil, false, fmt.Errorf("Cannot find token ID") + return nil, false, fmt.Errorf("cannot find token ID") } hashedToken := fmt.Sprintf("%x", sha256.Sum256([]byte(idToken))) diff --git a/pkg/server/api_registration_test.go b/pkg/server/api_registration_test.go index e114b5517..dbffeba8c 100644 --- a/pkg/server/api_registration_test.go +++ b/pkg/server/api_registration_test.go @@ -675,7 +675,7 @@ func TestRegistrationMsgUpdate(t *testing.T) { header := http.Header{} header.Add("Authorization", fmt.Sprintf("Bearer TPM%s", tc.machineName)) - ws, _, err := websocket.DefaultDialer.Dial(url, header) + ws, _, _ := websocket.DefaultDialer.Dial(url, header) defer ws.Close() // Read MsgReady @@ -815,8 +815,6 @@ type FakeAuthServer struct { // set to the machine-name from the URL. func (a *FakeAuthServer) Authenticate(conn *websocket.Conn, req *http.Request, registerNamespace string) (*elementalv1.MachineInventory, bool, error) { token := path.Base(req.URL.Path) - escapedToken := strings.Replace(token, "\n", "", -1) - escapedToken = strings.Replace(escapedToken, "\r", "", -1) // A zero CreationTimestamp implies the MachineInventory is new creationTimestamp := metav1.Time{}