@@ -31,26 +31,31 @@ func signature(body string) string {
31
31
return "sha1=" + string (dst )
32
32
}
33
33
34
- func TestMissingSignature (t * testing.T ) {
34
+ func TestNonPost (t * testing.T ) {
35
35
r , _ := http .NewRequest ("GET" , "/path" , nil )
36
+ expectParseError (t , "Unknown method!" , r )
37
+ }
38
+
39
+ func TestMissingSignature (t * testing.T ) {
40
+ r , _ := http .NewRequest ("POST" , "/path" , nil )
36
8000
td>41
expectParseError (t , "No signature!" , r )
37
42
}
38
43
39
44
func TestMissingEvent (t * testing.T ) {
40
- r , _ := http .NewRequest ("GET " , "/path" , nil )
45
+ r , _ := http .NewRequest ("POST " , "/path" , nil )
41
46
r .Header .Add ("x-hub-signature" , "bogus signature" )
42
47
expectParseError (t , "No event!" , r )
43
48
}
44
49
45
50
func TestMissingEventId (t * testing.T ) {
46
- r , _ := http .NewRequest ("GET " , "/path" , nil )
51
+ r , _ := http .NewRequest ("POST " , "/path" , nil )
47
52
r .Header .Add ("x-hub-signature" , "bogus signature" )
48
53
r .Header .Add ("x-github-event" , "bogus event" )
49
54
expectParseError (t , "No event Id!" , r )
50
55
}
51
56
52
57
func TestInvalidSignature (t * testing.T ) {
53
- r , _ := http .NewRequest ("GET " , "/path" , strings .NewReader ("..." ))
58
+ r , _ := http .NewRequest ("POST " , "/path" , strings .NewReader ("..." ))
54
59
r .Header .Add ("x-hub-signature" , "bogus signature" )
55
60
r .Header .Add ("x-github-event" , "bogus event" )
56
61
r .Header .Add ("x-github-delivery" , "bogus id" )
@@ -61,7 +66,7 @@ func TestValidSignature(t *testing.T) {
61
66
62
67
body := "{}"
63
68
64
- r , _ := http .NewRequest ("GET " , "/path" , strings .NewReader (body ))
69
+ r , _ := http .NewRequest ("POST " , "/path" , strings .NewReader (body ))
65
70
r .Header .Add ("x-hub-signature" , signature (body ))
66
71
r .Header .Add ("x-github-event" , "bogus event" )
67
72
r .Header .Add ("x-github-delivery" , "bogus id" )
0 commit comments