-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAwsCredentials.test.js
45 lines (37 loc) · 1.15 KB
/
AwsCredentials.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const Test = require('thunk-test')
const assert = require('assert')
const fs = require('fs')
const AwsCredentials = require('./AwsCredentials')
const test = new Test('AwsCredentials', async function () {
try {
await fs.promises.mkdir(`${__dirname}/../.aws`)
} catch {
await fs.promises.rm(`${__dirname}/../.aws`, { recursive: true })
await fs.promises.mkdir(`${__dirname}/../.aws`)
}
await fs.promises.writeFile(`${__dirname}/../.aws/credentials`, `
[default]
aws_access_key_id = AAA
aws_secret_access_key = FFF
`.trim())
{
const awsCreds = await AwsCredentials('default')
assert.equal(awsCreds.accessKeyId, 'AAA')
assert.equal(awsCreds.secretAccessKey, 'FFF')
}
{
const awsCreds = await AwsCredentials({ profile: 'default' })
assert.equal(awsCreds.accessKeyId, 'AAA')
assert.equal(awsCreds.secretAccessKey, 'FFF')
}
{
const awsCreds = await AwsCredentials()
assert.equal(awsCreds.accessKeyId, 'AAA')
assert.equal(awsCreds.secretAccessKey, 'FFF')
}
await fs.promises.rm(`${__dirname}/../.aws`, { recursive: true })
}).case()
if (process.argv[1] == __filename) {
test()
}
module.exports = test