"fmt" "github.com/cloudfoundry-incubator/routing-api/db" "github.com/tedsuo/ifrit" "github.com/tedsuo/ifrit/ginkgomon" "github.com/cloudfoundry-incubator/routing-api/cmd/routing-api/testrunner" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Routes API", func() { var routingAPIProcess ifrit.Process BeforeEach(func() { routingAPIRunner := testrunner.New(routingAPIBinPath, routingAPIArgs) routingAPIProcess = ginkgomon.Invoke(routingAPIRunner) }) AfterEach(func() { ginkgomon.Kill(routingAPIProcess) }) Describe("Routes", func() { var routes []db.Route var getErr error var route1, route2 db.Route BeforeEach(func() { route1 = db.Route{ Route: "a.b.c",
oAuthServer := func(logger lager.Logger) *ghttp.Server { server := ghttp.NewServer() server.AllowUnhandledRequests = true server.RouteToHandler("POST", "/oauth/token", func(w http.ResponseWriter, req *http.Request) { jsonBytes := []byte(`{"access_token":"some-token", "expires_in":10}`) w.Write(jsonBytes) }, ) logger.Info("starting-oauth-server", lager.Data{"address": server.URL()}) return server } routingApiServer := func(logger lager.Logger) ifrit.Process { server := routingtestrunner.New(routingAPIBinPath, routingAPIArgs) logger.Info("starting-routing-api-server") return ifrit.Invoke(server) } generateConfigFile := func(oauthServerPort, routingApiServerPort string, routingApiAuthDisabled bool) string { randomConfigFileName := testutil.RandomFileName("router_configurer", ".yml") configFile := path.Join(os.TempDir(), randomConfigFileName) cfg := fmt.Sprintf("%s\n port: %s\n%s\n auth_disabled: %t\n %s\n port: %s\n", `oauth: token_endpoint: "http://127.0.0.1" client_name: "someclient" client_secret: "somesecret"`, oauthServerPort, `routing_api:`, routingApiAuthDisabled,