@@ -1756,3 +1756,75 @@ describe.skip('RP and OP interaction should', () => {
17561756 expect ( resState ?. status ) . toBe ( 'error' )
17571757 } )
17581758} )
1759+
1760+
1761+ describe ( 'credential_sets tests' , ( ) => {
1762+ it ( 'DCQL credential_sets: happy flow (single required option is satisfied)' , ( ) => {
1763+ const queryWithSet : DcqlQuery . Input = {
1764+ credentials : [
1765+ {
1766+ id : 'credA' ,
1767+ format : 'ldp_vc' ,
1768+ meta : {
1769+ type_values : [
1770+ [ 'https://www.w3.org/2018/credentials#VerifiableCredential' ] ,
1771+ [ 'PermanentResidentCard' ]
1772+ ]
1773+ } ,
1774+ claims : [ { path : [ 'givenName' ] , values : [ 'JANE' ] } ]
1775+ }
1776+ ] ,
1777+ credential_sets : [
1778+ {
1779+ options : [ [ 'credA' ] ] ,
1780+ required : true ,
1781+ purpose : 'must include credA'
1782+ }
1783+ ]
1784+ }
1785+
1786+ const parsed = DcqlQuery . parse ( queryWithSet )
1787+ DcqlQuery . validate ( parsed ) // validates structure + credential_sets references
1788+
1789+ const dcqlCredential : DcqlW3cVcCredential = {
1790+ credential_format : 'ldp_vc' ,
1791+ claims : ( getVCs ( ) [ 0 ] . credentialSubject as { [ x : string ] : Json } ) ,
1792+ type : getVCs ( ) [ 0 ] . type ,
1793+ cryptographic_holder_binding : true
1794+ }
1795+
1796+ const result : DcqlQueryResult = DcqlQuery . query ( parsed , [ dcqlCredential ] )
1797+
1798+ // set is satisfied and matching_options should include ['credA']
1799+ expect ( result . can_be_satisfied ) . toBe ( true )
1800+ expect ( result . credential_sets ?. [ 0 ] . matching_options ) . toEqual ( [ [ 'credA' ] ] )
1801+ } )
1802+
1803+ it ( 'DCQL credential_sets: invalid rule (references unknown credential id) fails validation' , ( ) => {
1804+ const queryWithBadSet : DcqlQuery . Input = {
1805+ credentials : [
1806+ {
1807+ id : 'credA' ,
1808+ format : 'ldp_vc' ,
1809+ meta : {
1810+ type_values : [
1811+ [ 'https://www.w3.org/2018/credentials#VerifiableCredential' ] ,
1812+ [ 'PermanentResidentCard' ]
1813+ ]
1814+ } ,
1815+ claims : [ { path : [ 'givenName' ] , values : [ 'JANE' ] } ]
1816+ }
1817+ ] ,
1818+ credential_sets : [
1819+ {
1820+ // This option references a non-existent credential query id
1821+ options : [ [ 'does_not_exist' ] ] ,
1822+ required : true
1823+ }
1824+ ]
1825+ }
1826+
1827+ const parsed = DcqlQuery . parse ( queryWithBadSet )
1828+ expect ( ( ) => DcqlQuery . validate ( parsed ) ) . toThrowError ( / C r e d e n t i a l s e t c o n t a i n s u n d e f i n e d c r e d e n t i a l i d / i)
1829+ } )
1830+ } )
0 commit comments