TestNativeStructSkippedEmbeddedField verifies that a skipped struct cannot be reached through its promoted fields. CEL visibility is governed by the configured tag and JSON serialization by the `json` tag; each applies the same rule, so a field hidden from CEL by `cel:"-"` is still serialized unless
(t *testing.T)
| 1228 | // the `json` tag; each applies the same rule, so a field hidden from CEL by `cel:"-"` is still |
| 1229 | // serialized unless it also carries `json:"-"`. |
| 1230 | func TestNativeStructSkippedEmbeddedField(t *testing.T) { |
| 1231 | creds := SkipCreds{APIKey: "sk-SKIP"} |
| 1232 | tests := []struct { |
| 1233 | name string |
| 1234 | tag string |
| 1235 | typ reflect.Type |
| 1236 | in any |
| 1237 | hidden []string |
| 1238 | visible map[string]any |
| 1239 | json map[string]any |
| 1240 | }{ |
| 1241 | { |
| 1242 | name: "cel embedded", |
| 1243 | tag: "cel", |
| 1244 | typ: reflect.TypeFor[SkipEmbeddedCEL](), |
| 1245 | in: SkipEmbeddedCEL{SkipCreds: creds, SkipPublic: SkipPublic{Label: "pub"}, Path: "/v1"}, |
| 1246 | hidden: []string{"SkipCreds", "APIKey"}, |
| 1247 | visible: map[string]any{"path": "/v1", "Label": "pub"}, |
| 1248 | json: map[string]any{"path": "/v1", "Label": "pub", "APIKey": "sk-SKIP"}, |
| 1249 | }, |
| 1250 | { |
| 1251 | name: "cel embedded pointer", |
| 1252 | tag: "cel", |
| 1253 | typ: reflect.TypeFor[SkipEmbeddedPtrCEL](), |
| 1254 | in: SkipEmbeddedPtrCEL{SkipCreds: &creds, Path: "/v1"}, |
| 1255 | hidden: []string{"SkipCreds", "APIKey"}, |
| 1256 | visible: map[string]any{"path": "/v1"}, |
| 1257 | json: map[string]any{"path": "/v1", "APIKey": "sk-SKIP"}, |
| 1258 | }, |
| 1259 | { |
| 1260 | name: "cel non-embedded", |
| 1261 | tag: "cel", |
| 1262 | typ: reflect.TypeFor[SkipFieldCEL](), |
| 1263 | in: SkipFieldCEL{Creds: creds, Path: "/v1"}, |
| 1264 | hidden: []string{"Creds", "APIKey"}, |
| 1265 | visible: map[string]any{"path": "/v1"}, |
| 1266 | json: map[string]any{"path": "/v1", "Creds": map[string]any{"APIKey": "sk-SKIP"}}, |
| 1267 | }, |
| 1268 | { |
| 1269 | name: "cel nested embedded", |
| 1270 | tag: "cel", |
| 1271 | typ: reflect.TypeFor[SkipNestedCEL](), |
| 1272 | in: SkipNestedCEL{SkipDeepCreds: SkipDeepCreds{SkipCreds: creds, Token: "tok"}, Path: "/v1"}, |
| 1273 | hidden: []string{"SkipDeepCreds", "SkipCreds", "APIKey", "Token"}, |
| 1274 | visible: map[string]any{"path": "/v1"}, |
| 1275 | json: map[string]any{"path": "/v1", "APIKey": "sk-SKIP", "Token": "tok"}, |
| 1276 | }, |
| 1277 | { |
| 1278 | name: "cel and json embedded", |
| 1279 | tag: "cel", |
| 1280 | typ: reflect.TypeFor[SkipEmbeddedBoth](), |
| 1281 | in: SkipEmbeddedBoth{SkipCreds: creds, Path: "/v1"}, |
| 1282 | hidden: []string{"SkipCreds", "APIKey"}, |
| 1283 | visible: map[string]any{"path": "/v1"}, |
| 1284 | json: map[string]any{"path": "/v1"}, |
| 1285 | }, |
| 1286 | { |
| 1287 | name: "json embedded", |
nothing calls this directly
no test coverage detected