@@ -1733,7 +1733,7 @@ types:
17331733 policyContext : policyContext ( ) ,
17341734 } ) ;
17351735
1736- expect ( response ) . toEqual ( {
1736+ const expectedResult = {
17371737 path : {
17381738 "rebac.check" : {
17391739 allowed : false ,
@@ -1745,7 +1745,102 @@ types:
17451745 "todoApp.PUT.todos.__id" : { allowed : false } ,
17461746 } ,
17471747 pathRoot : "" ,
1748+ } ;
1749+
1750+ expect ( response ) . toEqual ( expectedResult ) ;
1751+ expect ( JSON . parse ( JSON . stringify ( response ) ) ) . toEqual ( expectedResult ) ;
1752+ } ) ;
1753+ } ) ;
1754+
1755+ describe ( "Is" , ( ) => {
1756+ it ( "returns the correct data structure" , async ( ) => {
1757+ const response = await authorizerClient . Is ( {
1758+ identityContext : await AnonymousIdentityMapper ( ) ,
1759+ policyInstance : policyInstance ( "todo" , "todo" ) ,
1760+ policyContext : policyContext ( "todoApp.GET.todos" ) ,
1761+ } ) ;
1762+
1763+ const expectedResult = true ;
1764+
1765+ expect ( response ) . toEqual ( expectedResult ) ;
1766+ expect ( JSON . parse ( JSON . stringify ( response ) ) ) . toEqual ( expectedResult ) ;
1767+ } ) ;
1768+ } ) ;
1769+
1770+ describe ( "Query" , ( ) => {
1771+ it ( "returns the correct data structure" , async ( ) => {
1772+ const response = await authorizerClient . Query ( {
1773+ query : "x=data" ,
1774+ input : '{"foo": "bar"}' ,
1775+ } ) ;
1776+
1777+ const expectedResult = {
1778+ result : [
1779+ {
1780+ bindings : {
1781+ x : {
1782+ rebac : { check : { allowed : false } } ,
1783+ todoApp : {
1784+ DELETE : { todos : { __id : { allowed : false } } } ,
1785+ GET : {
1786+ todos : { allowed : true } ,
1787+ users : { __userID : { allowed : true } } ,
1788+ } ,
1789+ POST : { todos : { allowed : false } } ,
1790+ PUT : { todos : { __id : { allowed : false } } } ,
1791+ common : { } ,
1792+ } ,
1793+ } ,
1794+ } ,
1795+ expressions : [
1796+ { location : { col : 1 , row : 1 } , text : "x=data" , value : true } ,
1797+ ] ,
1798+ } ,
1799+ ] ,
1800+ } ;
1801+
1802+ expect ( response ) . toEqual ( expectedResult ) ;
1803+ expect ( JSON . parse ( JSON . stringify ( response ) ) ) . toEqual ( expectedResult ) ;
1804+ } ) ;
1805+ } ) ;
1806+
1807+ describe ( "ListPolicies" , ( ) => {
1808+ it ( "returns the correct data structure" , async ( ) => {
1809+ const response = await authorizerClient . ListPolicies ( {
1810+ policyInstance : {
1811+ name : "todo" ,
1812+ } ,
1813+ fieldMask : {
1814+ paths : [ "id" ] ,
1815+ } ,
17481816 } ) ;
1817+
1818+ const expectedResult = [
1819+ {
1820+ id : "todo/github/workspace/content/src/policies/todoApp.DELETE.todos.__id.rego" ,
1821+ } ,
1822+ {
1823+ id : "todo/github/workspace/content/src/policies/todoApp.GET.todos.rego" ,
1824+ } ,
1825+ {
1826+ id : "todo/github/workspace/content/src/policies/todoApp.GET.users.__userID.rego" ,
1827+ } ,
1828+ {
1829+ id : "todo/github/workspace/content/src/policies/todoApp.POST.todos.rego" ,
1830+ } ,
1831+ {
1832+ id : "todo/github/workspace/content/src/policies/todoApp.PUT.todos.__id.rego" ,
1833+ } ,
1834+ {
1835+ id : "todo/github/workspace/content/src/policies/todoApp.common.rego" ,
1836+ } ,
1837+ { id : "todo/github/workspace/content/src/policies/rebac.check.rego" } ,
1838+ ] ;
1839+
1840+ expect ( response ) . toEqual ( expect . arrayContaining ( expectedResult ) ) ;
1841+ expect ( JSON . parse ( JSON . stringify ( response ) ) ) . toEqual (
1842+ expect . arrayContaining ( expectedResult ) ,
1843+ ) ;
17491844 } ) ;
17501845 } ) ;
17511846 } ) ;
0 commit comments