(t *testing.T)
| 246 | } |
| 247 | |
| 248 | func TestGRPC(t *testing.T) { |
| 249 | ctx := log.NewContext(test.Context(), test.GetLogger(t)) |
| 250 | is, isAddr, closeIS := mockis.New(ctx) |
| 251 | defer closeIS() |
| 252 | |
| 253 | testGtw := mockis.DefaultGateway(registeredGatewayID, false, false) |
| 254 | is.GatewayRegistry().Add(ctx, registeredGatewayID, "Bearer", registeredGatewayKey, testGtw, ttnpb.Right_RIGHT_GATEWAY_INFO) |
| 255 | |
| 256 | fpConf := config.FrequencyPlansConfig{ |
| 257 | ConfigSource: "static", |
| 258 | Static: test.StaticFrequencyPlans, |
| 259 | } |
| 260 | fps := frequencyplans.NewStore(test.Must(fpConf.Fetcher(ctx, config.BlobConfig{}, test.HTTPClientProvider)).(fetch.Interface)) |
| 261 | |
| 262 | conf := &component.Config{ |
| 263 | ServiceBase: config.ServiceBase{ |
| 264 | HTTP: config.HTTP{ |
| 265 | Listen: ":0", |
| 266 | }, |
| 267 | FrequencyPlans: fpConf, |
| 268 | Cluster: cluster.Config{ |
| 269 | IdentityServer: isAddr, |
| 270 | }, |
| 271 | }, |
| 272 | } |
| 273 | c := componenttest.NewComponent(t, conf) |
| 274 | c.AddContextFiller(func(ctx context.Context) context.Context { |
| 275 | ctx = newContextWithRightsFetcher(ctx) |
| 276 | return ctx |
| 277 | }) |
| 278 | |
| 279 | test.Must(New(c, testConfig)) |
| 280 | componenttest.StartComponent(t, c) |
| 281 | defer c.Close() |
| 282 | |
| 283 | mustHavePeer(ctx, c, ttnpb.ClusterRole_ENTITY_REGISTRY) |
| 284 | |
| 285 | mustHavePeer(ctx, c, ttnpb.ClusterRole_ENTITY_REGISTRY) |
| 286 | t.Run("Authorization", func(t *testing.T) { |
| 287 | a := assertions.New(t) |
| 288 | for _, tc := range []struct { |
| 289 | Name string |
| 290 | ID *ttnpb.GatewayIdentifiers |
| 291 | Key string |
| 292 | ErrAssertion func(error) bool |
| 293 | }{ |
| 294 | { |
| 295 | Name: "Valid", |
| 296 | ID: registeredGatewayID, |
| 297 | Key: registeredGatewayKey, |
| 298 | }, |
| 299 | { |
| 300 | Name: "InvalidKey", |
| 301 | ID: registeredGatewayID, |
| 302 | Key: "invalid key", |
| 303 | ErrAssertion: errors.IsPermissionDenied, |
| 304 | }, |
| 305 | { |
nothing calls this directly
no test coverage detected