Ejemplo n.º 1
0
func (self *S) SetUpTest(c *C) {
	self.request = testutil.RequestFromSNS()

	self.expectedNotification = &Notification{
		Type:             "Notification",
		MessageId:        "da41e39f-ea4d-435a-b922-c6aae3915ebe",
		TopicArn:         "arn:aws:sns:us-east-1:123456789012:MyTopic",
		Subject:          "test",
		Message:          "test message",
		Timestamp:        "2012-04-25T21:49:25.719Z",
		SignatureVersion: "1",
		Signature:        "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",
		SigningCertURL:   "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
		UnsubscribeURL:   "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55",
	}
}
Ejemplo n.º 2
0
func (self *S) TestSubscribe(c *C) {
	var wg sync.WaitGroup
	wg.Add(1)
	go func() {
		time.Sleep(time.Second)
		req := testutil.RequestFromSNS()
		http.Post("http://localhost"+port+"/publish/foo", "text/plain", req.Body)
		wg.Done()
	}()

	p := make([]byte, 50)
	resp, err := http.Get("http://localhost" + port + "/subscribe/foo")
	n, err := resp.Body.Read(p)
	text := string(p[:n])

	c.Check(err, IsNil)
	c.Check(strings.Trim(text, "\n"), Equals, "data: test message")
	wg.Wait()
}
Ejemplo n.º 3
0
func (self *S) TestPublish(c *C) {
	req := testutil.RequestFromSNS()
	resp, err := http.Post("http://localhost"+port+"/publish/foo", "text/plain", req.Body)
	c.Check(err, IsNil)
	c.Check(resp.StatusCode, Equals, 200)
}