@@ -27,38 +27,30 @@ describe("ProfileValidator", () => {
2727 [ "requesty" , { requestyModelId : "model" } ] ,
2828 [ "unbound" , { unboundModelId : "model" } ] ,
2929 ] ) ( "resolves %s model fields through canonical identifiers" , ( identifierKey , profileSettings ) => {
30- const identifiers = providerIdentifiers as Record < string , string >
31- const originalIdentifier = identifiers [ identifierKey ]
32- const canonicalIdentifier = `canonical-${ identifierKey } `
30+ const canonicalIdentifier = providerIdentifiers [ identifierKey as keyof typeof providerIdentifiers ]
3331 const modelId = "model"
3432
35- try {
36- identifiers [ identifierKey ] = canonicalIdentifier
37-
38- const profile = {
39- apiProvider : canonicalIdentifier ,
40- ...profileSettings ,
41- } as ProviderSettings
42- const allowList : OrganizationAllowList = {
43- allowAll : false ,
44- providers : {
45- [ canonicalIdentifier ] : { allowAll : false , models : [ modelId ] } ,
46- } ,
47- }
48-
49- expect ( ProfileValidator . isProfileAllowed ( profile , allowList ) ) . toBe ( true )
33+ const profile = {
34+ apiProvider : canonicalIdentifier ,
35+ ...profileSettings ,
36+ } as ProviderSettings
37+ const allowList : OrganizationAllowList = {
38+ allowAll : false ,
39+ providers : {
40+ [ canonicalIdentifier ] : { allowAll : false , models : [ modelId ] } ,
41+ } ,
42+ }
5043
51- const negativeAllowList : OrganizationAllowList = {
52- allowAll : false ,
53- providers : {
54- [ canonicalIdentifier ] : { allowAll : false , models : [ "other-model" ] } ,
55- } ,
56- }
44+ expect ( ProfileValidator . isProfileAllowed ( profile , allowList ) ) . toBe ( true )
5745
58- expect ( ProfileValidator . isProfileAllowed ( profile , negativeAllowList ) ) . toBe ( false )
59- } finally {
60- identifiers [ identifierKey ] = originalIdentifier
46+ const negativeAllowList : OrganizationAllowList = {
47+ allowAll : false ,
48+ providers : {
49+ [ canonicalIdentifier ] : { allowAll : false , models : [ "other-model" ] } ,
50+ } ,
6151 }
52+
53+ expect ( ProfileValidator . isProfileAllowed ( profile , negativeAllowList ) ) . toBe ( false )
6254 } )
6355
6456 it . each ( [
0 commit comments