(t *testing.T)
| 178 | ) |
| 179 | |
| 180 | func TestServer(t *testing.T) { //nolint:gocyclo |
| 181 | t.Parallel() |
| 182 | tlsServer := httptest.NewTLSServer(http.HandlerFunc(http.NotFound)) |
| 183 | t.Cleanup(func() { |
| 184 | tlsServer.Close() |
| 185 | }) |
| 186 | tlsServerURL, _ := url.Parse(tlsServer.URL) |
| 187 | |
| 188 | cupsURI := (&url.URL{Scheme: "https", Host: tlsServerURL.Host}).String() |
| 189 | lnsURI := (&url.URL{Scheme: "wss", Host: tlsServerURL.Host}).String() |
| 190 | |
| 191 | var kv config.KeyVault //nolint:gosimple |
| 192 | |
| 193 | mockGateway := func(hasLNSSecret, redirectCUPS, updateCUPSCreds bool) *ttnpb.Gateway { |
| 194 | secret := &ttnpb.Secret{ |
| 195 | KeyId: "test-key", |
| 196 | Value: []byte("KEYCONTENTS"), |
| 197 | } |
| 198 | gtw := ttnpb.Gateway{ |
| 199 | Ids: &ttnpb.GatewayIdentifiers{ |
| 200 | GatewayId: "test-gateway", |
| 201 | Eui: mockGatewayEUI.Bytes(), |
| 202 | }, |
| 203 | Attributes: map[string]string{ |
| 204 | cupsStationAttribute: "2.0.0(minihub/debug) 2018-12-06 09:30:35", |
| 205 | cupsModelAttribute: "minihub", |
| 206 | cupsPackageAttribute: "2.0.0", |
| 207 | }, |
| 208 | GatewayServerAddress: lnsURI, |
| 209 | } |
| 210 | if hasLNSSecret { |
| 211 | gtw.LbsLnsSecret = secret |
| 212 | } |
| 213 | if redirectCUPS { |
| 214 | gtw.TargetCupsUri = cupsURI |
| 215 | gtw.TargetCupsKey = secret |
| 216 | } |
| 217 | if updateCUPSCreds { |
| 218 | gtw.TargetCupsKey = secret |
| 219 | } |
| 220 | return >w |
| 221 | } |
| 222 | |
| 223 | for _, tt := range []struct { |
| 224 | Name string |
| 225 | StoreSetup func(*mockGatewayClient) |
| 226 | Options []Option |
| 227 | RequestSetup func(*http.Request) |
| 228 | SetContext func(ctx context.Context) context.Context |
| 229 | AssertError func(error) bool |
| 230 | AssertStore func(*assertions.Assertion, *mockGatewayClient) |
| 231 | AssertResponse func(*assertions.Assertion, *httptest.ResponseRecorder) |
| 232 | }{ |
| 233 | { |
| 234 | Name: "No Auth", |
| 235 | StoreSetup: func(c *mockGatewayClient) { |
| 236 | c.res.Get = mockGateway(false, false, false) |
| 237 | c.res.GetIdentifiersForEUI = c.res.Get.GetIds() |
nothing calls this directly
no test coverage detected