@@ -21,16 +21,17 @@ func TestServer(t *testing.T) {
2121 defer cancel ()
2222
2323 tests := []struct {
24- desc string
25- reqState string
26- port int
27- q url.Values
28- failPage bool
29- statusCode int
30- successPage []byte
31- errorPage []byte
32- testTemplate bool
33- testHTMLInjection bool
24+ desc string
25+ reqState string
26+ port int
27+ q url.Values
28+ failPage bool
29+ statusCode int
30+ successPage []byte
31+ errorPage []byte
32+ testTemplate bool
33+ testErrCodeXSS bool
34+ testErrDescriptionXSS bool
3435 }{
3536 {
3637 desc : "Error: Query Values has 'error' key" ,
@@ -113,13 +114,22 @@ func TestServer(t *testing.T) {
113114 testTemplate : true ,
114115 },
115116 {
116- desc : "Error: Query Values missing 'state' key, using default fail error page - XSS test" ,
117- reqState : "state" ,
118- port : 0 ,
119- q : url.Values {"error" : []string {"<script>alert('this code snippet was executed')</script>" }, "error_description" : []string {"error_description" }},
120- statusCode : 200 ,
121- testTemplate : true ,
122- testHTMLInjection : true ,
117+ desc : "Error: Query Values missing 'state' key, using default fail error page - Error Code XSS test" ,
118+ reqState : "state" ,
119+ port : 0 ,
120+ q : url.Values {"error" : []string {"<script>alert('this code snippet was executed')</script>" }, "error_description" : []string {"error_description" }},
121+ statusCode : 200 ,
122+ testTemplate : true ,
123+ testErrCodeXSS : true ,
124+ },
125+ {
126+ desc : "Error: Query Values missing 'state' key, using default fail error page - Error Description XSS test" ,
127+ reqState : "state" ,
128+ port : 0 ,
129+ q : url.Values {"error" : []string {"error_code" }, "error_description" : []string {"<script>alert('this code snippet was executed')</script>" }},
130+ statusCode : 200 ,
131+ testTemplate : true ,
132+ testErrDescriptionXSS : true ,
123133 },
124134 }
125135
@@ -195,7 +205,7 @@ func TestServer(t *testing.T) {
195205 }
196206
197207 if test .testTemplate {
198- if test .testHTMLInjection {
208+ if test .testErrCodeXSS || test . testErrDescriptionXSS {
199209 if ! strings .Contains (string (content ), "<script>alert('this code snippet was executed')</script>" ) {
200210 t .Errorf ("TestServer(%s): want escaped html entities" , test .desc )
201211 }
0 commit comments