@@ -139,8 +139,25 @@ creation_rules:
139139 encrypted_suffix: _enc
140140 ` )
141141
142- var sampleInvalidConfig = []byte (`
142+ var sampleConfigWithNoMatchingRules = []byte (`
143143creation_rules:
144+ - path_regex: notexisting
145+ pgp: bar
146+ ` )
147+
148+ var sampleEmptyConfig = []byte (`` )
149+
150+ var sampleConfigWithEmptyCreationRules = []byte (`
151+ creation_rules:
152+ ` )
153+
154+ var sampleConfigWithOnlyDestinationRules = []byte (`
155+ destination_rules:
156+ - path_regex: ""
157+ s3_bucket: "foobar"
158+ s3_prefix: "test/"
159+ recreation_rule:
160+ pgp: newpgp
144161` )
145162
146163var sampleConfigWithDestinationRule = []byte (`
@@ -178,6 +195,9 @@ destination_rules:
178195 vault_kv_mount_name: "kv/"
179196 vault_kv_version: 1
180197 path_regex: "vault-v1/*"
198+ - vault_path: "omit/"
199+ vault_path_omit_filename: true
200+ path_regex: "vault-omit-filename/*"
181201` )
182202
183203func parseConfigFile (confBytes []byte , t * testing.T ) * configFile {
@@ -248,11 +268,29 @@ func TestLoadConfigFileWithGroups(t *testing.T) {
248268 assert .Equal (t , expected , conf )
249269}
250270
251- func TestLoadInvalidConfigFile (t * testing.T ) {
252- _ , err := parseCreationRuleForFile (parseConfigFile (sampleInvalidConfig , t ), "foobar2000" , nil )
271+ func TestLoadConfigFileWithNoMatchingRules (t * testing.T ) {
272+ _ , err := parseCreationRuleForFile (parseConfigFile (sampleConfigWithNoMatchingRules , t ), "foobar2000" , nil )
253273 assert .NotNil (t , err )
254274}
255275
276+ func TestLoadEmptyConfigFile (t * testing.T ) {
277+ conf , err := parseCreationRuleForFile (parseConfigFile (sampleEmptyConfig , t ), "foobar2000" , nil )
278+ assert .Nil (t , conf )
279+ assert .Nil (t , err )
280+ }
281+
282+ func TestLoadConfigFileWithEmptyCreationRules (t * testing.T ) {
283+ conf , err := parseCreationRuleForFile (parseConfigFile (sampleConfigWithEmptyCreationRules , t ), "foobar2000" , nil )
284+ assert .Nil (t , conf )
285+ assert .Nil (t , err )
286+ }
287+
288+ func TestLoadConfigFileWithOnlyDestinationRules (t * testing.T ) {
289+ conf , err := parseCreationRuleForFile (parseConfigFile (sampleConfigWithOnlyDestinationRules , t ), "foobar2000" , nil )
290+ assert .Nil (t , conf )
291+ assert .Nil (t , err )
292+ }
293+
256294func TestKeyGroupsForFile (t * testing.T ) {
257295 conf , err := parseCreationRuleForFile (parseConfigFile (sampleConfig , t ), "foobar2000" , nil )
258296 assert .Nil (t , err )
@@ -328,4 +366,8 @@ func TestLoadConfigFileWithVaultDestinationRules(t *testing.T) {
328366 assert .Nil (t , err )
329367 assert .NotNil (t , conf .Destination )
330368 assert .Equal (t , "http://127.0.0.1:8200/v1/kv/barfoo/barfoo" , conf .Destination .Path ("barfoo" ))
369+ conf , err = parseDestinationRuleForFile (parseConfigFile (sampleConfigWithVaultDestinationRules , t ), "vault-omit-filename/barfoo" , nil )
370+ assert .Nil (t , err )
371+ assert .NotNil (t , conf .Destination )
372+ assert .Equal (t , "http://127.0.0.1:8200/v1/secret/data/omit/" , conf .Destination .Path ("omit" ))
331373}
0 commit comments