|
| 1 | +// Copyright 2024 Redpanda Data, Inc. |
| 2 | +// |
| 3 | +// Licensed as a Redpanda Enterprise file under the Redpanda Community |
| 4 | +// License (the "License"); you may not use this file except in compliance with |
| 5 | +// the License. You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// https://github.com/redpanda-data/connect/blob/main/licenses/rcl.md |
| 8 | + |
| 9 | +package schema_test |
| 10 | + |
| 11 | +import ( |
| 12 | + // Only import a subset of components for execution. |
| 13 | + "strings" |
| 14 | + "testing" |
| 15 | + |
| 16 | + "github.com/redpanda-data/benthos/v4/public/service" |
| 17 | + "github.com/stretchr/testify/assert" |
| 18 | + |
| 19 | + _ "embed" |
| 20 | + |
| 21 | + _ "github.com/redpanda-data/connect/v4/public/components/cloud" |
| 22 | +) |
| 23 | + |
| 24 | +//go:embed cloud_allow_list.txt |
| 25 | +var allowList string |
| 26 | + |
| 27 | +func TestImportsMatch(t *testing.T) { |
| 28 | + t.Skip("Skipping until we have a structured allow list") |
| 29 | + |
| 30 | + var allowSlice []string |
| 31 | + for _, s := range strings.Split(allowList, "\n") { |
| 32 | + s = strings.TrimSpace(s) |
| 33 | + if s == "" || strings.HasPrefix(s, "#") { |
| 34 | + continue |
| 35 | + } |
| 36 | + allowSlice = append(allowSlice, s) |
| 37 | + } |
| 38 | + |
| 39 | + env := service.GlobalEnvironment() |
| 40 | + |
| 41 | + seen := map[string]struct{}{} |
| 42 | + |
| 43 | + env.WalkBuffers(func(name string, config *service.ConfigView) { |
| 44 | + seen[name] = struct{}{} |
| 45 | + }) |
| 46 | + |
| 47 | + env.WalkCaches(func(name string, config *service.ConfigView) { |
| 48 | + seen[name] = struct{}{} |
| 49 | + }) |
| 50 | + |
| 51 | + env.WalkInputs(func(name string, config *service.ConfigView) { |
| 52 | + seen[name] = struct{}{} |
| 53 | + }) |
| 54 | + |
| 55 | + env.WalkMetrics(func(name string, config *service.ConfigView) { |
| 56 | + seen[name] = struct{}{} |
| 57 | + }) |
| 58 | + |
| 59 | + env.WalkOutputs(func(name string, config *service.ConfigView) { |
| 60 | + seen[name] = struct{}{} |
| 61 | + }) |
| 62 | + |
| 63 | + env.WalkProcessors(func(name string, config *service.ConfigView) { |
| 64 | + seen[name] = struct{}{} |
| 65 | + }) |
| 66 | + |
| 67 | + env.WalkRateLimits(func(name string, config *service.ConfigView) { |
| 68 | + seen[name] = struct{}{} |
| 69 | + }) |
| 70 | + |
| 71 | + env.WalkScanners(func(name string, config *service.ConfigView) { |
| 72 | + seen[name] = struct{}{} |
| 73 | + }) |
| 74 | + |
| 75 | + env.WalkTracers(func(name string, config *service.ConfigView) { |
| 76 | + seen[name] = struct{}{} |
| 77 | + }) |
| 78 | + |
| 79 | + for _, k := range allowSlice { |
| 80 | + assert.Contains(t, seen, k) |
| 81 | + } |
| 82 | +} |
0 commit comments