Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-a-d-nguyen committed Aug 21, 2024
1 parent dc13533 commit 98992e6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions integration/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"testing"
)

const RouteRegistrarPackage = "code.cloudfoundry.org/route-registrar/"
const routeRegistrarPackage = "code.cloudfoundry.org/route-registrar/"

var (
routeRegistrarBinPath string
Expand All @@ -29,7 +29,7 @@ func TestIntegration(test *testing.T) {
}

var _ = SynchronizedBeforeSuite(func() []byte {
path, err := gexec.Build(RouteRegistrarPackage, "-race")
path, err := gexec.Build(routeRegistrarPackage, "-race")
Expect(err).ShouldNot(HaveOccurred())

return []byte(path)
Expand Down
14 changes: 8 additions & 6 deletions integration/tcp_route_registration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strconv"
"time"

tls_helpers "code.cloudfoundry.org/cf-routing-test-helpers/tls"
tlsHelpers "code.cloudfoundry.org/cf-routing-test-helpers/tls"
"code.cloudfoundry.org/route-registrar/config"

"github.com/onsi/gomega/gbytes"
Expand All @@ -31,14 +31,14 @@ var _ = Describe("TCP Route Registration", func() {
)

BeforeEach(func() {
routingAPICAFileName, routingAPICAPrivateKey := tls_helpers.GenerateCa()
_, _, serverTLSConfig := tls_helpers.GenerateCertAndKey(routingAPICAFileName, routingAPICAPrivateKey)
routingAPIClientCertPath, routingAPIClientPrivateKeyPath, _ := tls_helpers.GenerateCertAndKey(routingAPICAFileName, routingAPICAPrivateKey)
routingAPICAFileName, routingAPICAPrivateKey := tlsHelpers.GenerateCa()
_, _, serverTLSConfig := tlsHelpers.GenerateCertAndKey(routingAPICAFileName, routingAPICAPrivateKey)
routingAPIClientCertPath, routingAPIClientPrivateKeyPath, _ := tlsHelpers.GenerateCertAndKey(routingAPICAFileName, routingAPICAPrivateKey)

routingAPIServer = ghttp.NewUnstartedServer()
routingAPIServer.HTTPTestServer.TLS = &tls.Config{}
routingAPIServer.HTTPTestServer.TLS.RootCAs = tls_helpers.CertPool(routingAPICAFileName)
routingAPIServer.HTTPTestServer.TLS.ClientCAs = tls_helpers.CertPool(routingAPICAFileName)
routingAPIServer.HTTPTestServer.TLS.RootCAs = tlsHelpers.CertPool(routingAPICAFileName)
routingAPIServer.HTTPTestServer.TLS.ClientCAs = tlsHelpers.CertPool(routingAPICAFileName)
routingAPIServer.HTTPTestServer.TLS.ClientAuth = tls.RequireAndVerifyClientCert
routingAPIServer.HTTPTestServer.TLS.CipherSuites = []uint16{tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}
routingAPIServer.HTTPTestServer.TLS.Certificates = []tls.Certificate{serverTLSConfig}
Expand All @@ -58,7 +58,9 @@ var _ = Describe("TCP Route Registration", func() {
ghttp.VerifyJSON(`[{
"router_group_guid":"router-group-guid",
"backend_port":1234,
"backend_tls_port": -1,
"backend_ip":"127.0.0.1",
"instance_id": "",
"port":5678,
"modification_tag":{
"guid":"",
Expand Down
7 changes: 6 additions & 1 deletion routingapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,17 @@ func (r *RoutingAPI) makeTcpRouteMapping(route config.Route) (models.TcpRouteMap

r.logger.Info("Creating mapping", lager.Data{})

hostTLSPort := -1
if route.TLSPort != nil {
hostTLSPort = *route.TLSPort
}

return models.NewTcpRouteMapping(
routerGroupGUID,
uint16(*route.ExternalPort),
route.Host,
uint16(*route.Port),
0,
hostTLSPort,
"",
nilIfEmpty(&route.ServerCertDomainSAN),
calculateTTL(route.RegistrationInterval, r.routingAPIMaxTTL),
Expand Down

0 comments on commit 98992e6

Please sign in to comment.