@@ -20,99 +20,115 @@ func TestResultSummarizerShouldSummarizeResults(t *testing.T) {
2020 sut := summarizer .NewResultSummarizer (tree .NewResultTreeProducer (), logger )
2121
2222 sut .Add (
23- scan .NewResult (scan.Target {
24- Method : http .MethodPost ,
25- Path : "/home" ,
26- }, & http.Response {
27- StatusCode : http .StatusCreated ,
28- Request : & http.Request {
29- URL : test .MustParseURL (t , "http://mysite/home" ),
23+ scan .NewResult (
24+ scan.Target {
25+ Method : http .MethodPost ,
26+ Path : "/home" ,
3027 },
31- }, nil ),
28+ & http.Response {
29+ StatusCode : http .StatusCreated ,
30+ Request : & http.Request {
31+ URL : test .MustParseURL (t , "http://mysite/home" ),
32+ },
33+ }, nil ),
3234 )
3335
3436 sut .Add (
35- scan .NewResult (scan.Target {
36- Method : http .MethodPost ,
37- Path : "/home/hidden" ,
38- }, & http.Response {
39- StatusCode : http .StatusCreated ,
40- Request : & http.Request {
41- URL : test .MustParseURL (t , "http://mysite/home/hidden" ),
37+ scan .NewResult (
38+ scan.Target {
39+ Method : http .MethodPost ,
40+ Path : "/home/hidden" ,
4241 },
43- }, nil ),
42+ & http.Response {
43+ StatusCode : http .StatusCreated ,
44+ Request : & http.Request {
45+ URL : test .MustParseURL (t , "http://mysite/home/hidden" ),
46+ },
47+ }, nil ),
4448 )
4549
4650 sut .Add (
47- scan .NewResult (scan.Target {
48- Method : http .MethodGet ,
49- Path : "/home/about" ,
50- }, & http.Response {
51- StatusCode : http .StatusOK ,
52- Request : & http.Request {
53- URL : test .MustParseURL (t , "http://mysite/home/about" ),
51+ scan .NewResult (
52+ scan.Target {
53+ Method : http .MethodGet ,
54+ Path : "/home/about" ,
5455 },
55- }, nil ),
56+ & http.Response {
57+ StatusCode : http .StatusOK ,
58+ Request : & http.Request {
59+ URL : test .MustParseURL (t , "http://mysite/home/about" ),
60+ },
61+ }, nil ),
5662 )
5763
5864 sut .Add (
59- scan .NewResult (scan.Target {
60- Method : http .MethodGet ,
61- Path : "/home/about/me" ,
62- }, & http.Response {
63- StatusCode : http .StatusOK ,
64- Request : & http.Request {
65- URL : test .MustParseURL (t , "http://mysite/home/about/me" ),
65+ scan .NewResult (
66+ scan.Target {
67+ Method : http .MethodGet ,
68+ Path : "/home/about/me" ,
6669 },
67- }, nil ),
70+ & http.Response {
71+ StatusCode : http .StatusOK ,
72+ Request : & http.Request {
73+ URL : test .MustParseURL (t , "http://mysite/home/about/me" ),
74+ },
75+ }, nil ),
6876 )
6977
7078 sut .Add (
71- scan .NewResult (scan.Target {
72- Method : http .MethodGet ,
73- Path : "/home/home" ,
74- }, & http.Response {
75- StatusCode : http .StatusOK ,
76- Request : & http.Request {
77- URL : test .MustParseURL (t , "http://mysite/home/home" ),
79+ scan .NewResult (
80+ scan.Target {
81+ Method : http .MethodGet ,
82+ Path : "/home/home" ,
7883 },
79- }, nil ),
84+ & http.Response {
85+ StatusCode : http .StatusOK ,
86+ Request : & http.Request {
87+ URL : test .MustParseURL (t , "http://mysite/home/home" ),
88+ },
89+ }, nil ),
8090 )
8191
8292 sut .Add (
83- scan .NewResult (scan.Target {
84- Method : http .MethodGet ,
85- Path : "/contacts" ,
86- }, & http.Response {
87- StatusCode : http .StatusOK ,
88- Request : & http.Request {
89- URL : test .MustParseURL (t , "http://mysite/contacts" ),
93+ scan .NewResult (
94+ scan.Target {
95+ Method : http .MethodGet ,
96+ Path : "/contacts" ,
9097 },
91- }, nil ),
98+ & http.Response {
99+ StatusCode : http .StatusOK ,
100+ Request : & http.Request {
101+ URL : test .MustParseURL (t , "http://mysite/contacts" ),
102+ },
103+ }, nil ),
92104 )
93105
94106 sut .Add (
95- scan .NewResult (scan.Target {
96- Method : http .MethodGet ,
97- Path : "/gibberish" ,
98- }, & http.Response {
99- StatusCode : http .StatusNotFound ,
100- Request : & http.Request {
101- URL : test .MustParseURL (t , "http://mysite/gibberish" ),
107+ scan .NewResult (
108+ scan.Target {
109+ Method : http .MethodGet ,
110+ Path : "/gibberish" ,
102111 },
103- }, nil ),
112+ & http.Response {
113+ StatusCode : http .StatusNotFound ,
114+ Request : & http.Request {
115+ URL : test .MustParseURL (t , "http://mysite/gibberish" ),
116+ },
117+ }, nil ),
104118 )
105119
106120 sut .Add (
107- scan .NewResult (scan.Target {
108- Method : http .MethodGet ,
109- Path : "/path/to/my/files" ,
110- }, & http.Response {
111- StatusCode : http .StatusOK ,
112- Request : & http.Request {
113- URL : test .MustParseURL (t , "http://mysite/path/to/my/files" ),
121+ scan .NewResult (
122+ scan.Target {
123+ Method : http .MethodGet ,
124+ Path : "/path/to/my/files" ,
114125 },
115- }, nil ),
126+ & http.Response {
127+ StatusCode : http .StatusOK ,
128+ Request : & http.Request {
129+ URL : test .MustParseURL (t , "http://mysite/path/to/my/files" ),
130+ },
131+ }, nil ),
116132 )
117133
118134 // Adding multiple times the same result should not change the outcome
@@ -127,15 +143,17 @@ func TestResultSummarizerShouldSummarizeResults(t *testing.T) {
127143 defer wg .Done ()
128144
129145 sut .Add (
130- scan .NewResult (scan.Target {
131- Method : http .MethodGet ,
132- Path : "/path/to/my/files" ,
133- }, & http.Response {
134- StatusCode : http .StatusOK ,
135- Request : & http.Request {
136- URL : test .MustParseURL (t , "http://mysite/path/to/my/files" ),
146+ scan .NewResult (
147+ scan.Target {
148+ Method : http .MethodGet ,
149+ Path : "/path/to/my/files" ,
137150 },
138- }, nil ),
151+ & http.Response {
152+ StatusCode : http .StatusOK ,
153+ Request : & http.Request {
154+ URL : test .MustParseURL (t , "http://mysite/path/to/my/files" ),
155+ },
156+ }, nil ),
139157 )
140158 }()
141159 }
@@ -176,15 +194,17 @@ func TestResultSummarizerShouldLogResults(t *testing.T) {
176194 expectedToContain []string
177195 }{
178196 {
179- result : scan .NewResult (scan.Target {
180- Method : http .MethodPost ,
181- Path : "/home" ,
182- }, & http.Response {
183- StatusCode : http .StatusOK ,
184- Request : & http.Request {
185- URL : test .MustParseURL (t , "http://mysite/home" ),
197+ result : scan .NewResult (
198+ scan.Target {
199+ Method : http .MethodPost ,
200+ Path : "/home" ,
186201 },
187- }, nil ),
202+ & http.Response {
203+ StatusCode : http .StatusOK ,
204+ Request : & http.Request {
205+ URL : test .MustParseURL (t , "http://mysite/home" ),
206+ },
207+ }, nil ),
188208 expectedToContain : []string {
189209 "Found" ,
190210 "method=POST" ,
@@ -193,15 +213,17 @@ func TestResultSummarizerShouldLogResults(t *testing.T) {
193213 },
194214 },
195215 {
196- result : scan .NewResult (scan.Target {
197- Method : http .MethodGet ,
198- Path : "/index" ,
199- }, & http.Response {
200- StatusCode : http .StatusBadGateway ,
201- Request : & http.Request {
202- URL : test .MustParseURL (t , "http://mysite/index" ),
216+ result : scan .NewResult (
217+ scan.Target {
218+ Method : http .MethodGet ,
219+ Path : "/index" ,
203220 },
204- }, nil ),
221+ & http.Response {
222+ StatusCode : http .StatusBadGateway ,
223+ Request : & http.Request {
224+ URL : test .MustParseURL (t , "http://mysite/index" ),
225+ },
226+ }, nil ),
205227 expectedToContain : []string {
206228 "Found something breaking" ,
207229 "method=GET" ,
@@ -210,15 +232,17 @@ func TestResultSummarizerShouldLogResults(t *testing.T) {
210232 },
211233 },
212234 {
213- result : scan .NewResult (scan.Target {
214- Method : http .MethodGet ,
215- Path : "/gibberish" ,
216- }, & http.Response {
217- StatusCode : http .StatusNotFound ,
218- Request : & http.Request {
219- URL : test .MustParseURL (t , "http://mysite/gibberish" ),
235+ result : scan .NewResult (
236+ scan.Target {
237+ Method : http .MethodGet ,
238+ Path : "/gibberish" ,
220239 },
221- }, nil ),
240+ & http.Response {
241+ StatusCode : http .StatusNotFound ,
242+ Request : & http.Request {
243+ URL : test .MustParseURL (t , "http://mysite/gibberish" ),
244+ },
245+ }, nil ),
222246 expectedToContain : []string {
223247 "Found" ,
224248 "method=GET" ,
0 commit comments