Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
  • Loading branch information
shirady committed Jun 20, 2024
1 parent 5f4f6b2 commit 4e8c0c0
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/test/unit_tests/jest_tests/test_accountspace_fs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ describe('Accountspace_FS tests', () => {
const dummy_username3 = 'Alice';
const dummy_username4 = 'James';
const dummy_username5 = 'Oliver';
const dummy_username6 = 'Henry';
const dummy_user1 = {
username: dummy_username1,
path: dummy_path,
Expand Down Expand Up @@ -1154,6 +1155,40 @@ describe('Accountspace_FS tests', () => {
await fs_utils.file_must_not_exist(symlink_config_path);
});

it('delete_access_key should not return any param (account with 2 access keys)', async function() {
const username = dummy_username6;
const account_sdk = make_dummy_account_sdk();
// create the user
let params = {
username: username,
};
await accountspace_fs.create_user(params, account_sdk);
// create the access key (first time)
params = {
username: username,
};
// create the access key (second time)
const access_creation = await accountspace_fs.create_access_key(params, account_sdk);
const access_key_to_delete = access_creation.access_key;
// create the access key (second time)
const access_creation2 = await accountspace_fs.create_access_key(params, account_sdk);
const access_key = access_creation2.access_key;
params = {
username: username,
access_key: access_key_to_delete,
};
const res = await accountspace_fs.delete_access_key(params, account_sdk);
expect(res).toBeUndefined();
const user_account_config_file = await read_config_file(accountspace_fs.accounts_dir, username);
expect(user_account_config_file.access_keys.length).toBe(1);
expect(user_account_config_file.access_keys[0].access_key).toBe(access_key);
expect(user_account_config_file.access_keys[0].access_key).not.toBe(access_key_to_delete);
let symlink_config_path = path.join(accountspace_fs.access_keys_dir, access_key_to_delete + '.symlink');
await fs_utils.file_must_not_exist(symlink_config_path);
symlink_config_path = path.join(accountspace_fs.access_keys_dir, access_key + '.symlink');
await fs_utils.file_must_exist(symlink_config_path);
});

it('delete_access_key should not return any param (requester is an IAM user)', async function() {
let account_sdk = make_dummy_account_sdk();
let user_account_config_file = await read_config_file(accountspace_fs.accounts_dir, dummy_username5);
Expand All @@ -1167,6 +1202,7 @@ describe('Accountspace_FS tests', () => {
expect(res).toBeUndefined();
user_account_config_file = await read_config_file(accountspace_fs.accounts_dir, dummy_username1);
expect(user_account_config_file.access_keys.length).toBe(1);
expect(user_account_config_file.access_keys[0].access_key).not.toBe(access_key);
const symlink_config_path = path.join(accountspace_fs.access_keys_dir, access_key + '.symlink');
await fs_utils.file_must_not_exist(symlink_config_path);
});
Expand Down

0 comments on commit 4e8c0c0

Please sign in to comment.