File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed
Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -536,4 +536,64 @@ describe.skip('Live Test', function () {
536536 await this . warrant . User . delete ( newUser . userId ) ;
537537 await this . warrant . Permission . delete ( newPermission . permissionId ) ;
538538 } ) ;
539+
540+ it ( 'warrant with policy' , async function ( ) {
541+ await this . warrant . Warrant . create ( {
542+ object : {
543+ objectType : "permission" ,
544+ objectId : "test-permission"
545+ } ,
546+ relation : "member" ,
547+ subject : {
548+ objectType : "user" ,
549+ objectId : "user-1"
550+ } ,
551+ policy : `geo == "us"`
552+ } ) ;
553+
554+ checkResult = await this . warrant . Authorization . check ( {
555+ object : {
556+ objectType : "permission" ,
557+ objectId : "test-permission"
558+ } ,
559+ relation : "member" ,
560+ subject : {
561+ objectType : "user" ,
562+ objectId : "user-1"
563+ } ,
564+ context : {
565+ "geo" : "us" ,
566+ }
567+ } ) ;
568+ assert . strictEqual ( checkResult , true ) ;
569+
570+ checkResult = await this . warrant . Authorization . check ( {
571+ object : {
572+ objectType : "permission" ,
573+ objectId : "test-permission"
574+ } ,
575+ relation : "member" ,
576+ subject : {
577+ objectType : "user" ,
578+ objectId : "user-1"
579+ } ,
580+ context : {
581+ "geo" : "eu" ,
582+ }
583+ } ) ;
584+ assert . strictEqual ( checkResult , false ) ;
585+
586+ await this . warrant . Warrant . delete ( {
587+ object : {
588+ objectType : "permission" ,
589+ objectId : "test-permission"
590+ } ,
591+ relation : "member" ,
592+ subject : {
593+ objectType : "user" ,
594+ objectId : "user-1"
595+ } ,
596+ policy : `geo == "us"`
597+ } ) ;
598+ } ) ;
539599} )
You can’t perform that action at this time.
0 commit comments