| 12345678910111213141516171819202122232425262728 |
- package config
- import (
- "crypto/md5"
- "encoding/hex"
- "os"
- "path/filepath"
- "testing"
- )
- func TestFWHPasswordsAreMD5Encoded(t *testing.T) {
- path := filepath.Join(t.TempDir(), "config.env")
- if err := os.WriteFile(path, []byte("FWH_PASSWORD=plain-password\nFWH_TEST_PASSWORD=test-password\n"), 0600); err != nil {
- t.Fatal(err)
- }
- cfg, err := LoadConfig(path)
- if err != nil {
- t.Fatal(err)
- }
- productionHash := md5.Sum([]byte("plain-password"))
- if cfg.FwhApi.FwhPassword != hex.EncodeToString(productionHash[:]) {
- t.Fatalf("production password was not MD5 encoded")
- }
- testHash := md5.Sum([]byte("test-password"))
- if cfg.FwhTestApi.FwhPassword != hex.EncodeToString(testHash[:]) {
- t.Fatalf("test environment password hashing changed")
- }
- }
|