style: format code for consistency and readability
This commit is contained in:
parent
85d3a237eb
commit
0ca908f434
5 changed files with 12 additions and 13 deletions
|
|
@ -160,4 +160,4 @@ func (s *Service) EncryptRSA(publicKey, data, label []byte) ([]byte, error) {
|
|||
func (s *Service) DecryptRSA(privateKey, ciphertext, label []byte) ([]byte, error) {
|
||||
s.ensureRSA()
|
||||
return s.rsa.Decrypt(privateKey, ciphertext, label)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ func TestHash_Bad(t *testing.T) {
|
|||
func TestHash_Ugly(t *testing.T) {
|
||||
// Test with potentially problematic inputs
|
||||
testCases := []string{
|
||||
"", // Empty string
|
||||
" ", // Whitespace
|
||||
"\x00\x01\x02\x03\x04", // Null bytes
|
||||
"", // Empty string
|
||||
" ", // Whitespace
|
||||
"\x00\x01\x02\x03\x04", // Null bytes
|
||||
strings.Repeat("a", 1024*1024), // Large payload (1MB)
|
||||
"こんにちは", // Unicode characters
|
||||
"こんにちは", // Unicode characters
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
|
@ -105,7 +105,6 @@ func TestFletcher64_Ugly(t *testing.T) {
|
|||
assert.NotEqual(t, uint64(0), service.Fletcher64("abc"), "Checksum of length 3 string")
|
||||
}
|
||||
|
||||
|
||||
// --- RSA Tests ---
|
||||
|
||||
func TestRSA_Good(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -88,4 +88,4 @@ func (s *Service) Decrypt(privateKey, ciphertext, label []byte) ([]byte, error)
|
|||
}
|
||||
|
||||
return plaintext, nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ var (
|
|||
type Trix struct {
|
||||
Header map[string]interface{}
|
||||
Payload []byte
|
||||
InSigils []string `json:"-"` // Ignore Sigils during JSON marshaling
|
||||
OutSigils []string `json:"-"` // Ignore Sigils during JSON marshaling
|
||||
InSigils []string `json:"-"` // Ignore Sigils during JSON marshaling
|
||||
OutSigils []string `json:"-"` // Ignore Sigils during JSON marshaling
|
||||
ChecksumAlgo crypt.HashType `json:"-"`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,10 +85,10 @@ func TestTrixEncodeDecode_Ugly(t *testing.T) {
|
|||
t.Run("CorruptedHeaderLength", func(t *testing.T) {
|
||||
// Manually construct a byte slice where the header length is larger than the actual data.
|
||||
var buf []byte
|
||||
buf = append(buf, []byte(magicNumber)...) // Magic Number
|
||||
buf = append(buf, byte(trix.Version)) // Version
|
||||
buf = append(buf, []byte{0, 0, 3, 232}...) // BigEndian representation of 1000
|
||||
buf = append(buf, []byte("{}")...) // A minimal valid JSON header
|
||||
buf = append(buf, []byte(magicNumber)...) // Magic Number
|
||||
buf = append(buf, byte(trix.Version)) // Version
|
||||
buf = append(buf, []byte{0, 0, 3, 232}...) // BigEndian representation of 1000
|
||||
buf = append(buf, []byte("{}")...) // A minimal valid JSON header
|
||||
buf = append(buf, []byte("payload")...)
|
||||
|
||||
_, err := trix.Decode(buf, magicNumber)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue