Skip to content

Commit

Permalink
fix uid/gid bug
Browse files Browse the repository at this point in the history
Signed-off-by: Romy <35330373+romayalon@users.noreply.github.com>
  • Loading branch information
romayalon committed Feb 4, 2024
1 parent 3142e2b commit 42f88d7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cmd/manage_nsfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,10 @@ async function validate_account_args(data, action) {

if (is_undefined(data.access_keys[0].secret_key)) throw_cli_error(ManageCLIError.MissingAccountSecretKeyFlag);
if (is_undefined(data.access_keys[0].access_key)) throw_cli_error(ManageCLIError.MissingAccountAccessKeyFlag);
if (data.nsfs_account_config.gid && (is_undefined(data.nsfs_account_config.uid))) {
if (data.nsfs_account_config.gid && data.nsfs_account_config.uid === undefined) {
throw_cli_error(ManageCLIError.MissingAccountNSFSConfigUID, data.nsfs_account_config);
}
if (data.nsfs_account_config.uid && (is_undefined(data.nsfs_account_config.gid))) {
if (data.nsfs_account_config.uid && data.nsfs_account_config.gid === undefined) {
throw_cli_error(ManageCLIError.MissingAccountNSFSConfigGID, data.nsfs_account_config);
}
if ((is_undefined(data.nsfs_account_config.distinguished_name) &&
Expand Down
28 changes: 28 additions & 0 deletions src/test/unit_tests/test_nc_nsfs_cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const config_module = require('../../../config');
const { ManageCLIError } = require('../../manage_nsfs/manage_nsfs_cli_errors');
const { ManageCLIResponse } = require('../../manage_nsfs/manage_nsfs_cli_responses');
const { exec_manage_cli, generate_s3_policy, nc_nsfs_manage_actions, nc_nsfs_manage_entity_types } = require('../system_tests/test_utils');
const { ACTIONS } = require('../../manage_nsfs/manage_nsfs_constants');

const MAC_PLATFORM = 'darwin';
let tmp_fs_path = '/tmp/test_bucketspace_fs';
Expand Down Expand Up @@ -530,6 +531,33 @@ mocha.describe('manage_nsfs cli', function() {
}
});

mocha.it('cli account add - uid=0, gid!=0', async function() {
const action = ACTIONS.ADD;
const account_name = 'uid_is_0';
const options = { name: account_name, email: account_name, uid: 0, gid: 1001 };
const res = await exec_manage_cli(type, action, { config_root, ...options });
assert_response(action, type, res, options);
await exec_manage_cli(type, ACTIONS.DELETE, { config_root, name: account_name });
});

mocha.it('cli account add - uid=!0, gid=0', async function() {
const action = ACTIONS.ADD;
const account_name = 'gid_is_0';
const options = { name: account_name, email: account_name, uid: 1001, gid: 0 };
const res = await exec_manage_cli(type, action, { config_root, ...options });
assert_response(action, type, res, options);
await exec_manage_cli(type, ACTIONS.DELETE, { config_root, name: account_name });
});

mocha.it('cli account add - uid=0, gid=0', async function() {
const action = ACTIONS.ADD;
const account_name = 'uid_gid_are_0';
const options = { name: account_name, email: account_name, uid: 0, gid: 0 };
const res = await exec_manage_cli(type, ACTIONS.ADD, { config_root, ...options});
assert_response(action, type, res, options);
await exec_manage_cli(type, ACTIONS.DELETE, { config_root, name: account_name });
});

mocha.it('cli account create - no gid - should fail', async function() {
const action = nc_nsfs_manage_actions.ADD;
try {
Expand Down

0 comments on commit 42f88d7

Please sign in to comment.