Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ test('it uses secrets manager (happy path)', async (t) => {
t.end();
});

test('use() defaults region to us-east-1 when AWS_REGION is unset', async (t) => {
let capturedRegion;
class SpyClient {
constructor ({ region }) { capturedRegion = region; }
send () {
return Promise.resolve({ SecretString: JSON.stringify({ spyVal: 'x' }) });
}
}
const awsSecretsManager = { SecretsManagerClient: SpyClient, GetSecretValueCommand };
const saved = process.env.AWS_REGION;
delete process.env.AWS_REGION;
try {
await env.use(awsSecretsManager, 'my-secret');
t.equals(capturedRegion, 'us-east-1');
} finally {
process.env.AWS_REGION = saved;
}
t.end();
});

test('it gets an IP address', (t) => {
const ip = env.getIP('VALID_IP');
t.equals(ip, '192.168.1.60');
Expand Down
Loading