@@ -26,6 +26,8 @@ import (
2626 "net/url"
2727 "strings"
2828
29+ "github.com/onsi/ginkgo/extensions/table"
30+
2931 "github.com/pivotal-cf/brokerapi/middlewares"
3032
3133 "code.cloudfoundry.org/lager"
@@ -111,13 +113,6 @@ var _ = Describe("Service Broker API", func() {
111113 return recorder
112114 }
113115
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-
121116 It ("has a Content-Type header" , func () {
122117 response := makeRequest ()
123118
@@ -2337,6 +2332,11 @@ var _ = Describe("Service Broker API", func() {
23372332 })
23382333
23392334 Describe ("CorrelationIDHeader" , func () {
2335+ const correlationID = "fake-correlation-id"
2336+
2337+ type testCase struct {
2338+ correlationIDHeaderName string
2339+ }
23402340
23412341 var (
23422342 fakeServiceBroker * fakes.AutoFakeServiceBroker
@@ -2360,20 +2360,33 @@ var _ = Describe("Service Broker API", func() {
23602360 testServer .Close ()
23612361 })
23622362
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 )
23672365
2368- _ , err := http .DefaultClient .Do (req )
2369- Expect (err ).NotTo (HaveOccurred ())
2366+ _ , err := http .DefaultClient .Do (req )
2367+ Expect (err ).NotTo (HaveOccurred ())
23702368
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+ )
23742389
2375- })
2376- })
23772390 When ("X-Correlation-ID is not passed" , func () {
23782391 It ("Generates correlation id and adds it to the context" , func () {
23792392 _ , err := http .DefaultClient .Do (req )
0 commit comments