@@ -103,6 +103,28 @@ describe('manage nsfs cli account flow', () => {
103
103
assert_account ( account_symlink , account_options ) ;
104
104
} ) ;
105
105
106
+ it ( 'should fail - cli create account invalid access_key(leading space in access_key)' , async ( ) => {
107
+ const { type, name, uid, gid, secret_key } = defaults ;
108
+ const account_options = { config_root, name, uid, gid, secret_key} ;
109
+ const action = ACTIONS . ADD ;
110
+ const command = create_command ( type , action , account_options )
111
+ const flag = 'access_key' ;
112
+ const value = ' 12345678912345678ABC' ; // leading space for access_key
113
+ const res = await exec_manage_cli_add_leading_space_option ( command , flag , value ) ;
114
+ expect ( JSON . parse ( res . stdout ) . error . message ) . toBe ( ManageCLIError . InvalidArgument . message ) ;
115
+ } ) ;
116
+
117
+ it ( 'should fail - cli create account invalid secret_key(leading space in secret_key)' , async ( ) => {
118
+ const { type, name, uid, gid, access_key } = defaults ;
119
+ const account_options = { config_root, name, uid, gid, access_key} ;
120
+ const action = ACTIONS . ADD ;
121
+ const command = create_command ( type , action , account_options )
122
+ const flag = 'secret_key' ;
123
+ const value = ' a234567891234567891212345678912345678912' ; // leading space for secret_key
124
+ const res = await exec_manage_cli_add_leading_space_option ( command , flag , value ) ;
125
+ expect ( JSON . parse ( res . stdout ) . error . message ) . toBe ( ManageCLIError . InvalidArgument . message ) ;
126
+ } ) ;
127
+
106
128
it ( 'should fail - cli update account invalid access_key - invalid size' , async ( ) => {
107
129
const { type, secret_key, name, new_buckets_path, uid, gid } = defaults ;
108
130
const account_options = { config_root, access_key : 'abc' , secret_key, name, new_buckets_path, uid, gid } ;
@@ -2210,6 +2232,23 @@ async function exec_manage_cli_add_empty_option(command, option) {
2210
2232
return res ;
2211
2233
}
2212
2234
2235
+ /**
2236
+ * exec_manage_cli_add_leading_space_option adds a flag with value having leading space
2237
+ * @param {string } command
2238
+ * @param {string } option
2239
+ * @param {string } value
2240
+ */
2241
+ async function exec_manage_cli_add_leading_space_option ( command , option , value ) {
2242
+ const changed_command = command + ` --${ option } = ${ value } ` ;
2243
+ let res ;
2244
+ try {
2245
+ res = await os_util . exec ( changed_command , { return_stdout : true } ) ;
2246
+ } catch ( e ) {
2247
+ res = e ;
2248
+ }
2249
+ return res ;
2250
+ }
2251
+
2213
2252
/**
2214
2253
* create_command would create the string needed to run the CLI command
2215
2254
* @param {string } type
0 commit comments