(t *testing.T)
| 72 | } |
| 73 | |
| 74 | func TestWeb(t *testing.T) { |
| 75 | ctx := log.NewContext(test.Context(), test.GetLogger(t)) |
| 76 | |
| 77 | is, isAddr, closeIS := mockis.New(ctx) |
| 78 | defer closeIS() |
| 79 | |
| 80 | testGtw := mockis.DefaultGateway(registeredGatewayID, false, false) |
| 81 | is.GatewayRegistry().Add(ctx, registeredGatewayID, "Bearer", registeredGatewayKey, testGtw, ttnpb.Right_RIGHT_GATEWAY_INFO) |
| 82 | |
| 83 | fpConf := config.FrequencyPlansConfig{ |
| 84 | ConfigSource: "static", |
| 85 | Static: test.StaticFrequencyPlans, |
| 86 | } |
| 87 | fps := frequencyplans.NewStore(test.Must(fpConf.Fetcher(ctx, config.BlobConfig{}, test.HTTPClientProvider)).(fetch.Interface)) |
| 88 | |
| 89 | conf := &component.Config{ |
| 90 | ServiceBase: config.ServiceBase{ |
| 91 | HTTP: config.HTTP{ |
| 92 | Listen: ":0", |
| 93 | }, |
| 94 | FrequencyPlans: fpConf, |
| 95 | Cluster: cluster.Config{ |
| 96 | IdentityServer: isAddr, |
| 97 | }, |
| 98 | }, |
| 99 | } |
| 100 | c := componenttest.NewComponent(t, conf) |
| 101 | c.AddContextFiller(func(ctx context.Context) context.Context { |
| 102 | ctx = newContextWithRightsFetcher(ctx) |
| 103 | return ctx |
| 104 | }) |
| 105 | |
| 106 | test.Must(New(c, testConfig)) |
| 107 | componenttest.StartComponent(t, c) |
| 108 | defer c.Close() |
| 109 | |
| 110 | mustHavePeer(ctx, c, ttnpb.ClusterRole_ENTITY_REGISTRY) |
| 111 | |
| 112 | mustMarshal := func(b []byte, err error) []byte { return test.Must(b, err) } |
| 113 | marshalJSON := func(v any) string { |
| 114 | return string(mustMarshal(json.MarshalIndent(v, "", "\t"))) |
| 115 | } |
| 116 | marshalText := func(v encoding.TextMarshaler) string { |
| 117 | return string(mustMarshal(v.MarshalText())) |
| 118 | } |
| 119 | semtechUDPConfig := func(gtw *ttnpb.Gateway) string { |
| 120 | return marshalJSON(test.Must(semtechudp.Build(gtw, fps))) |
| 121 | } |
| 122 | cpfLoradConfig := func(gtw *ttnpb.Gateway) string { |
| 123 | return marshalJSON(test.Must(cpf.BuildLorad(gtw, fps))) |
| 124 | } |
| 125 | cpfLorafwdConfig := func(gtw *ttnpb.Gateway) string { |
| 126 | return marshalText(test.Must(cpf.BuildLorafwd(gtw))) |
| 127 | } |
| 128 | |
| 129 | t.Run("Authorization", func(t *testing.T) { |
| 130 | for _, tc := range []struct { |
| 131 | Name string |
nothing calls this directly
no test coverage detected