(t *testing.T)
| 157 | } |
| 158 | |
| 159 | func TestLoadByPathMultiFileLoading(t *testing.T) { |
| 160 | cfg := newTestConfig() |
| 161 | |
| 162 | // First file: old format |
| 163 | f1 := writeTempYAML(t, ` |
| 164 | name: test-multi |
| 165 | inband_rules: |
| 166 | - crowdsecurity/base-config |
| 167 | on_match: |
| 168 | - filter: "IsInBand == true" |
| 169 | apply: |
| 170 | - SendAlert() |
| 171 | `) |
| 172 | |
| 173 | // Second file: new format |
| 174 | dir := t.TempDir() |
| 175 | f2 := filepath.Join(dir, "config2.yaml") |
| 176 | require.NoError(t, os.WriteFile(f2, []byte(` |
| 177 | inband: |
| 178 | rules: |
| 179 | - crowdsecurity/vpatch-* |
| 180 | on_match: |
| 181 | - apply: |
| 182 | - SetReturnCode(413) |
| 183 | `), 0o644)) |
| 184 | |
| 185 | require.NoError(t, cfg.LoadByPath(f1)) |
| 186 | require.NoError(t, cfg.LoadByPath(f2)) |
| 187 | |
| 188 | // Rules merged from both files |
| 189 | assert.Equal(t, []string{"crowdsecurity/base-config", "crowdsecurity/vpatch-*"}, cfg.InBandRules) |
| 190 | // Shared hook from file 1 |
| 191 | assert.Len(t, cfg.OnMatch, 1) |
| 192 | // Phase-scoped hook from file 2 |
| 193 | require.NotNil(t, cfg.InBand) |
| 194 | assert.Len(t, cfg.InBand.OnMatch, 1) |
| 195 | } |
| 196 | |
| 197 | func TestLoadByPathPhaseOptionsOverride(t *testing.T) { |
| 198 | cfg := newTestConfig() |
nothing calls this directly
no test coverage detected
searching dependent graphs…