Skip to content

Commit b5553f5

Browse files
migrate smoke_tests to aws sdk v3
ISSUE: ZENKO-5054
1 parent 085d550 commit b5553f5

File tree

2 files changed

+51
-40
lines changed

2 files changed

+51
-40
lines changed
Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
21
const async = require('async');
3-
42
const VaultClient = require('../../VaultClient');
53

64
const clientAdmin = VaultClient.getAdminClient();
@@ -13,16 +11,21 @@ const accountInfo = {
1311
let iamClient = null;
1412

1513
describe('Accounts: ', () => {
16-
it('should be able create, generate credentials and delete an account', done => async.series([
17-
next => clientAdmin.createAccount(accountName, accountInfo, next),
18-
next => clientAdmin.generateAccountAccessKey(accountName, (err, res) => {
19-
if (err) {
20-
return next(err);
21-
}
22-
23-
iamClient = VaultClient.getIamClient(res.id, res.value);
24-
return next(null);
25-
}),
26-
next => VaultClient.deleteVaultAccount(clientAdmin, iamClient, accountName, next),
27-
], done));
14+
it('should be able create, generate credentials and delete an account', done => {
15+
async.series([
16+
next => clientAdmin.createAccount(accountName, accountInfo, next),
17+
next => clientAdmin.generateAccountAccessKey(accountName, (err, res) => {
18+
if (err) {
19+
return next(err);
20+
}
21+
iamClient = VaultClient.getIamClient(res.id, res.value);
22+
return next(null);
23+
}),
24+
next => {
25+
VaultClient.deleteVaultAccount(clientAdmin, iamClient, accountName)
26+
.then(() => next())
27+
.catch(next);
28+
},
29+
], done);
30+
});
2831
});

tests/zenko_tests/node_tests/smoke_tests/vault_admin_and_IAM_API_tests/iamApi.js

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
const async = require('async');
2-
2+
const {
3+
CreateUserCommand,
4+
ListUsersCommand,
5+
GetUserCommand,
6+
UpdateUserCommand,
7+
DeleteUserCommand,
8+
CreateAccessKeyCommand,
9+
ListAccessKeysCommand,
10+
DeleteAccessKeyCommand,
11+
} = require('@aws-sdk/client-iam');
312
const VaultClient = require('../../VaultClient');
413

514
const clientAdmin = VaultClient.getAdminClient();
@@ -27,15 +36,17 @@ describe('IAM users: ', () => {
2736
return done();
2837
}));
2938

30-
afterEach(done => VaultClient.deleteVaultAccount(clientAdmin, iamAccountClient, accountName, done));
39+
afterEach(async () => {
40+
await VaultClient.deleteVaultAccount(clientAdmin, iamAccountClient, accountName);
41+
});
3142

32-
it('should be able to perform CRUD operations on a user', done => async.series([
33-
next => iamAccountClient.createUser({ UserName: userName }, next),
34-
next => iamAccountClient.listUsers({}, next),
35-
next => iamAccountClient.getUser({ UserName: userName }, next),
36-
next => iamAccountClient.updateUser({ UserName: userName, NewPath: randomPath }, next),
37-
next => iamAccountClient.deleteUser({ UserName: userName }, next),
38-
], done));
43+
it('should be able to perform CRUD operations on a user', async () => {
44+
await iamAccountClient.send(new CreateUserCommand({ UserName: userName }));
45+
await iamAccountClient.send(new ListUsersCommand({}));
46+
await iamAccountClient.send(new GetUserCommand({ UserName: userName }));
47+
await iamAccountClient.send(new UpdateUserCommand({ UserName: userName, NewPath: randomPath }));
48+
await iamAccountClient.send(new DeleteUserCommand({ UserName: userName }));
49+
});
3950
});
4051

4152
describe('IAM user - Access Keys: ', () => {
@@ -50,26 +61,23 @@ describe('IAM user - Access Keys: ', () => {
5061
return done(err);
5162
}
5263
iamAccountClient = VaultClient.getIamClient(externalAccessKey, externalSecretKey);
53-
return iamAccountClient.createUser({ UserName: userName }, done);
64+
return iamAccountClient.send(new CreateUserCommand({ UserName: userName }))
65+
.then(() => done())
66+
.catch(done);
5467
}));
5568

56-
afterEach(done => iamAccountClient.deleteUser(
57-
{ UserName: userName },
58-
() => VaultClient.deleteVaultAccount(clientAdmin, iamAccountClient, accountName, done),
59-
));
69+
afterEach(async () => {
70+
await iamAccountClient.send(new DeleteUserCommand({ UserName: userName }));
71+
await VaultClient.deleteVaultAccount(clientAdmin, iamAccountClient, accountName);
72+
});
6073

61-
it('should be able to create, list and delete user access keys', done => async.series([
62-
next => iamAccountClient.createAccessKey({ UserName: userName }, (err, result) => {
63-
if (err) {
64-
return next(err);
65-
}
66-
keyPair = result.AccessKey;
67-
return next();
68-
}),
69-
next => iamAccountClient.listAccessKeys({ UserName: userName }, next),
70-
next => iamAccountClient.deleteAccessKey({
74+
it('should be able to create, list and delete user access keys', async () => {
75+
const res = await iamAccountClient.send(new CreateAccessKeyCommand({ UserName: userName }));
76+
keyPair = res.AccessKey;
77+
await iamAccountClient.send(new ListAccessKeysCommand({ UserName: userName }));
78+
await iamAccountClient.send(new DeleteAccessKeyCommand({
7179
UserName: userName,
7280
AccessKeyId: keyPair.AccessKeyId,
73-
}, next),
74-
], done));
81+
}));
82+
});
7583
});

0 commit comments

Comments
 (0)