MCPcopy Create free account
hub / github.com/activecm/rita / ReadTestFileConfig

Function ReadTestFileConfig

config/config.go:620–642  ·  view source on GitHub ↗

ReadTestFileConfig is for TESTS only

(afs afero.Fs, path string)

Source from the content-addressed store, hash-verified

618
619// ReadTestFileConfig is for TESTS only
620func ReadTestFileConfig(afs afero.Fs, path string) (*Config, error) {
621 // read the config file
622 contents, err := util.GetFileContents(afs, path)
623 if err != nil {
624 return nil, err
625 }
626
627 // create a temporary config just to generate the environment
628 var tmpCfg Config
629 if err := tmpCfg.setEnv(); err != nil {
630 return nil, fmt.Errorf("unable to set environment variables for TEST environment")
631 }
632 // override path based variables since tests use their package directory
633 tmpCfg.Env.HTTPExtensionsFilePath = "../deployment/http_extensions_list.csv"
634 tmpCfg.Env.ThreatIntelCustomFeedsDirectory = "../deployment/threat_intel_feeds"
635
636 var cfg Config
637 if err := unmarshal(contents, &cfg, &tmpCfg.Env); err != nil {
638 return nil, fmt.Errorf("%w, located by default at '%s', please correct the issue in the config and try again:\n\t- %w", errReadingConfigFile, path, err)
639 }
640
641 return &cfg, nil
642}

Callers 1

Calls 3

setEnvMethod · 0.95
GetFileContentsFunction · 0.92
unmarshalFunction · 0.85

Tested by 1