Skip to content

Commit 5cc4170

Browse files
committed
fix: run gofmt on modified files
1 parent 2575b16 commit 5cc4170

3 files changed

Lines changed: 45 additions & 45 deletions

File tree

src/code.cloudfoundry.org/gorouter/integration/common_integration_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,55 +198,55 @@ func (s *testState) newGetRequest(url string) *http.Request {
198198
func (s *testState) newMtlsGetRequest(url string) (*http.Request, *http.Client) {
199199
req, err := http.NewRequest("GET", url, nil)
200200
Expect(err).NotTo(HaveOccurred())
201-
201+
202202
// Parse the original hostname for SNI
203203
originalHost := req.URL.Hostname()
204204
port := s.cfg.SSLPort
205-
205+
206206
// Get the base transport to access current TLS config (including any client certs set by tests)
207207
baseTransport := s.client.Transport.(*http.Transport)
208-
208+
209209
// Create custom transport with dialer that connects to 127.0.0.1 but uses original hostname for SNI
210210
transport := &http.Transport{
211211
DialTLSContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
212212
// Read certificates at dial time (not at closure creation time) so we get
213213
// any certificates that tests set after calling newMtlsGetRequest()
214214
currentCerts := baseTransport.TLSClientConfig.Certificates
215-
215+
216216
// Create TLS config for this connection
217217
tlsConfig := &tls.Config{
218218
ServerName: originalHost, // SNI uses original hostname
219219
RootCAs: baseTransport.TLSClientConfig.RootCAs,
220220
Certificates: currentCerts, // Use current certificates from baseTransport
221221
InsecureSkipVerify: true, // Skip cert verification since we connect to 127.0.0.1
222222
}
223-
223+
224224
// Create a plain dialer for the TCP connection
225225
netDialer := &net.Dialer{}
226226
rawConn, err := netDialer.DialContext(ctx, network, fmt.Sprintf("127.0.0.1:%d", port))
227227
if err != nil {
228228
return nil, err
229229
}
230-
230+
231231
// Wrap with TLS
232232
tlsConn := tls.Client(rawConn, tlsConfig)
233-
233+
234234
// Perform handshake
235235
if err := tlsConn.HandshakeContext(ctx); err != nil {
236236
rawConn.Close()
237237
return nil, err
238238
}
239-
239+
240240
return tlsConn, nil
241241
},
242242
}
243-
243+
244244
// Create a new client with the custom transport
245245
client := &http.Client{
246246
Transport: transport,
247247
Timeout: s.client.Timeout,
248248
}
249-
249+
250250
return req, client
251251
}
252252

src/code.cloudfoundry.org/gorouter/integration/identity_aware_routing_test.go

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,27 @@ var _ = Describe("Identity-Aware Routing", func() {
7777
testState.StartGorouterOrFail()
7878
})
7979

80-
It("requires a client certificate", func() {
81-
// Register route on mTLS domain
82-
testState.register(backendApp, mtlsDomain)
83-
84-
// Attempt request without client certificate
85-
req, client := testState.newMtlsGetRequest(fmt.Sprintf("https://%s", mtlsDomain))
86-
_, err := client.Do(req)
87-
Expect(err).To(HaveOccurred())
88-
Expect(err.Error()).To(ContainSubstring("tls"))
89-
})
80+
It("requires a client certificate", func() {
81+
// Register route on mTLS domain
82+
testState.register(backendApp, mtlsDomain)
83+
84+
// Attempt request without client certificate
85+
req, client := testState.newMtlsGetRequest(fmt.Sprintf("https://%s", mtlsDomain))
86+
_, err := client.Do(req)
87+
Expect(err).To(HaveOccurred())
88+
Expect(err.Error()).To(ContainSubstring("tls"))
89+
})
9090

