(t *testing.T)
| 21 | ) |
| 22 | |
| 23 | func TestHTTP(t *testing.T) { |
| 24 | port := test.GetNextPort(t, "HTTP") |
| 25 | logger := log.NewTestLogger(t) |
| 26 | srv, err := config.NewServer( |
| 27 | configuration.HTTPServerConfiguration{ |
| 28 | Listen: fmt.Sprintf("127.0.0.1:%d", port), |
| 29 | }, |
| 30 | &myConfigReqHandler{}, |
| 31 | logger, |
| 32 | ) |
| 33 | assert.NoError(t, err) |
| 34 | lifecycle := service2.NewLifecycle(srv) |
| 35 | |
| 36 | ready := make(chan struct{}) |
| 37 | lifecycle.OnRunning( |
| 38 | func(s service2.Service, l service2.Lifecycle) { |
| 39 | ready <- struct{}{} |
| 40 | }, |
| 41 | ) |
| 42 | go func() { |
| 43 | _ = lifecycle.Run() |
| 44 | }() |
| 45 | <-ready |
| 46 | |
| 47 | client, err := config.NewClient( |
| 48 | configuration.ClientConfig{ |
| 49 | HTTPClientConfiguration: configuration.HTTPClientConfiguration{ |
| 50 | URL: fmt.Sprintf("http://127.0.0.1:%d", port), |
| 51 | Timeout: 2 * time.Second, |
| 52 | }, |
| 53 | }, logger, getMetricsCollector(t), |
| 54 | ) |
| 55 | assert.NoError(t, err) |
| 56 | |
| 57 | connectionID := "0123456789ABCDEF" |
| 58 | |
| 59 | cfg, _, err := client.Get( |
| 60 | context.Background(), |
| 61 | metadata.ConnectionAuthenticatedMetadata{ |
| 62 | ConnectionAuthPendingMetadata: metadata.ConnectionAuthPendingMetadata{ |
| 63 | ConnectionMetadata: metadata.ConnectionMetadata{ |
| 64 | RemoteAddress: metadata.RemoteAddress( |
| 65 | net.TCPAddr{ |
| 66 | IP: net.ParseIP("127.0.0.1"), |
| 67 | Port: port, |
| 68 | }, |
| 69 | ), |
| 70 | ConnectionID: connectionID, |
| 71 | Metadata: map[string]metadata.Value{}, |
| 72 | Environment: map[string]metadata.Value{}, |
| 73 | Files: map[string]metadata.BinaryValue{}, |
| 74 | }, |
| 75 | ClientVersion: "", |
| 76 | Username: "foo", |
| 77 | }, |
| 78 | AuthenticatedUsername: "foo", |
| 79 | }, |
| 80 | ) |
nothing calls this directly
no test coverage detected