@@ -12,7 +12,7 @@ import Ajv, { Schema, ValidateFunction, SchemaValidateFunction } from "ajv";
12
12
import { Validator } from "./validate-rules" ;
13
13
14
14
export function isStringValue ( str : unknown ) {
15
- return typeof str == "string" ;
15
+ return typeof str == "string" || String ;
16
16
}
17
17
18
18
type Store = {
@@ -34,16 +34,20 @@ type Test = {
34
34
35
35
type CheckTest = Omit < CheckRequestTupleKey , "relation" > & {
36
36
assertions : Record < string , boolean > ;
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
38
context : Record < string , any > ;
38
39
} ;
39
40
40
41
type ListObjectTest = Omit < ListObjectsRequest , "relation" > & {
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
43
assertions : Record < string , any > ;
42
44
} ;
43
45
44
46
type ListUsersTest = Omit < ListUsersRequest , "relation" | "user_filters" > & {
45
47
object : string ;
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
46
49
user_filter : Record < string , any > ;
50
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
51
assertions : Record < string , any > ;
48
52
} ;
49
53
@@ -418,6 +422,7 @@ function validateUserField(model: AuthorizationModel, types: string[], userField
418
422
function validateAssertionField (
419
423
model : AuthorizationModel ,
420
424
typeField : string ,
425
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
421
426
assertions : Record < string , any > ,
422
427
instancePath : string ,
423
428
) {
@@ -649,7 +654,7 @@ function validateTestTypes(store: Store, model: AuthorizationModel, instancePath
649
654
650
655
// Validate check
651
656
if ( test . check ) {
652
- for ( const singleCheckTest of test . check ) {
657
+ for ( const [ testNumber , singleCheckTest ] of Object . entries ( test . check ) ) {
653
658
if ( ! singleCheckTest . user || ! singleCheckTest . object ) {
654
659
return false ;
655
660
}
@@ -659,15 +664,15 @@ function validateTestTypes(store: Store, model: AuthorizationModel, instancePath
659
664
singleCheckTest ,
660
665
tuples ,
661
666
params ,
662
- instancePath + `/tests/${ singleTest } /check/${ singleCheckTest } ` ,
667
+ instancePath + `/tests/${ singleTest } /check/${ testNumber } ` ,
663
668
) ,
664
669
) ;
665
670
}
666
671
}
667
672
668
673
// Validate list objects
669
674
if ( test . list_objects ) {
670
- for ( const singleListObjectTest of test . list_objects ) {
675
+ for ( const [ testNumber , singleListObjectTest ] of Object . entries ( test . list_objects ) ) {
671
676
if ( ! singleListObjectTest . user || ! singleListObjectTest . type ) {
672
677
return false ;
673
678
}
@@ -677,15 +682,15 @@ function validateTestTypes(store: Store, model: AuthorizationModel, instancePath
677
682
singleListObjectTest ,
678
683
tuples ,
679
684
params ,
680
- instancePath + `/tests/${ singleTest } /list_objects/${ singleListObjectTest } ` ,
685
+ instancePath + `/tests/${ singleTest } /list_objects/${ testNumber } ` ,
681
686
) ,
682
687
) ;
683
688
}
684
689
}
685
690
686
691
// Validate list users
687
692
if ( test . list_users ) {
688
- for ( const singleListUsersTest of test . list_users ) {
693
+ for ( const [ testNumber , singleListUsersTest ] of Object . entries ( test . list_users ) ) {
689
694
if ( ! singleListUsersTest . object || ! singleListUsersTest . user_filter ) {
690
695
return false ;
691
696
}
@@ -695,7 +700,7 @@ function validateTestTypes(store: Store, model: AuthorizationModel, instancePath
695
700
singleListUsersTest ,
696
701
tuples ,
697
702
params ,
698
- instancePath + `/tests/${ singleTest } /list_users/${ singleListUsersTest } ` ,
703
+ instancePath + `/tests/${ singleTest } /list_users/${ testNumber } ` ,
699
704
) ,
700
705
) ;
701
706
}
0 commit comments