Skip to content

Unofficial Go library to perform AWS SNS message validation

Notifications You must be signed in to change notification settings

calvinlauyh/go-sns-message-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go SNS Message Validator

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.

Features

Installation

$ go get -u github.com/yuhlau/go-sns-message-validator

Usage

Verifying a SNS message

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

Test

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.

The test cases are written using

Goconvey [Github] as testing framework

$ go get github.com/smartystreets/goconvey

gock [Github] for HTTP mocking

$ go get -u gopkg.in/h2non/gock.v1

License

MIT

Version History

18 Sep 2017, v0.0.1

  • Initial release

About

Unofficial Go library to perform AWS SNS message validation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages