func TestAuthSuccess(t *testing.T) {
	w, r := MakeRequest("POST", "/pub/place", "MESSAGE")
	token := Sha1HMAC(TEST_KEY, "/pub/place")
	r.SetBasicAuth(token, "")
	func() {
		hookbot := New(TEST_KEY)
		defer hookbot.Shutdown()
		hookbot.ServeHTTP(w, r)
	}()
	if w.Code != http.StatusOK {
		t.Errorf("Status code != 200 (= %v)", w.Code)
	}
}
Valid secret authentication should return 200 OK
package hookbot
import (
	"bufio"
	"bytes"
	"fmt"
	"net"
	"net/http"
	"net/http/httptest"
	"testing"
)
const (
	TEST_GITHUB_SECRET = "github_secret"
	TEST_KEY           = "key"
)
func MakeRequest(method, url, body string) (w *httptest.ResponseRecorder, r *http.Request) {
	w = httptest.NewRecorder()
	bodyReader := bytes.NewReader([]byte(body))
	r, _ = http.NewRequest(method, "http://localhost"+url, bodyReader)
	return w, r
}
func TestAuthMissingFail(t *testing.T) {
	w, r := MakeRequest("POST", "/pub/", "MESSAGE")
	func() {
		hookbot := New(TEST_KEY)
		defer hookbot.Shutdown()
		hookbot.ServeHTTP(w, r)
	}()
	if w.Code != http.StatusUnauthorized {
		t.Errorf("Status code != 404 (= %v)", w.Code)
	}
}
func TestAuthInvalidSecret(t *testing.T) {
	w, r := MakeRequest("POST", "/pub/", "MESSAGE")
	token := Sha1HMAC(TEST_KEY, "/pub/not/the/same/as/above")  
	r.SetBasicAuth(token, "")
	func() {
		hookbot := New(TEST_KEY)
		defer hookbot.Shutdown()
		hookbot.ServeHTTP(w, r)
	}()
	if w.Code != http.StatusUnauthorized {
		t.Errorf("Status code != 404 (= %v)", w.Code)
	}
}