@@ -26,6 +26,8 @@ import (
26
26
"net/url"
27
27
"strings"
28
28
29
+ "github.com/onsi/ginkgo/extensions/table"
30
+
29
31
"github.com/pivotal-cf/brokerapi/middlewares"
30
32
31
33
"code.cloudfoundry.org/lager"
@@ -111,13 +113,6 @@ var _ = Describe("Service Broker API", func() {
111
113
return recorder
112
114
}
113
115
114
- It ("has a X-Correlation-ID header" , func () {
115
- response := makeRequest ()
116
-
117
- header := response .Header ().Get ("X-Correlation-ID" )
118
- Expect (header ).Should (Not (BeNil ()))
119
- })
120
-
121
116
It ("has a Content-Type header" , func () {
122
117
response := makeRequest ()
123
118
@@ -2337,6 +2332,11 @@ var _ = Describe("Service Broker API", func() {
2337
2332
})
2338
2333
2339
2334
Describe ("CorrelationIDHeader" , func () {
2335
+ const correlationID = "fake-correlation-id"
2336
+
2337
+ type testCase struct {
2338
+ correlationIDHeaderName string
2339
+ }
2340
2340
2341
2341
var (
2342
2342
fakeServiceBroker * fakes.AutoFakeServiceBroker
@@ -2360,20 +2360,33 @@ var _ = Describe("Service Broker API", func() {
2360
2360
testServer .Close ()
2361
2361
})
2362
2362
2363
- When ("X-Correlation-ID is passed" , func () {
2364
- It ("Adds correlation id to the context" , func () {
2365
- const correlationID = "fake-correlation-id"
2366
- req .Header .Add ("X-Correlation-ID" , correlationID )
2363
+ table .DescribeTable ("Adds correlation id to the context" , func (tc testCase ) {
2364
+ req .Header .Add (tc .correlationIDHeaderName , correlationID )
2367
2365
2368
- _ , err := http .DefaultClient .Do (req )
2369
- Expect (err ).NotTo (HaveOccurred ())
2366
+ _ , err := http .DefaultClient .Do (req )
2367
+ Expect (err ).NotTo (HaveOccurred ())
2370
2368
2371
- Expect (fakeServiceBroker .ServicesCallCount ()).To (Equal (1 ), "Services was not called" )
2372
- ctx := fakeServiceBroker .ServicesArgsForCall (0 )
2373
- Expect (ctx .Value (middlewares .CorrelationIDKey )).To (Equal (correlationID ))
2369
+ Expect (fakeServiceBroker .ServicesCallCount ()).To (Equal (1 ), "Services was not called" )
2370
+ ctx := fakeServiceBroker .ServicesArgsForCall (0 )
2371
+ Expect (ctx .Value (middlewares .CorrelationIDKey )).To (Equal (correlationID ))
2372
+ },
2373
+ table .Entry ("X-Correlation-ID" , testCase {
2374
+ correlationIDHeaderName : "X-Correlation-ID" ,
2375
+ }),
2376
+ table .Entry ("X-CorrelationID" , testCase {
2377
+ correlationIDHeaderName : "X-CorrelationID" ,
2378
+ }),
2379
+ table .Entry ("X-ForRequest-ID" , testCase {
2380
+ correlationIDHeaderName : "X-ForRequest-ID" ,
2381
+ }),
2382
+ table .Entry ("X-Request-ID" , testCase {
2383
+ correlationIDHeaderName : "X-Request-ID" ,
2384
+ }),
2385
+ table .Entry ("X-Vcap-Request-Id" , testCase {
2386
+ correlationIDHeaderName : "X-Vcap-Request-Id" ,
2387
+ }),
2388
+ )
2374
2389
2375
- })
2376
- })
2377
2390
When ("X-Correlation-ID is not passed" , func () {
2378
2391
It ("Generates correlation id and adds it to the context" , func () {
2379
2392
_ , err := http .DefaultClient .Do (req )
0 commit comments