Added unit tests for bad meta values
This commit is contained in:
parent
5c4d8940ea
commit
ef7a35b203
|
@ -999,7 +999,7 @@ func (b *Builder) serviceVal(v *ServiceDefinition) *structs.ServiceDefinition {
|
|||
|
||||
meta := make(map[string]string)
|
||||
if err := structs.ValidateMetadata(v.Meta, false); err != nil {
|
||||
b.err = multierror.Append(fmt.Errorf("invalid meta for service %v: %v", v.Name, err))
|
||||
b.err = multierror.Append(fmt.Errorf("invalid meta for service %s: %v", *v.Name, err))
|
||||
} else {
|
||||
meta = v.Meta
|
||||
}
|
||||
|
|
|
@ -1939,6 +1939,32 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
|
|||
rt.DataDir = dataDir
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "service with wrong meta: too long",
|
||||
args: []string{
|
||||
`-data-dir=` + dataDir,
|
||||
},
|
||||
json: []string{
|
||||
`{ "service": { "name": "a", "port": 80, "meta": { "a": "` + randomString(520) + `" } } }`,
|
||||
},
|
||||
hcl: []string{
|
||||
`service = { name = "a" port = 80, meta={a="` + randomString(520) + `"} }`,
|
||||
},
|
||||
err: `Value is too long`,
|
||||
},
|
||||
{
|
||||
desc: "service with wrong meta: too many meta",
|
||||
args: []string{
|
||||
`-data-dir=` + dataDir,
|
||||
},
|
||||
json: []string{
|
||||
`{ "service": { "name": "a", "port": 80, "meta": { ` + metaPairs(70, "json") + `} } }`,
|
||||
},
|
||||
hcl: []string{
|
||||
`service = { name = "a" port = 80 meta={` + metaPairs(70, "hcl") + `} }`,
|
||||
},
|
||||
err: `invalid meta for service a: Node metadata cannot contain more than 64 key`,
|
||||
},
|
||||
{
|
||||
desc: "translated keys",
|
||||
args: []string{
|
||||
|
|
Loading…
Reference in New Issue