Skip to content

Commit

Permalink
chore: upgrade nodejs version
Browse files Browse the repository at this point in the history
  • Loading branch information
coquer committed Apr 8, 2024
1 parent 60062c3 commit c864965
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 68 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: yarn

- name: Install dependencies
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: yarn

- name: Install dependencies
Expand All @@ -57,7 +57,7 @@ jobs:
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: yarn

- name: Install dependencies
Expand All @@ -84,7 +84,7 @@ jobs:
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: yarn

- name: Install dependencies
Expand All @@ -107,7 +107,7 @@ jobs:
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: yarn

- name: Install dependencies
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: yarn

- name: Install dependencies
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: yarn

- name: Install dependencies
Expand All @@ -55,7 +55,7 @@ jobs:
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: yarn

- name: Install dependencies
Expand All @@ -81,7 +81,7 @@ jobs:
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: yarn

- name: Install dependencies
Expand Down
24 changes: 12 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: 'aws-secrets-manager-actions'
description: 'GitHub Actions for AWS Secrets Manager'
name: "aws-secrets-manager-actions"
description: "GitHub Actions for AWS Secrets Manager"
inputs:
SECRET_NAME:
description: 'Set secret name that you want to get.'
description: "Set secret name that you want to get."
required: true
AWS_ACCESS_KEY_ID:
description: 'Set Aws Access Key ID'
description: "Set Aws Access Key ID"
required: false
AWS_SECRET_ACCESS_KEY:
description: 'Set Aws Secret access Key'
description: "Set Aws Secret access Key"
required: false
AWS_SESSION_TOKEN:
description: 'Set Aws Session token Key'
description: "Set Aws Session token Key"
required: false
AWS_DEFAULT_REGION:
description: 'Set Aws default region'
description: "Set Aws default region"
required: false
OUTPUT_PATH:
description: 'Set output file where variables are write'
description: "Set output file where variables are write"
required: false
runs:
using: 'node16'
main: 'dist/index.js'
using: "node20"
main: "dist/index.js"
branding:
icon: 'lock'
color: 'orange'
icon: "lock"
color: "orange"
80 changes: 33 additions & 47 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,40 @@ const aws = require('aws-sdk')
const index = require('./index.js')

describe('get SecretString from AWS SecretsManager', () => {
let data = {}
describe('get parsable data', () => {
beforeAll(async () => {
const INPUT_SECRET_NAME = process.env.SECRET_NAME

const AWSConfig = {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: process.env.AWS_DEFAULT_REGION
}

if (process.env.AWS_SESSION_TOKEN) {
AWSConfig.sessionToken = process.env.AWS_SESSION_TOKEN
}

const secretsManager = new aws.SecretsManager(AWSConfig)
data = await index.getSecretValue(secretsManager, INPUT_SECRET_NAME)
})

test('should have SecretString', () => {
expect(data).toHaveProperty('SecretString')
})

test('should have parsed values', () => {
const parsedData = JSON.parse(data.SecretString)
expect(parsedData.SCIENTIFIC_NAME).toEqual('Pygoscelis adeliae')
expect(parsedData.MIN_HEIGHT).toEqual(46)
expect(parsedData.MAX_HEIGHT).toEqual(71)
expect(parsedData.MIN_WEIGHT).toEqual(3.6)
expect(parsedData.MAX_WEIGHT).toEqual(6)
expect(parsedData.SWIMMING_SPEED).toEqual(8)
expect(parsedData.LEAPING_METERS).toEqual(3)
})
const secretsManager = new aws.SecretsManager({
accessKeyId: 'fake-access-key-id',
secretAccessKey: 'fake-secret',
region: 'us-east-1'
})

describe('get unparsable data', () => {
beforeAll(async () => {
const INPUT_SECRET_NAME = `${process.env.SECRET_NAME}-unvalid`
const secretsManager = new aws.SecretsManager({
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: process.env.AWS_DEFAULT_REGION
})
data = await index.getSecretValue(secretsManager, INPUT_SECRET_NAME)
})

test('should have SecretString', () => {
expect(data).toHaveProperty('SecretString')
})
const secretName = 'secretName'

const secretString = JSON.stringify({
key1: 'value1',
key2: 'value2'
})

const resp = {
SecretString: secretString
}

secretsManager.getSecretValue = jest.fn().mockReturnValue({
promise: jest.fn().mockResolvedValue(resp)
})

it('should have parsed values', async () => {
await index.getSecretValue(secretsManager, secretName)
expect(process.env.key1).toEqual('value1')
expect(process.env.key2).toEqual('value2')
})

it('should return the secret values', async () => {
const result = await index.getSecretValue(secretsManager, secretName)
expect(result).toEqual(resp)
})

it('should have SecretString', async () => {
await index.getSecretValue(secretsManager, secretName)
expect(process.env.asm_secret).toEqual(secretString)
})
})

0 comments on commit c864965

Please sign in to comment.