@@ -9,14 +9,14 @@ const record = {
99 outcome : "success" ,
1010 actor : { membershipId : "22222222-2222-4222-8222-222222222222" } ,
1111 context : {
12- provider : "github " ,
12+ provider : "corp.auth.v2 " ,
1313 revision : 3 ,
1414 providerKeys : [ "github" , "entra" ] ,
1515 } ,
1616}
1717
1818describe ( "securityAuditResponseSchema" , ( ) => {
19- it ( "accepts provider-neutral UUID records and a nullable opaque cursor" , ( ) => {
19+ it ( "accepts provider-neutral UUID records, a dotted provider, and a nullable opaque cursor" , ( ) => {
2020 expect (
2121 securityAuditResponseSchema . parse ( {
2222 records : [ record ] ,
@@ -32,7 +32,7 @@ describe("securityAuditResponseSchema", () => {
3232 [ "a nested object" , { metadata : { provider : "github" } } ] ,
3333 [ "a non-integer number" , { revision : 1.5 } ] ,
3434 [ "a mixed array" , { providerKeys : [ "github" , 2 ] } ] ,
35- [ "a secret-bearing field" , { accessToken : "github_pat_1234567890abcdef " } ] ,
35+ [ "a secret-bearing field" , { accessToken : "public-provider-label " } ] ,
3636 [ "credential-shaped text" , { reason : "Bearer private-credential-value" } ] ,
3737 ] ) ( "rejects context containing %s" , ( _label , context ) => {
3838 expect (
@@ -43,20 +43,21 @@ describe("securityAuditResponseSchema", () => {
4343 ) . toBe ( false )
4444 } )
4545
46- it ( "rejects malformed record identity, time, actor, outcome, and cursor values" , ( ) => {
47- expect (
48- securityAuditResponseSchema . safeParse ( {
49- records : [
50- {
51- ...record ,
52- id : "12" ,
53- occurredAt : "yesterday" ,
54- outcome : "unknown" ,
55- actor : { membershipId : 7 } ,
56- } ,
57- ] ,
58- nextCursor : "" ,
59- } ) . success ,
60- ) . toBe ( false )
61- } )
46+ it . each ( [
47+ [ "record identity" , { id : "12" } , null ] ,
48+ [ "record time" , { occurredAt : "yesterday" } , null ] ,
49+ [ "actor membership identity" , { actor : { membershipId : 7 } } , null ] ,
50+ [ "outcome" , { outcome : "unknown" } , null ] ,
51+ [ "cursor" , { } , "" ] ,
52+ ] as Array < [ string , Record < string , unknown > , string | null ] > ) (
53+ "rejects a malformed %s independently" ,
54+ ( _label , recordPatch , nextCursor ) => {
55+ expect (
56+ securityAuditResponseSchema . safeParse ( {
57+ records : [ { ...record , ...recordPatch } ] ,
58+ nextCursor,
59+ } ) . success ,
60+ ) . toBe ( false )
61+ } ,
62+ )
6263} )
0 commit comments