omni/internal/pkg/auth/handler/mock_test.go
Edward Sammut Alessi d3ae77c0cc
chore: bump copyright to 2026
Bump copyright for conformance to 2026

Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
2026-01-21 15:30:49 +01:00

38 lines
776 B
Go

// Copyright (c) 2026 Sidero Labs, Inc.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
package handler_test
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"errors"
)
type mockSignerVerifier struct {
appendSignature []byte
}
func (mock mockSignerVerifier) Fingerprint() string {
return "mock-fingerprint"
}
func (mock mockSignerVerifier) Sign(data []byte) ([]byte, error) {
hash := sha256.Sum256(data)
return []byte(hex.EncodeToString(append(hash[:], mock.appendSignature...))), nil
}
func (mock mockSignerVerifier) Verify(data, signature []byte) error {
expected, _ := mock.Sign(data) //nolint:errcheck
if !bytes.Equal(signature, expected) {
return errors.New("invalid signature")
}
return nil
}