Skip to content

Commit

Permalink
unit-tests: minor cleanups
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Giudici <[email protected]>
  • Loading branch information
fgiudici committed Mar 27, 2024
1 parent c6aac92 commit fd53144
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/plainauth/plainauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down
4 changes: 1 addition & 3 deletions pkg/server/api_registration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{}
Expand Down

0 comments on commit fd53144

Please sign in to comment.