@@ -18,6 +18,30 @@ describe("getDefaultRoleFromConfig", () => {
1818 disabledTools : [ ] ,
1919 } ;
2020
21+ const readWriteConfigWithDeleteDisabled : UserConfig = {
22+ ...defaultConfig ,
23+ readOnly : false ,
24+ disabledTools : [ "delete" ] ,
25+ } ;
26+
27+ const readWriteConfigWithCreateDisabled : UserConfig = {
28+ ...defaultConfig ,
29+ readOnly : false ,
30+ disabledTools : [ "create" ] ,
31+ } ;
32+
33+ const readWriteConfigWithUpdateDisabled : UserConfig = {
34+ ...defaultConfig ,
35+ readOnly : false ,
36+ disabledTools : [ "update" ] ,
37+ } ;
38+
39+ const readWriteConfigWithAllToolsDisabled : UserConfig = {
40+ ...defaultConfig ,
41+ readOnly : false ,
42+ disabledTools : [ "create" , "update" , "delete" ] ,
43+ } ;
44+
2145 it ( "should return the correct role for a read-only config" , ( ) => {
2246 const role = getDefaultRoleFromConfig ( readOnlyConfig ) ;
2347 expect ( role ) . toEqual ( {
@@ -42,14 +66,35 @@ describe("getDefaultRoleFromConfig", () => {
4266 } ) ;
4367 } ) ;
4468
45- for ( const tool of [ "create" , "update" , "delete" , "metadata" ] ) {
46- it ( `should return the correct role for a config with ${ tool } disabled` , ( ) => {
47- const config = { ...defaultConfig , disabledTools : [ tool ] } ;
48- const role = getDefaultRoleFromConfig ( config ) ;
49- expect ( role ) . toEqual ( {
50- roleName : "readAnyDatabase" ,
51- databaseName : "admin" ,
52- } ) ;
69+ it ( "should return the correct role for a read-write config with delete disabled" , ( ) => {
70+ const role = getDefaultRoleFromConfig ( readWriteConfigWithDeleteDisabled ) ;
71+ expect ( role ) . toEqual ( {
72+ roleName : "readWriteAnyDatabase" ,
73+ databaseName : "admin" ,
74+ } ) ;
75+ } ) ;
76+
77+ it ( "should return the correct role for a read-write config with create disabled" , ( ) => {
78+ const role = getDefaultRoleFromConfig ( readWriteConfigWithCreateDisabled ) ;
79+ expect ( role ) . toEqual ( {
80+ roleName : "readWriteAnyDatabase" ,
81+ databaseName : "admin" ,
5382 } ) ;
54- }
83+ } ) ;
84+
85+ it ( "should return the correct role for a read-write config with update disabled" , ( ) => {
86+ const role = getDefaultRoleFromConfig ( readWriteConfigWithUpdateDisabled ) ;
87+ expect ( role ) . toEqual ( {
88+ roleName : "readAnyDatabase" ,
89+ databaseName : "admin" ,
90+ } ) ;
91+ } ) ;
92+
93+ it ( "should return the correct role for a read-write config with all tools disabled" , ( ) => {
94+ const role = getDefaultRoleFromConfig ( readWriteConfigWithAllToolsDisabled ) ;
95+ expect ( role ) . toEqual ( {
96+ roleName : "readAnyDatabase" ,
97+ databaseName : "admin" ,
98+ } ) ;
99+ } ) ;
55100} ) ;
0 commit comments