Skip to content

Commit 906ba38

Browse files
authored
Merge pull request #8278 from shirady/nsfs-nc-fix-cli-list
NC | NSFS | CLI | `list_config_files` Small Fix
2 parents 7d1e7e9 + 6268072 commit 906ba38

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/cmd/manage_nsfs.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ async function manage_bucket_operations(action, data, user_input) {
247247
} else if (action === ACTIONS.LIST) {
248248
const bucket_filters = _.pick(user_input, LIST_BUCKET_FILTERS);
249249
const wide = get_boolean_or_string_value(user_input.wide);
250-
const buckets = await list_config_files(TYPES.BUCKET, config_fs.buckets_dir_path, wide, undefined, bucket_filters);
250+
const buckets = await list_config_files(TYPES.BUCKET, wide, undefined, bucket_filters);
251251
write_stdout_response(ManageCLIResponse.BucketList, buckets);
252252
} else {
253253
// we should not get here (we check it before)
@@ -506,8 +506,7 @@ async function manage_account_operations(action, data, show_secrets, user_input)
506506
} else if (action === ACTIONS.LIST) {
507507
const account_filters = _.pick(user_input, LIST_ACCOUNT_FILTERS);
508508
const wide = get_boolean_or_string_value(user_input.wide);
509-
const accounts = await list_config_files(TYPES.ACCOUNT, config_fs.accounts_dir_path, wide,
510-
show_secrets, account_filters);
509+
const accounts = await list_config_files(TYPES.ACCOUNT, wide, show_secrets, account_filters);
511510
write_stdout_response(ManageCLIResponse.AccountList, accounts);
512511
} else {
513512
// we should not get here (we check it before)
@@ -567,12 +566,12 @@ function filter_bucket(bucket, filters) {
567566
}
568567
/**
569568
* list_config_files will list all the config files (json) in a given config directory
570-
* @param {string} config_path
569+
* @param {string} type
571570
* @param {boolean} [wide]
572571
* @param {boolean} [show_secrets]
573572
* @param {object} [filters]
574573
*/
575-
async function list_config_files(type, config_path, wide, show_secrets, filters) {
574+
async function list_config_files(type, wide, show_secrets, filters) {
576575
const entries = type === TYPES.ACCOUNT ?
577576
await config_fs.list_root_accounts() :
578577
await config_fs.list_buckets();
@@ -582,7 +581,7 @@ async function list_config_files(type, config_path, wide, show_secrets, filters)
582581
// decrypt only if data has access_keys and show_secrets = true (no need to decrypt if show_secrets = false but should_filter = true)
583582
const options = {
584583
show_secrets: show_secrets || should_filter,
585-
should_decrypt: show_secrets,
584+
decrypt_secret_key: show_secrets,
586585
silent_if_missing: true
587586
};
588587

src/test/unit_tests/jest_tests/test_nc_nsfs_account_cli.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,19 @@ describe('manage nsfs cli account flow', () => {
13161316
expect(JSON.parse(res.stdout).error.message).toBe(ManageCLIError.InvalidFlagsCombination.message);
13171317
});
13181318

1319+
it('cli list wide and show_secrets', async () => {
1320+
const account_options = { config_root, wide: true, show_secrets: true };
1321+
const action = ACTIONS.LIST;
1322+
const res = await exec_manage_cli(type, action, account_options);
1323+
expect(JSON.parse(res).response.reply.map(item => item.name))
1324+
.toEqual(expect.arrayContaining(['account3', 'account2', 'account1']));
1325+
const res_arr = JSON.parse(res).response.reply;
1326+
for (const item of res_arr) {
1327+
expect(item.access_keys[0].secret_key).toBeDefined();
1328+
expect(item.access_keys[0].encrypted_secret_key).toBeUndefined();
1329+
}
1330+
});
1331+
13191332
});
13201333

13211334
describe('cli delete account', () => {

0 commit comments

Comments
 (0)