Go SMS Message Validator is an unofficial Go library for validating AWS SNS message. It validates an incoming SNS Message authenticity and integrity by validating the message structure and verifying the message signature. It is standalone and does not require AWS SDK to work.
This project is still in its early development and a more stable release will be coming out in a few weeks.
- Follows AWS documentation on message validation
- Validate message structure
- Verify message signature
$ go get -u github.com/yuhlau/go-sns-message-validator
import (
"fmt"
"github.com/yuhlau/go-sns-message-validator/snsmessage"
)
// Retrieve SNS message in JSON format from HTTP request and store into variable messageJSON
...
message, err := snsmessage.NewFromJSON([]byte(messageJSON))
if err != nil {
fmt.Println(err)
}
if err := message.GetValidator().ValidateMessage(); err != nil {
fmt.Println(err)
}
// The SNS message is validated now
Most of the code are covered by test. Test coverage is about 99.5% right now. The only remaining part is an I/O error handling which requires special data to cover it in the test.
More testing with the real AWS platform is in progress and the first stable 1.0.0
release will wait until all tests are finished.
Goconvey [Github] as testing framework
$ go get github.com/smartystreets/goconvey
gock [Github] for HTTP mocking
$ go get -u gopkg.in/h2non/gock.v1
MIT
18 Sep 2017, v0.0.1
- Initial release