|
| 1 | +Helper.readK8sResources("k8s_resources/kafka_acl_filter") |
| 2 | + |
| 3 | +local team = Team.new("devteam", "purpose", "#slack-channel") |
| 4 | +local user = User.new() |
| 5 | + |
| 6 | +Test.gql("topic without filter", function(t) |
| 7 | + t.addHeader("x-user-email", user:email()) |
| 8 | + |
| 9 | + t.query([[ |
| 10 | + { |
| 11 | + team(slug: "devteam") { |
| 12 | + environment(name: "dev") { |
| 13 | + kafkaTopic(name: "dokument") { |
| 14 | + acl { |
| 15 | + nodes { |
| 16 | + workloadName |
| 17 | + teamName |
| 18 | + access |
| 19 | + } |
| 20 | + } |
| 21 | + } |
| 22 | + } |
| 23 | + } |
| 24 | + } |
| 25 | + ]]) |
| 26 | + |
| 27 | + t.check { |
| 28 | + data = { |
| 29 | + team = { |
| 30 | + environment = { |
| 31 | + kafkaTopic = { |
| 32 | + acl = { |
| 33 | + nodes = { |
| 34 | + { workloadName = "*", teamName = "devteam", access = "read" }, |
| 35 | + { workloadName = "all", teamName = "*", access = "readwrite" }, |
| 36 | + { workloadName = "app1", teamName = "devteam", access = "readwrite" }, |
| 37 | + { workloadName = "app2", teamName = "otherteam", access = "readwrite" }, |
| 38 | + { workloadName = "jobname-1", teamName = "otherteam", access = "readwrite" }, |
| 39 | + { workloadName = "missing", teamName = "devteam", access = "readwrite" }, |
| 40 | + { workloadName = "missing", teamName = "otherteam", access = "readwrite" }, |
| 41 | + }, |
| 42 | + }, |
| 43 | + }, |
| 44 | + }, |
| 45 | + }, |
| 46 | + }, |
| 47 | + } |
| 48 | +end) |
| 49 | + |
| 50 | +Test.gql("topic filtering for workload", function(t) |
| 51 | + t.addHeader("x-user-email", user:email()) |
| 52 | + |
| 53 | + t.query([[ |
| 54 | + { |
| 55 | + team(slug: "devteam") { |
| 56 | + environment(name: "dev") { |
| 57 | + kafkaTopic(name: "dokument") { |
| 58 | + acl(filter: { workload: "app1" }) { |
| 59 | + nodes { |
| 60 | + workloadName |
| 61 | + teamName |
| 62 | + access |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | + ]]) |
| 70 | + |
| 71 | + t.check { |
| 72 | + data = { |
| 73 | + team = { |
| 74 | + environment = { |
| 75 | + kafkaTopic = { |
| 76 | + acl = { |
| 77 | + nodes = { |
| 78 | + { workloadName = "*", teamName = "devteam", access = "read" }, |
| 79 | + { workloadName = "app1", teamName = "devteam", access = "readwrite" }, |
| 80 | + }, |
| 81 | + }, |
| 82 | + }, |
| 83 | + }, |
| 84 | + }, |
| 85 | + }, |
| 86 | + } |
| 87 | +end) |
| 88 | + |
| 89 | +Test.gql("topic filtering for team", function(t) |
| 90 | + t.addHeader("x-user-email", user:email()) |
| 91 | + |
| 92 | + t.query([[ |
| 93 | + { |
| 94 | + team(slug: "devteam") { |
| 95 | + environment(name: "dev") { |
| 96 | + kafkaTopic(name: "dokument") { |
| 97 | + acl(filter: { team: "otherteam" }) { |
| 98 | + nodes { |
| 99 | + workloadName |
| 100 | + teamName |
| 101 | + access |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + ]]) |
| 109 | + |
| 110 | + t.check { |
| 111 | + data = { |
| 112 | + team = { |
| 113 | + environment = { |
| 114 | + kafkaTopic = { |
| 115 | + acl = { |
| 116 | + nodes = { |
| 117 | + { workloadName = "all", teamName = "*", access = "readwrite" }, |
| 118 | + { workloadName = "app2", teamName = "otherteam", access = "readwrite" }, |
| 119 | + { workloadName = "jobname-1", teamName = "otherteam", access = "readwrite" }, |
| 120 | + { workloadName = "missing", teamName = "otherteam", access = "readwrite" }, |
| 121 | + }, |
| 122 | + }, |
| 123 | + }, |
| 124 | + }, |
| 125 | + }, |
| 126 | + }, |
| 127 | + } |
| 128 | +end) |
| 129 | + |
| 130 | +Test.gql("topic filtering for valid workloads", function(t) |
| 131 | + t.addHeader("x-user-email", user:email()) |
| 132 | + |
| 133 | + t.query([[ |
| 134 | + { |
| 135 | + team(slug: "devteam") { |
| 136 | + environment(name: "dev") { |
| 137 | + kafkaTopic(name: "dokument") { |
| 138 | + acl(filter: { validWorkloads: true }) { |
| 139 | + nodes { |
| 140 | + workloadName |
| 141 | + teamName |
| 142 | + access |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | + } |
| 147 | + } |
| 148 | + } |
| 149 | + ]]) |
| 150 | + |
| 151 | + t.check { |
| 152 | + data = { |
| 153 | + team = { |
| 154 | + environment = { |
| 155 | + kafkaTopic = { |
| 156 | + acl = { |
| 157 | + nodes = { |
| 158 | + { workloadName = "*", teamName = "devteam", access = "read" }, |
| 159 | + { workloadName = "all", teamName = "*", access = "readwrite" }, |
| 160 | + { workloadName = "app1", teamName = "devteam", access = "readwrite" }, |
| 161 | + { workloadName = "app2", teamName = "otherteam", access = "readwrite" }, |
| 162 | + { workloadName = "jobname-1", teamName = "otherteam", access = "readwrite" }, |
| 163 | + }, |
| 164 | + }, |
| 165 | + }, |
| 166 | + }, |
| 167 | + }, |
| 168 | + }, |
| 169 | + } |
| 170 | +end) |
| 171 | + |
| 172 | +Test.gql("topic filtering for invalid workloads", function(t) |
| 173 | + t.addHeader("x-user-email", user:email()) |
| 174 | + |
| 175 | + t.query([[ |
| 176 | + { |
| 177 | + team(slug: "devteam") { |
| 178 | + environment(name: "dev") { |
| 179 | + kafkaTopic(name: "dokument") { |
| 180 | + acl(filter: { validWorkloads: false }) { |
| 181 | + nodes { |
| 182 | + workloadName |
| 183 | + teamName |
| 184 | + access |
| 185 | + } |
| 186 | + } |
| 187 | + } |
| 188 | + } |
| 189 | + } |
| 190 | + } |
| 191 | + ]]) |
| 192 | + |
| 193 | + t.check { |
| 194 | + data = { |
| 195 | + team = { |
| 196 | + environment = { |
| 197 | + kafkaTopic = { |
| 198 | + acl = { |
| 199 | + nodes = { |
| 200 | + { workloadName = "missing", teamName = "devteam", access = "readwrite" }, |
| 201 | + { workloadName = "missing", teamName = "otherteam", access = "readwrite" }, |
| 202 | + }, |
| 203 | + }, |
| 204 | + }, |
| 205 | + }, |
| 206 | + }, |
| 207 | + }, |
| 208 | + } |
| 209 | +end) |
0 commit comments