From eaba14e591221bc9eae5ac5fa871be0423d6a1d7 Mon Sep 17 00:00:00 2001 From: "R.I.Pienaar" Date: Thu, 14 Feb 2019 15:06:13 +0100 Subject: [PATCH] (#28) include the site and string version of the action --- auditors/natsstream/natsstream.go | 8 +++++--- auditors/natsstream/natsstream_test.go | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/auditors/natsstream/natsstream.go b/auditors/natsstream/natsstream.go index bbc8307..6905aaa 100644 --- a/auditors/natsstream/natsstream.go +++ b/auditors/natsstream/natsstream.go @@ -9,10 +9,10 @@ import ( "fmt" "strings" + "github.com/choria-io/aaasvc/auditors" "github.com/choria-io/go-choria/srvcache" "github.com/choria-io/go-protocol/protocol" "github.com/pkg/errors" - "github.com/choria-io/aaasvc/auditors" "github.com/sirupsen/logrus" "github.com/choria-io/go-choria/backoff" @@ -48,7 +48,8 @@ type NatsStream struct { type Notification struct { Protocol string `json:"protocol"` CallerID string `json:"callerid"` - Action int `json:"action"` + Action string `json:"action"` + Site string `json:"site"` Request json.RawMessage `json:"request"` } @@ -79,7 +80,8 @@ func (ns *NatsStream) Audit(act auditors.Action, caller string, req protocol.Req n := &Notification{ Protocol: "io.choria.signer.v1.signature_audit", CallerID: caller, - Action: int(act), + Action: auditors.ActionNames[act], + Site: ns.site, Request: json.RawMessage(j), } diff --git a/auditors/natsstream/natsstream_test.go b/auditors/natsstream/natsstream_test.go index f691fca..184fa65 100644 --- a/auditors/natsstream/natsstream_test.go +++ b/auditors/natsstream/natsstream_test.go @@ -21,6 +21,7 @@ var _ = Describe("Auditors/NATSStream", func() { It("Should publish valid audit messages", func() { auditor := &NatsStream{ outbox: make(chan interface{}, 1000), + site: "GINKGO", } rpcreq, err := v1.NewRequest("ginkgo", "ginkgo.example.net", "choria=ginkgo", 60, "9b3a0089dbe0d896c1b79bbc12d61212", "mcollective") @@ -38,7 +39,8 @@ var _ = Describe("Auditors/NATSStream", func() { Expect(ok).To(BeTrue()) Expect(notification.Protocol).To(Equal("io.choria.signer.v1.signature_audit")) Expect(notification.CallerID).To(Equal("choria=allowed")) - Expect(notification.Action).To(Equal(int(auditors.Allow))) + Expect(notification.Action).To(Equal("allow")) + Expect(notification.Site).To(Equal("GINKGO")) Expect(notification.Request).To(Equal(json.RawMessage(j))) msg = <-auditor.outbox @@ -46,7 +48,8 @@ var _ = Describe("Auditors/NATSStream", func() { Expect(ok).To(BeTrue()) Expect(notification.Protocol).To(Equal("io.choria.signer.v1.signature_audit")) Expect(notification.CallerID).To(Equal("choria=denied")) - Expect(notification.Action).To(Equal(int(auditors.Deny))) + Expect(notification.Action).To(Equal("deny")) + Expect(notification.Site).To(Equal("GINKGO")) Expect(notification.Request).To(Equal(json.RawMessage(j))) }) })