Some checks are pending
Build / build_app (push) Waiting to run
Build / build (386, linux) (push) Blocked by required conditions
Build / build (amd64, darwin) (push) Blocked by required conditions
Build / build (amd64, linux) (push) Blocked by required conditions
Build / build (arm, 5, linux) (push) Blocked by required conditions
Build / build (arm, 6, linux) (push) Blocked by required conditions
Build / build (arm, 7, linux) (push) Blocked by required conditions
Build / build (arm64, darwin) (push) Blocked by required conditions
Build / build (arm64, linux) (push) Blocked by required conditions
Build / build (loong64, linux) (push) Blocked by required conditions
Build / build (mips, linux) (push) Blocked by required conditions
Build / build (mips64, linux) (push) Blocked by required conditions
Build / build (mips64le, linux) (push) Blocked by required conditions
Build / build (mipsle, linux) (push) Blocked by required conditions
Build / build (riscv64, linux) (push) Blocked by required conditions
Build / docker-build (push) Blocked by required conditions
Build Documents / build (push) Waiting to run
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package settings
|
|
|
|
import (
|
|
"crypto/md5"
|
|
"encoding/hex"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetSecretMd5_WithNonEmptySecret_ReturnsExpectedMd5Hash(t *testing.T) {
|
|
// Init
|
|
CryptoSettings.Secret = "testSecret"
|
|
expectedMd5 := md5.Sum([]byte("testSecret"))
|
|
expectedMd5String := hex.EncodeToString(expectedMd5[:])
|
|
|
|
// Execute
|
|
resultMd5 := CryptoSettings.GetSecretMd5()
|
|
resultMd5String := hex.EncodeToString(resultMd5[:])
|
|
|
|
// Verify
|
|
assert.Equal(t, expectedMd5String, resultMd5String, "MD5 hash should match for non-empty secret")
|
|
}
|
|
|
|
func TestGetSecretMd5_WithEmptySecret_ReturnsMd5OfEmptyString(t *testing.T) {
|
|
// Init
|
|
CryptoSettings.Secret = ""
|
|
expectedMd5 := md5.Sum([]byte(""))
|
|
expectedMd5String := hex.EncodeToString(expectedMd5[:])
|
|
|
|
// Execute
|
|
resultMd5 := CryptoSettings.GetSecretMd5()
|
|
resultMd5String := hex.EncodeToString(resultMd5[:])
|
|
|
|
// Verify
|
|
assert.Equal(t, expectedMd5String, resultMd5String, "MD5 hash of an empty string should be returned for empty secret")
|
|
}
|
|
|
|
func TestGetSecretMd5_WithDifferentSecrets_ReturnsDifferentMd5Hashes(t *testing.T) {
|
|
// Init
|
|
CryptoSettings.Secret = "secret1"
|
|
firstMd5 := CryptoSettings.GetSecretMd5()
|
|
CryptoSettings.Secret = "secret2"
|
|
secondMd5 := CryptoSettings.GetSecretMd5()
|
|
|
|
// Verify
|
|
assert.NotEqual(t, firstMd5, secondMd5, "Different secrets should produce different MD5 hashes")
|
|
}
|