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