9191
It("accepts valid client certificate from the configured CA", func() {
9292
// Create instance identity certificate (need to use the same CA!)
9393
appInstanceCert = &test_util.CertChain{}
9494
// Recreate with SAME CA as configured in GoRouter
95-
*appInstanceCert = test_util.CreateInstanceIdentityCertWithCA(test_util.InstanceIdentityCertNames{
96-
CommonName: "app-instance",
97-
AppGUID: "app-guid-123",
98-
SpaceGUID: "space-guid-456",
99-
OrgGUID: "org-guid-789",
100-
}, mtlsDomainCA)
95+
*appInstanceCert = test_util.CreateInstanceIdentityCertWithCA(test_util.InstanceIdentityCertNames{
96+
CommonName: "app-instance",
97+
AppGUID: "app-guid-123",
98+
SpaceGUID: "space-guid-456",
99+
OrgGUID: "org-guid-789",
100+
}, mtlsDomainCA)
101101

102102
// Register route on mTLS domain with allowed sources
103103
testState.registerWithAccessRules(
@@ -115,13 +115,13 @@ var _ = Describe("Identity-Aware Routing", func() {
115115
appInstanceCert.TLSCert(),
116116
},
117117
}
118-
testState.client.Transport.(*http.Transport).TLSClientConfig = clientTLSConfig
118+
testState.client.Transport.(*http.Transport).TLSClientConfig = clientTLSConfig
119119

120-
// Make request
121-
req, client := testState.newMtlsGetRequest(fmt.Sprintf("https://%s", mtlsDomain))
122-
resp, err := client.Do(req)
123-
Expect(err).NotTo(HaveOccurred())
124-
Expect(resp.StatusCode).To(Equal(http.StatusOK))
120+
// Make request
121+
req, client := testState.newMtlsGetRequest(fmt.Sprintf("https://%s", mtlsDomain))
122+
resp, err := client.Do(req)
123+
Expect(err).NotTo(HaveOccurred())
124+
Expect(resp.StatusCode).To(Equal(http.StatusOK))
125125

126126
body, _ := io.ReadAll(resp.Body)
127127
resp.Body.Close()
@@ -132,11 +132,11 @@ var _ = Describe("Identity-Aware Routing", func() {
132132
})
133133

134134
It("rejects client certificate from unknown CA", func() {
135-
// Create certificate from different CA (not the configured mtlsDomainCA)
136-
unknownCert := test_util.CreateInstanceIdentityCert(test_util.InstanceIdentityCertNames{
137-
CommonName: "app-instance",
138-
AppGUID: "app-guid-123",
139-
})
135+
// Create certificate from different CA (not the configured mtlsDomainCA)
136+
unknownCert := test_util.CreateInstanceIdentityCert(test_util.InstanceIdentityCertNames{
137+
CommonName: "app-instance",
138+
AppGUID: "app-guid-123",
139+
})
140140

141141
// Register route
142142
testState.register(backendApp, mtlsDomain)
@@ -249,13 +249,13 @@ var _ = Describe("Identity-Aware Routing", func() {
249249
},
250250
)
251251

252-
// Create caller certificate
253-
callerCert := test_util.CreateInstanceIdentityCertWithCA(test_util.InstanceIdentityCertNames{
254-
CommonName: "caller-app-instance",
255-
AppGUID: callerAppGUID,
256-
SpaceGUID: "caller-space-guid",
257-
OrgGUID: "caller-org-guid",
258-
}, mtlsDomainCA)
252+
// Create caller certificate
253+
callerCert := test_util.CreateInstanceIdentityCertWithCA(test_util.InstanceIdentityCertNames{
254+
CommonName: "caller-app-instance",
255+
AppGUID: callerAppGUID,
256+
SpaceGUID: "caller-space-guid",
257+
OrgGUID: "caller-org-guid",
258+
}, mtlsDomainCA)
259259

260260
// Configure client
261261
testState.client.Transport.(*http.Transport).TLSClientConfig.Certificates = []tls.Certificate{

src/code.cloudfoundry.org/gorouter/proxy/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func NewProxy(
152152
rw.Write([]byte(authErr.Error()))
153153
return
154154
}
155-
155+
156156
// For all other errors, use default behavior (502 Bad Gateway)
157157
rw.WriteHeader(http.StatusBadGateway)
158158
rw.Write([]byte(err.Error()))

0 commit comments

Comments
 (0)