diff --git a/v2/account_claims.go b/v2/account_claims.go index 2fea7c6..1f893bd 100644 --- a/v2/account_claims.go +++ b/v2/account_claims.go @@ -230,11 +230,16 @@ type Account struct { DefaultPermissions Permissions `json:"default_permissions,omitempty"` Mappings Mapping `json:"mappings,omitempty"` Authorization ExternalAuthorization `json:"authorization,omitempty"` - TraceDest Subject `json:"trace_dest,omitempty"` + Trace *MsgTrace `json:"trace,omitempty"` Info GenericFields } +// MsgTrace holds distributed message tracing configuration +type MsgTrace struct { + Destination Subject `json:"dest,omitempty"` +} + // Validate checks if the account is valid, based on the wrapper func (a *Account) Validate(acct *AccountClaims, vr *ValidationResults) { a.Imports.Validate(acct.Subject, vr) @@ -243,14 +248,14 @@ func (a *Account) Validate(acct *AccountClaims, vr *ValidationResults) { a.DefaultPermissions.Validate(vr) a.Mappings.Validate(vr) a.Authorization.Validate(vr) - if a.TraceDest != "" { + if a.Trace != nil { tvr := CreateValidationResults() - a.TraceDest.Validate(tvr) + a.Trace.Destination.Validate(tvr) if !tvr.IsEmpty() { - vr.AddError(fmt.Sprintf("the account TraceDest %s", tvr.Issues[0].Description)) + vr.AddError(fmt.Sprintf("the account Trace.Destination %s", tvr.Issues[0].Description)) } - if a.TraceDest.HasWildCards() { - vr.AddError("the account TraceDest subject %q is not a valid publish subject", a.TraceDest) + if a.Trace.Destination.HasWildCards() { + vr.AddError("the account Trace.Destination subject %q is not a valid publish subject", a.Trace.Destination) } } diff --git a/v2/account_claims_test.go b/v2/account_claims_test.go index e4b6a0b..dd5a27e 100644 --- a/v2/account_claims_test.go +++ b/v2/account_claims_test.go @@ -882,12 +882,13 @@ func TestAccountClaimsTraceDest(t *testing.T) { apk := publicKey(akp, t) account := NewAccountClaims(apk) - for _, test := range []struct { + for i, test := range []struct { name string invalidSubj Subject expectErr bool }{ {"trace not specified", "", false}, + {"trace created but with empty destination", "", true}, {"trace dest has spaces", "invalid dest", true}, {"trace dest start with a dot", ".invalid.dest", true}, {"trace dest ends with a dot", "invalid.dest.", true}, @@ -895,7 +896,9 @@ func TestAccountClaimsTraceDest(t *testing.T) { {"trace dest invalid publish dest", "invalid.publish.*.dest", true}, } { t.Run(test.name, func(t *testing.T) { - account.TraceDest = test.invalidSubj + if i > 0 { + account.Trace = &MsgTrace{Destination: test.invalidSubj} + } vr := CreateValidationResults() account.Validate(vr)