Skip to content

Commit baa5097

Browse files
fix(secret-manager): Add TTL support to secret creation with improved test validation
1 parent c115ac4 commit baa5097

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

secret-manager/createSecret.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ async function main(
4545
secretConfig.ttl = {
4646
seconds: parseInt(ttl.replace('s', ''), 10),
4747
};
48+
console.log(`Secret TTL set to ${ttl}`);
4849
}
4950

5051
const [secret] = await client.createSecret({

secret-manager/test/secretmanager.test.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,21 @@ describe('Secret Manager samples', () => {
245245
assert.match(stdout, new RegExp('Payload: bar'));
246246
});
247247

248-
it('creates a secret', async () => {
248+
it('creates a secret with TTL', async () => {
249249
const ttl = '900s';
250250
const output = execSync(
251251
`node createSecret.js projects/${projectId} ${secretId}-2 ${ttl}`
252252
);
253253
assert.match(output, new RegExp('Created secret'));
254+
assert.match(output, new RegExp(`Secret TTL set to ${ttl}`));
255+
});
256+
257+
it('creates a secret without TTL', async () => {
258+
const output = execSync(
259+
`node createSecret.js projects/${projectId} ${secretId}-7`
260+
);
261+
assert.match(output, new RegExp('Created secret'));
262+
assert.notMatch(output, new RegExp('Secret TTL set to'));
254263
});
255264

256265
it('creates a regional secret', async () => {

0 commit comments

Comments
 (0)