github.com/letsencrypt/boulder@v0.20251208.0/cmd/boulder/main_test.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os" 6 "testing" 7 8 "github.com/letsencrypt/boulder/cmd" 9 "github.com/letsencrypt/boulder/test" 10 ) 11 12 // TestConfigValidation checks that each of the components which register a 13 // validation tagged Config struct at init time can be used to successfully 14 // validate their corresponding test configuration files. 15 func TestConfigValidation(t *testing.T) { 16 configPath := "../../test/config" 17 if os.Getenv("BOULDER_CONFIG_DIR") == "test/config-next" { 18 configPath = "../../test/config-next" 19 } 20 21 // Each component is a set of `cmd` package name and a list of paths to 22 // configuration files to validate. 23 components := make(map[string][]string) 24 25 // For each component, add the paths to the configuration files to validate. 26 // By default we assume that the configuration file is named after the 27 // component. However, there are some exceptions to this rule. We've added 28 // special cases for these components. 29 for _, cmdName := range cmd.AvailableConfigValidators() { 30 var fileNames []string 31 switch cmdName { 32 case "boulder-ca": 33 fileNames = []string{"ca.json"} 34 case "boulder-observer": 35 fileNames = []string{"observer.yml"} 36 case "boulder-publisher": 37 fileNames = []string{"publisher.json"} 38 case "boulder-ra": 39 fileNames = []string{"ra.json"} 40 case "boulder-sa": 41 fileNames = []string{"sa.json"} 42 case "boulder-va": 43 fileNames = []string{"va.json"} 44 case "remoteva": 45 fileNames = []string{ 46 "remoteva-a.json", 47 "remoteva-b.json", 48 } 49 case "boulder-wfe2": 50 fileNames = []string{"wfe2.json"} 51 case "sfe": 52 fileNames = []string{"sfe.json"} 53 case "nonce-service": 54 fileNames = []string{ 55 "nonce-a.json", 56 "nonce-b.json", 57 } 58 default: 59 fileNames = []string{cmdName + ".json"} 60 } 61 components[cmdName] = append(components[cmdName], fileNames...) 62 } 63 t.Parallel() 64 for cmdName, paths := range components { 65 for _, path := range paths { 66 t.Run(path, func(t *testing.T) { 67 err := readAndValidateConfigFile(cmdName, fmt.Sprintf("%s/%s", configPath, path)) 68 test.AssertNotError(t, err, fmt.Sprintf("Failed to validate config file %q", path)) 69 }) 70 } 71 } 72 }