Skip to content

Commit

Permalink
Merge pull request #29 from ripienaar/28
Browse files Browse the repository at this point in the history
(#28) include the site and string version of the action
  • Loading branch information
ripienaar authored Feb 14, 2019
2 parents 343269a + eaba14e commit 97be2a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions auditors/natsstream/natsstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"`
}

Expand Down Expand Up @@ -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),
}

Expand Down
7 changes: 5 additions & 2 deletions auditors/natsstream/natsstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -38,15 +39,17 @@ 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
notification, ok = msg.(*Notification)
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)))
})
})
Expand Down

0 comments on commit 97be2a6

Please sign in to comment.