Update deps (#384)

This commit is contained in:
Seth Vargo 2024-01-22 21:04:58 -05:00 committed by GitHub
parent f6de81663f
commit aaf2e69f95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 343 additions and 349 deletions

4
dist/main/index.js vendored

File diff suppressed because one or more lines are too long

4
dist/post/index.js vendored

File diff suppressed because one or more lines are too long

148
package-lock.json generated
View File

@ -11,17 +11,17 @@
"dependencies": { "dependencies": {
"@actions/core": "^1.10.1", "@actions/core": "^1.10.1",
"@actions/http-client": "^2.2.0", "@actions/http-client": "^2.2.0",
"@google-github-actions/actions-utils": "^0.5.2" "@google-github-actions/actions-utils": "^0.7.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.10.7", "@types/node": "^20.11.5",
"@typescript-eslint/eslint-plugin": "^6.18.0", "@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.18.0", "@typescript-eslint/parser": "^6.19.1",
"@vercel/ncc": "^0.38.1", "@vercel/ncc": "^0.38.1",
"eslint": "^8.56.0", "eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2", "eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.1.1", "prettier": "^3.2.4",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.3.3" "typescript": "^5.3.3"
} }
@ -152,21 +152,21 @@
} }
}, },
"node_modules/@google-github-actions/actions-utils": { "node_modules/@google-github-actions/actions-utils": {
"version": "0.5.2", "version": "0.7.0",
"resolved": "https://registry.npmjs.org/@google-github-actions/actions-utils/-/actions-utils-0.5.2.tgz", "resolved": "https://registry.npmjs.org/@google-github-actions/actions-utils/-/actions-utils-0.7.0.tgz",
"integrity": "sha512-yowU1yGq1fV6qUV2L6xThtLW0ENYjWJwZpFY3V4JorwnGqwmiUmRLSAADiFdefHkACv6ge8rTyORzhF3GAIk3w==", "integrity": "sha512-rFA3m+cNbet+NACfuyakhTwTKSnZbPtub8BGQ7Oqt7qB7nUVBfl0l3wjiAgHdMP50e8DGnfC515iQlwLzSumlw==",
"dependencies": { "dependencies": {
"yaml": "^2.3.4" "yaml": "^2.3.4"
} }
}, },
"node_modules/@humanwhocodes/config-array": { "node_modules/@humanwhocodes/config-array": {
"version": "0.11.13", "version": "0.11.14",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz",
"integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@humanwhocodes/object-schema": "^2.0.1", "@humanwhocodes/object-schema": "^2.0.2",
"debug": "^4.1.1", "debug": "^4.3.1",
"minimatch": "^3.0.5" "minimatch": "^3.0.5"
}, },
"engines": { "engines": {
@ -209,9 +209,9 @@
} }
}, },
"node_modules/@humanwhocodes/object-schema": { "node_modules/@humanwhocodes/object-schema": {
"version": "2.0.1", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz",
"integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==",
"dev": true "dev": true
}, },
"node_modules/@jridgewell/resolve-uri": { "node_modules/@jridgewell/resolve-uri": {
@ -275,9 +275,9 @@
} }
}, },
"node_modules/@pkgr/core": { "node_modules/@pkgr/core": {
"version": "0.1.0", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.0.tgz", "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz",
"integrity": "sha512-Zwq5OCzuwJC2jwqmpEQt7Ds1DTi6BWSwoGkbb1n9pO3hzb35BoJELx7c0T23iDkBGkh2e7tvOtjF3tr3OaQHDQ==", "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": "^12.20.0 || ^14.18.0 || >=16.0.0" "node": "^12.20.0 || ^14.18.0 || >=16.0.0"
@ -317,9 +317,9 @@
"dev": true "dev": true
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "20.10.7", "version": "20.11.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.7.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.5.tgz",
"integrity": "sha512-fRbIKb8C/Y2lXxB5eVMj4IU7xpdox0Lh8bUPEdtLysaylsml1hOOx1+STloRs/B9nf7C6kPRmmg/V7aQW7usNg==", "integrity": "sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"undici-types": "~5.26.4" "undici-types": "~5.26.4"
@ -332,16 +332,16 @@
"dev": true "dev": true
}, },
"node_modules/@typescript-eslint/eslint-plugin": { "node_modules/@typescript-eslint/eslint-plugin": {
"version": "6.18.0", "version": "6.19.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.18.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.19.1.tgz",
"integrity": "sha512-3lqEvQUdCozi6d1mddWqd+kf8KxmGq2Plzx36BlkjuQe3rSTm/O98cLf0A4uDO+a5N1KD2SeEEl6fW97YHY+6w==", "integrity": "sha512-roQScUGFruWod9CEyoV5KlCYrubC/fvG8/1zXuT0WTcxX87GnMMmnksMwSg99lo1xiKrBzw2icsJPMAw1OtKxg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@eslint-community/regexpp": "^4.5.1", "@eslint-community/regexpp": "^4.5.1",
"@typescript-eslint/scope-manager": "6.18.0", "@typescript-eslint/scope-manager": "6.19.1",
"@typescript-eslint/type-utils": "6.18.0", "@typescript-eslint/type-utils": "6.19.1",
"@typescript-eslint/utils": "6.18.0", "@typescript-eslint/utils": "6.19.1",
"@typescript-eslint/visitor-keys": "6.18.0", "@typescript-eslint/visitor-keys": "6.19.1",
"debug": "^4.3.4", "debug": "^4.3.4",
"graphemer": "^1.4.0", "graphemer": "^1.4.0",
"ignore": "^5.2.4", "ignore": "^5.2.4",
@ -367,15 +367,15 @@
} }
}, },
"node_modules/@typescript-eslint/parser": { "node_modules/@typescript-eslint/parser": {
"version": "6.18.0", "version": "6.19.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.18.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.19.1.tgz",
"integrity": "sha512-v6uR68SFvqhNQT41frCMCQpsP+5vySy6IdgjlzUWoo7ALCnpaWYcz/Ij2k4L8cEsL0wkvOviCMpjmtRtHNOKzA==", "integrity": "sha512-WEfX22ziAh6pRE9jnbkkLGp/4RhTpffr2ZK5bJ18M8mIfA8A+k97U9ZyaXCEJRlmMHh7R9MJZWXp/r73DzINVQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/scope-manager": "6.18.0", "@typescript-eslint/scope-manager": "6.19.1",
"@typescript-eslint/types": "6.18.0", "@typescript-eslint/types": "6.19.1",
"@typescript-eslint/typescript-estree": "6.18.0", "@typescript-eslint/typescript-estree": "6.19.1",
"@typescript-eslint/visitor-keys": "6.18.0", "@typescript-eslint/visitor-keys": "6.19.1",
"debug": "^4.3.4" "debug": "^4.3.4"
}, },
"engines": { "engines": {
@ -395,13 +395,13 @@
} }
}, },
"node_modules/@typescript-eslint/scope-manager": { "node_modules/@typescript-eslint/scope-manager": {
"version": "6.18.0", "version": "6.19.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.19.1.tgz",
"integrity": "sha512-o/UoDT2NgOJ2VfHpfr+KBY2ErWvCySNUIX/X7O9g8Zzt/tXdpfEU43qbNk8LVuWUT2E0ptzTWXh79i74PP0twA==", "integrity": "sha512-4CdXYjKf6/6aKNMSly/BP4iCSOpvMmqtDzRtqFyyAae3z5kkqEjKndR5vDHL8rSuMIIWP8u4Mw4VxLyxZW6D5w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/types": "6.18.0", "@typescript-eslint/types": "6.19.1",
"@typescript-eslint/visitor-keys": "6.18.0" "@typescript-eslint/visitor-keys": "6.19.1"
}, },
"engines": { "engines": {
"node": "^16.0.0 || >=18.0.0" "node": "^16.0.0 || >=18.0.0"
@ -412,13 +412,13 @@
} }
}, },
"node_modules/@typescript-eslint/type-utils": { "node_modules/@typescript-eslint/type-utils": {
"version": "6.18.0", "version": "6.19.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.18.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.19.1.tgz",
"integrity": "sha512-ZeMtrXnGmTcHciJN1+u2CigWEEXgy1ufoxtWcHORt5kGvpjjIlK9MUhzHm4RM8iVy6dqSaZA/6PVkX6+r+ChjQ==", "integrity": "sha512-0vdyld3ecfxJuddDjACUvlAeYNrHP/pDeQk2pWBR2ESeEzQhg52DF53AbI9QCBkYE23lgkhLCZNkHn2hEXXYIg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/typescript-estree": "6.18.0", "@typescript-eslint/typescript-estree": "6.19.1",
"@typescript-eslint/utils": "6.18.0", "@typescript-eslint/utils": "6.19.1",
"debug": "^4.3.4", "debug": "^4.3.4",
"ts-api-utils": "^1.0.1" "ts-api-utils": "^1.0.1"
}, },
@ -439,9 +439,9 @@
} }
}, },
"node_modules/@typescript-eslint/types": { "node_modules/@typescript-eslint/types": {
"version": "6.18.0", "version": "6.19.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.19.1.tgz",
"integrity": "sha512-/RFVIccwkwSdW/1zeMx3hADShWbgBxBnV/qSrex6607isYjj05t36P6LyONgqdUrNLl5TYU8NIKdHUYpFvExkA==", "integrity": "sha512-6+bk6FEtBhvfYvpHsDgAL3uo4BfvnTnoge5LrrCj2eJN8g3IJdLTD4B/jK3Q6vo4Ql/Hoip9I8aB6fF+6RfDqg==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": "^16.0.0 || >=18.0.0" "node": "^16.0.0 || >=18.0.0"
@ -452,13 +452,13 @@
} }
}, },
"node_modules/@typescript-eslint/typescript-estree": { "node_modules/@typescript-eslint/typescript-estree": {
"version": "6.18.0", "version": "6.19.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.19.1.tgz",
"integrity": "sha512-klNvl+Ql4NsBNGB4W9TZ2Od03lm7aGvTbs0wYaFYsplVPhr+oeXjlPZCDI4U9jgJIDK38W1FKhacCFzCC+nbIg==", "integrity": "sha512-aFdAxuhzBFRWhy+H20nYu19+Km+gFfwNO4TEqyszkMcgBDYQjmPJ61erHxuT2ESJXhlhrO7I5EFIlZ+qGR8oVA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/types": "6.18.0", "@typescript-eslint/types": "6.19.1",
"@typescript-eslint/visitor-keys": "6.18.0", "@typescript-eslint/visitor-keys": "6.19.1",
"debug": "^4.3.4", "debug": "^4.3.4",
"globby": "^11.1.0", "globby": "^11.1.0",
"is-glob": "^4.0.3", "is-glob": "^4.0.3",
@ -480,17 +480,17 @@
} }
}, },
"node_modules/@typescript-eslint/utils": { "node_modules/@typescript-eslint/utils": {
"version": "6.18.0", "version": "6.19.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.18.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.19.1.tgz",
"integrity": "sha512-wiKKCbUeDPGaYEYQh1S580dGxJ/V9HI7K5sbGAVklyf+o5g3O+adnS4UNJajplF4e7z2q0uVBaTdT/yLb4XAVA==", "integrity": "sha512-JvjfEZuP5WoMqwh9SPAPDSHSg9FBHHGhjPugSRxu5jMfjvBpq5/sGTD+9M9aQ5sh6iJ8AY/Kk/oUYVEMAPwi7w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.4.0", "@eslint-community/eslint-utils": "^4.4.0",
"@types/json-schema": "^7.0.12", "@types/json-schema": "^7.0.12",
"@types/semver": "^7.5.0", "@types/semver": "^7.5.0",
"@typescript-eslint/scope-manager": "6.18.0", "@typescript-eslint/scope-manager": "6.19.1",
"@typescript-eslint/types": "6.18.0", "@typescript-eslint/types": "6.19.1",
"@typescript-eslint/typescript-estree": "6.18.0", "@typescript-eslint/typescript-estree": "6.19.1",
"semver": "^7.5.4" "semver": "^7.5.4"
}, },
"engines": { "engines": {
@ -505,12 +505,12 @@
} }
}, },
"node_modules/@typescript-eslint/visitor-keys": { "node_modules/@typescript-eslint/visitor-keys": {
"version": "6.18.0", "version": "6.19.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.1.tgz",
"integrity": "sha512-1wetAlSZpewRDb2h9p/Q8kRjdGuqdTAQbkJIOUMLug2LBLG+QOjiWoSj6/3B/hA9/tVTFFdtiKvAYoYnSRW/RA==", "integrity": "sha512-gkdtIO+xSO/SmI0W68DBg4u1KElmIUo3vXzgHyGPs6cxgB0sa3TlptRAAE0hUY1hM6FcDKEv7aIwiTGm76cXfQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/types": "6.18.0", "@typescript-eslint/types": "6.19.1",
"eslint-visitor-keys": "^3.4.1" "eslint-visitor-keys": "^3.4.1"
}, },
"engines": { "engines": {
@ -558,9 +558,9 @@
} }
}, },
"node_modules/acorn-walk": { "node_modules/acorn-walk": {
"version": "8.3.1", "version": "8.3.2",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.1.tgz", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz",
"integrity": "sha512-TgUZgYvqZprrl7YldZNoa9OciCAyZR+Ejm9eXzKCmjsF5IKp/wgQ7Z/ZpjpGTIUPwrHQIcYeI8qDh4PsEwxMbw==", "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=0.4.0" "node": ">=0.4.0"
@ -859,9 +859,9 @@
} }
}, },
"node_modules/eslint-plugin-prettier": { "node_modules/eslint-plugin-prettier": {
"version": "5.1.2", "version": "5.1.3",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.2.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz",
"integrity": "sha512-dhlpWc9vOwohcWmClFcA+HjlvUpuyynYs0Rf+L/P6/0iQE6vlHW9l5bkfzN62/Stm9fbq8ku46qzde76T1xlSg==", "integrity": "sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"prettier-linter-helpers": "^1.0.0", "prettier-linter-helpers": "^1.0.0",
@ -1589,9 +1589,9 @@
} }
}, },
"node_modules/prettier": { "node_modules/prettier": {
"version": "3.1.1", "version": "3.2.4",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.4.tgz",
"integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", "integrity": "sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ==",
"dev": true, "dev": true,
"bin": { "bin": {
"prettier": "bin/prettier.cjs" "prettier": "bin/prettier.cjs"

View File

@ -25,17 +25,17 @@
"dependencies": { "dependencies": {
"@actions/core": "^1.10.1", "@actions/core": "^1.10.1",
"@actions/http-client": "^2.2.0", "@actions/http-client": "^2.2.0",
"@google-github-actions/actions-utils": "^0.5.2" "@google-github-actions/actions-utils": "^0.7.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.10.7", "@types/node": "^20.11.5",
"@typescript-eslint/eslint-plugin": "^6.18.0", "@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.18.0", "@typescript-eslint/parser": "^6.19.1",
"@vercel/ncc": "^0.38.1", "@vercel/ncc": "^0.38.1",
"eslint": "^8.56.0", "eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2", "eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.1.1", "prettier": "^3.2.4",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.3.3" "typescript": "^5.3.3"
} }

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { describe, it } from 'node:test'; import { test } from 'node:test';
import assert from 'node:assert'; import assert from 'node:assert';
import { join as pathjoin } from 'path'; import { join as pathjoin } from 'path';
@ -41,71 +41,69 @@ const credentialsJSON = `
} }
`; `;
describe('ServiceAccountKeyClient', () => { test('#parseServiceAccountKeyJSON', { concurrency: true }, async (suite) => {
describe('#parseServiceAccountKeyJSON', () => { await suite.test('throws exception on invalid json', async () => {
it('throws exception on invalid json', async () => { await assert.rejects(async () => {
assert.rejects(async () => { new ServiceAccountKeyClient({
new ServiceAccountKeyClient({
logger: new NullLogger(),
universe: 'googleapis.com',
serviceAccountKey: 'invalid json',
});
}, SyntaxError);
});
it('handles base64', async () => {
assert.rejects(async () => {
new ServiceAccountKeyClient({
logger: new NullLogger(),
universe: 'googleapis.com',
serviceAccountKey: 'base64',
});
}, SyntaxError);
});
});
describe('#getToken', () => {
it('gets a token', async () => {
const client = new ServiceAccountKeyClient({
logger: new NullLogger(), logger: new NullLogger(),
universe: 'googleapis.com', universe: 'googleapis.com',
serviceAccountKey: credentialsJSON, serviceAccountKey: 'invalid json',
}); });
}, SyntaxError);
const token = await client.getToken();
assert.ok(token);
});
}); });
describe('#signJWT', () => { await suite.test('handles base64', async () => {
it('signs a jwt', async () => { await assert.rejects(async () => {
const client = new ServiceAccountKeyClient({ new ServiceAccountKeyClient({
logger: new NullLogger(), logger: new NullLogger(),
universe: 'googleapis.com', universe: 'googleapis.com',
serviceAccountKey: credentialsJSON, serviceAccountKey: 'base64',
}); });
}, SyntaxError);
const token = await client.signJWT('thisismy.jwt'); });
assert.ok(token); });
});
}); test('#getToken', { concurrency: true }, async (suite) => {
await suite.test('gets a token', async () => {
describe('#createCredentialsFile', () => { const client = new ServiceAccountKeyClient({
it('writes the file', async () => { logger: new NullLogger(),
const outputFile = pathjoin(tmpdir(), randomFilename()); universe: 'googleapis.com',
const client = new ServiceAccountKeyClient({ serviceAccountKey: credentialsJSON,
logger: new NullLogger(), });
universe: 'googleapis.com',
serviceAccountKey: credentialsJSON, const token = await client.getToken();
}); assert.ok(token);
});
const exp = JSON.parse(credentialsJSON); });
const pth = await client.createCredentialsFile(outputFile); test('#signJWT', { concurrency: true }, async (suite) => {
const data = readFileSync(pth); await suite.test('signs a jwt', async () => {
const got = JSON.parse(data.toString('utf8')); const client = new ServiceAccountKeyClient({
logger: new NullLogger(),
assert.deepStrictEqual(got, exp); universe: 'googleapis.com',
}); serviceAccountKey: credentialsJSON,
});
const token = await client.signJWT('thisismy.jwt');
assert.ok(token);
});
});
test('#createCredentialsFile', { concurrency: true }, async (suite) => {
await suite.test('writes the file', async () => {
const outputFile = pathjoin(tmpdir(), randomFilename());
const client = new ServiceAccountKeyClient({
logger: new NullLogger(),
universe: 'googleapis.com',
serviceAccountKey: credentialsJSON,
});
const exp = JSON.parse(credentialsJSON);
const pth = await client.createCredentialsFile(outputFile);
const data = readFileSync(pth);
const got = JSON.parse(data.toString('utf8'));
assert.deepStrictEqual(got, exp);
}); });
}); });

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { describe, it } from 'node:test'; import { test } from 'node:test';
import assert from 'node:assert'; import assert from 'node:assert';
import { tmpdir } from 'os'; import { tmpdir } from 'os';
@ -24,83 +24,81 @@ import { randomFilename } from '@google-github-actions/actions-utils';
import { NullLogger } from '../../src/logger'; import { NullLogger } from '../../src/logger';
import { WorkloadIdentityFederationClient } from '../../src/client/workload_identity_federation'; import { WorkloadIdentityFederationClient } from '../../src/client/workload_identity_federation';
describe('WorkloadIdentityFederationClient', () => { test('#createCredentialsFile', { concurrency: true }, async (suite) => {
describe('#createCredentialsFile', () => { await suite.test('writes the file', async () => {
it('writes the file', async () => { const outputFile = pathjoin(tmpdir(), randomFilename());
const outputFile = pathjoin(tmpdir(), randomFilename()); const client = new WorkloadIdentityFederationClient({
const client = new WorkloadIdentityFederationClient({ logger: new NullLogger(),
logger: new NullLogger(), universe: 'googleapis.com',
universe: 'googleapis.com',
githubOIDCToken: 'my-token', githubOIDCToken: 'my-token',
githubOIDCTokenRequestURL: 'https://example.com/', githubOIDCTokenRequestURL: 'https://example.com/',
githubOIDCTokenRequestToken: 'token', githubOIDCTokenRequestToken: 'token',
githubOIDCTokenAudience: 'my-aud', githubOIDCTokenAudience: 'my-aud',
workloadIdentityProviderName: 'my-provider', workloadIdentityProviderName: 'my-provider',
});
const exp = {
audience: '//iam.googleapis.com/my-provider',
credential_source: {
format: {
subject_token_field_name: 'value',
type: 'json',
},
headers: {
Authorization: 'Bearer token',
},
url: 'https://example.com/?audience=my-aud',
},
subject_token_type: 'urn:ietf:params:oauth:token-type:jwt',
token_url: 'https://sts.googleapis.com/v1/token',
type: 'external_account',
};
const pth = await client.createCredentialsFile(outputFile);
const data = readFileSync(pth);
const got = JSON.parse(data.toString('utf8'));
assert.deepStrictEqual(got, exp);
}); });
it('writes the file with impersonation', async () => { const exp = {
const outputFile = pathjoin(tmpdir(), randomFilename()); audience: '//iam.googleapis.com/my-provider',
const client = new WorkloadIdentityFederationClient({ credential_source: {
logger: new NullLogger(), format: {
universe: 'googleapis.com', subject_token_field_name: 'value',
type: 'json',
githubOIDCToken: 'my-token',
githubOIDCTokenRequestURL: 'https://example.com/',
githubOIDCTokenRequestToken: 'token',
githubOIDCTokenAudience: 'my-aud',
workloadIdentityProviderName: 'my-provider',
serviceAccount: 'my-service@my-project.iam.gserviceaccount.com',
});
const exp = {
audience: '//iam.googleapis.com/my-provider',
credential_source: {
format: {
subject_token_field_name: 'value',
type: 'json',
},
headers: {
Authorization: 'Bearer token',
},
url: 'https://example.com/?audience=my-aud',
}, },
service_account_impersonation_url: headers: {
'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/my-service@my-project.iam.gserviceaccount.com:generateAccessToken', Authorization: 'Bearer token',
subject_token_type: 'urn:ietf:params:oauth:token-type:jwt', },
token_url: 'https://sts.googleapis.com/v1/token', url: 'https://example.com/?audience=my-aud',
type: 'external_account', },
}; subject_token_type: 'urn:ietf:params:oauth:token-type:jwt',
token_url: 'https://sts.googleapis.com/v1/token',
type: 'external_account',
};
const pth = await client.createCredentialsFile(outputFile); const pth = await client.createCredentialsFile(outputFile);
const data = readFileSync(pth); const data = readFileSync(pth);
const got = JSON.parse(data.toString('utf8')); const got = JSON.parse(data.toString('utf8'));
assert.deepStrictEqual(got, exp); assert.deepStrictEqual(got, exp);
});
await suite.test('writes the file with impersonation', async () => {
const outputFile = pathjoin(tmpdir(), randomFilename());
const client = new WorkloadIdentityFederationClient({
logger: new NullLogger(),
universe: 'googleapis.com',
githubOIDCToken: 'my-token',
githubOIDCTokenRequestURL: 'https://example.com/',
githubOIDCTokenRequestToken: 'token',
githubOIDCTokenAudience: 'my-aud',
workloadIdentityProviderName: 'my-provider',
serviceAccount: 'my-service@my-project.iam.gserviceaccount.com',
}); });
const exp = {
audience: '//iam.googleapis.com/my-provider',
credential_source: {
format: {
subject_token_field_name: 'value',
type: 'json',
},
headers: {
Authorization: 'Bearer token',
},
url: 'https://example.com/?audience=my-aud',
},
service_account_impersonation_url:
'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/my-service@my-project.iam.gserviceaccount.com:generateAccessToken',
subject_token_type: 'urn:ietf:params:oauth:token-type:jwt',
token_url: 'https://sts.googleapis.com/v1/token',
type: 'external_account',
};
const pth = await client.createCredentialsFile(outputFile);
const data = readFileSync(pth);
const got = JSON.parse(data.toString('utf8'));
assert.deepStrictEqual(got, exp);
}); });
}); });

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { describe, it } from 'node:test'; import { test } from 'node:test';
import assert from 'node:assert'; import assert from 'node:assert';
import { import {
@ -23,151 +23,149 @@ import {
projectIDFromServiceAccountEmail, projectIDFromServiceAccountEmail,
} from '../src/utils'; } from '../src/utils';
describe('Utils', async () => { test('#buildDomainWideDelegationJWT', { concurrency: true }, async (suite) => {
describe('#buildDomainWideDelegationJWT', async () => { const cases = [
const cases = [ {
{ name: 'default',
name: 'default', serviceAccount: 'my-service@example.com',
serviceAccount: 'my-service@example.com', lifetime: 1000,
lifetime: 1000, },
}, {
{ name: 'with subject',
name: 'with subject', serviceAccount: 'my-service@example.com',
serviceAccount: 'my-service@example.com', subject: 'my-subject',
subject: 'my-subject', lifetime: 1000,
lifetime: 1000, },
}, {
{ name: 'with scopes',
name: 'with scopes', serviceAccount: 'my-service@example.com',
serviceAccount: 'my-service@example.com', scopes: ['scope1', 'scope2'],
scopes: ['scope1', 'scope2'], lifetime: 1000,
lifetime: 1000, },
}, ];
];
cases.forEach((tc) => { for await (const tc of cases) {
it(tc.name, async () => { await suite.test(tc.name, async () => {
const val = buildDomainWideDelegationJWT( const val = buildDomainWideDelegationJWT(
tc.serviceAccount, tc.serviceAccount,
tc.subject, tc.subject,
tc.scopes, tc.scopes,
tc.lifetime, tc.lifetime,
); );
const body = JSON.parse(val); const body = JSON.parse(val);
assert.deepStrictEqual(body.iss, tc.serviceAccount); assert.deepStrictEqual(body.iss, tc.serviceAccount);
assert.deepStrictEqual(body.aud, 'https://oauth2.googleapis.com/token'); assert.deepStrictEqual(body.aud, 'https://oauth2.googleapis.com/token');
assert.deepStrictEqual(body.sub, tc.subject); assert.deepStrictEqual(body.sub, tc.subject);
assert.deepStrictEqual(body.scope, tc.scopes?.join(' ')); assert.deepStrictEqual(body.scope, tc.scopes?.join(' '));
});
}); });
}); }
});
describe('#computeProjectID', async () => { test('#computeProjectID', { concurrency: true }, async (suite) => {
const cases = [ const cases = [
{ {
name: 'directly given', name: 'directly given',
projectID: 'my-project', projectID: 'my-project',
exp: 'my-project', exp: 'my-project',
}, },
{ {
name: 'from service account email', name: 'from service account email',
serviceAccountEmail: 'my-account@my-project.iam.gserviceaccount.com', serviceAccountEmail: 'my-account@my-project.iam.gserviceaccount.com',
exp: 'my-project', exp: 'my-project',
}, },
{ {
name: 'from json credential', name: 'from json credential',
serviceAccountKeyJSON: '{"type":"service_account", "project_id": "my-project"}', serviceAccountKeyJSON: '{"type":"service_account", "project_id": "my-project"}',
exp: 'my-project', exp: 'my-project',
}, },
{ {
name: 'from json credential invalid', name: 'from json credential invalid',
serviceAccountKeyJSON: '{"nope": "foo@bar.com"}', serviceAccountKeyJSON: '{"nope": "foo@bar.com"}',
exp: undefined, exp: undefined,
}, },
]; ];
cases.forEach(async (tc) => { for await (const tc of cases) {
it(tc.name, async () => { await suite.test(tc.name, async () => {
const result = computeProjectID( const result = computeProjectID(
tc.projectID, tc.projectID,
tc.serviceAccountEmail, tc.serviceAccountEmail,
tc.serviceAccountKeyJSON, tc.serviceAccountKeyJSON,
); );
assert.deepStrictEqual(result, tc.exp); assert.deepStrictEqual(result, tc.exp);
});
}); });
}); }
});
describe('#computeServiceAccountEmail', async () => { test('#computeServiceAccountEmail', { concurrency: true }, async (suite) => {
const cases = [ const cases = [
{ {
name: 'directly given', name: 'directly given',
serviceAccountEmail: 'foo@bar.com', serviceAccountEmail: 'foo@bar.com',
exp: 'foo@bar.com', exp: 'foo@bar.com',
}, },
{ {
name: 'from json credential', name: 'from json credential',
serviceAccountKeyJSON: '{"type":"service_account", "client_email": "foo@bar.com"}', serviceAccountKeyJSON: '{"type":"service_account", "client_email": "foo@bar.com"}',
exp: 'foo@bar.com', exp: 'foo@bar.com',
}, },
{ {
name: 'invalid json credential', name: 'invalid json credential',
serviceAccountKeyJSON: '{"nope": "foo@bar.com"}', serviceAccountKeyJSON: '{"nope": "foo@bar.com"}',
exp: undefined, exp: undefined,
}, },
{ {
name: 'nothing', name: 'nothing',
exp: undefined, exp: undefined,
}, },
]; ];
cases.forEach(async (tc) => { for await (const tc of cases) {
it(tc.name, async () => { await suite.test(tc.name, async () => {
const result = computeServiceAccountEmail(tc.serviceAccountEmail, tc.serviceAccountKeyJSON); const result = computeServiceAccountEmail(tc.serviceAccountEmail, tc.serviceAccountKeyJSON);
assert.deepStrictEqual(result, tc.exp); assert.deepStrictEqual(result, tc.exp);
});
}); });
}); }
});
describe('#projectIDFromServiceAccountEmail', async () => { test('#projectIDFromServiceAccountEmail', { concurrency: true }, async (suite) => {
const cases = [ const cases = [
{ {
name: 'empty', name: 'empty',
input: '', input: '',
exp: null, exp: null,
}, },
{ {
name: 'not an email', name: 'not an email',
input: 'not a service account', input: 'not a service account',
exp: null, exp: null,
}, },
{ {
name: 'invalid email', name: 'invalid email',
input: 'foo@abc', input: 'foo@abc',
exp: null, exp: null,
}, },
{ {
name: 'returns project', name: 'returns project',
input: 'test-sa@my-project.iam.gserviceaccount.com', input: 'test-sa@my-project.iam.gserviceaccount.com',
exp: 'my-project', exp: 'my-project',
}, },
]; ];
cases.forEach(async (tc) => { for await (const tc of cases) {
it(tc.name, async () => { await suite.test(tc.name, async () => {
const result = projectIDFromServiceAccountEmail(tc.input); const result = projectIDFromServiceAccountEmail(tc.input);
assert.deepStrictEqual(result, tc.exp); assert.deepStrictEqual(result, tc.exp);
});
}); });
}); }
});
describe('#generateCredentialsFilename', async () => { test('#generateCredentialsFilename', { concurrency: true }, async (suite) => {
it('returns a string matching the regex', () => { await suite.test('returns a string matching the regex', () => {
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
const filename = generateCredentialsFilename(); const filename = generateCredentialsFilename();
assert.match(filename, /gha-creds-[0-9a-z]{16}\.json/); assert.match(filename, /gha-creds-[0-9a-z]{16}\.json/);
} }
});
}); });
}); });