Reorder function arguments alphabetically

This commit is contained in:
Eric Haag 2025-03-13 08:44:52 -05:00
parent 9f1c708302
commit ceec906aa9
No known key found for this signature in database
GPG Key ID: 6773458DF11F3FC4
3 changed files with 16 additions and 16 deletions

View File

@ -30,8 +30,8 @@ export async function setup(config: BuildScanConfig): Promise<void> {
return setupToken( return setupToken(
config.getDevelocityAccessKey(), config.getDevelocityAccessKey(),
config.getDevelocityTokenExpiry(), config.getDevelocityAllowUntrustedServer(),
config.getDevelocityAllowUntrustedServer() config.getDevelocityTokenExpiry()
) )
} }

View File

@ -5,13 +5,13 @@ import {recordDeprecation} from '../deprecation-collector'
export async function setupToken( export async function setupToken(
develocityAccessKey: string, develocityAccessKey: string,
develocityTokenExpiry: string, develocityAllowUntrustedServer: boolean | undefined,
develocityAllowUntrustedServer: boolean | undefined develocityTokenExpiry: string
): Promise<void> { ): Promise<void> {
if (develocityAccessKey) { if (develocityAccessKey) {
try { try {
core.debug('Fetching short-lived token...') core.debug('Fetching short-lived token...')
const tokens = await getToken(develocityAccessKey, develocityTokenExpiry, develocityAllowUntrustedServer) const tokens = await getToken(develocityAccessKey, develocityAllowUntrustedServer, develocityTokenExpiry)
if (tokens != null && !tokens.isEmpty()) { if (tokens != null && !tokens.isEmpty()) {
core.debug(`Got token(s), setting the access key env vars`) core.debug(`Got token(s), setting the access key env vars`)
const token = tokens.raw() const token = tokens.raw()
@ -47,12 +47,12 @@ function handleMissingAccessToken(): void {
export async function getToken( export async function getToken(
accessKey: string, accessKey: string,
expiry: string, allowUntrustedServer: undefined | boolean,
develocityAllowUntrustedServer: undefined | boolean expiry: string
): Promise<DevelocityAccessCredentials | null> { ): Promise<DevelocityAccessCredentials | null> {
const empty: Promise<DevelocityAccessCredentials | null> = new Promise(r => r(null)) const empty: Promise<DevelocityAccessCredentials | null> = new Promise(r => r(null))
const develocityAccessKey = DevelocityAccessCredentials.parse(accessKey) const develocityAccessKey = DevelocityAccessCredentials.parse(accessKey)
const shortLivedTokenClient = new ShortLivedTokenClient(develocityAllowUntrustedServer) const shortLivedTokenClient = new ShortLivedTokenClient(allowUntrustedServer)
if (develocityAccessKey == null) { if (develocityAccessKey == null) {
return empty return empty

View File

@ -39,7 +39,7 @@ describe('short lived tokens', () => {
message: 'connect ECONNREFUSED 127.0.0.1:3333', message: 'connect ECONNREFUSED 127.0.0.1:3333',
code: 'ECONNREFUSED' code: 'ECONNREFUSED'
}) })
await expect(getToken('localhost=key0', '', false)) await expect(getToken('localhost=key0', false, ''))
.resolves .resolves
.toBeNull() .toBeNull()
}) })
@ -50,14 +50,14 @@ describe('short lived tokens', () => {
.times(3) .times(3)
.reply(500, 'Internal error') .reply(500, 'Internal error')
expect.assertions(1) expect.assertions(1)
await expect(getToken('dev=xyz', '', false)) await expect(getToken('dev=xyz', false, ''))
.resolves .resolves
.toBeNull() .toBeNull()
}) })
it('get short lived token returns null when access key is empty', async () => { it('get short lived token returns null when access key is empty', async () => {
expect.assertions(1) expect.assertions(1)
await expect(getToken('', '', false)) await expect(getToken('', false, ''))
.resolves .resolves
.toBeNull() .toBeNull()
}) })
@ -67,7 +67,7 @@ describe('short lived tokens', () => {
.post('/api/auth/token') .post('/api/auth/token')
.reply(200, 'token') .reply(200, 'token')
expect.assertions(1) expect.assertions(1)
await expect(getToken('dev=key1', '', false)) await expect(getToken('dev=key1', false, ''))
.resolves .resolves
.toEqual({"keys": [{"hostname": "dev", "key": "token"}]}) .toEqual({"keys": [{"hostname": "dev", "key": "token"}]})
}) })
@ -80,7 +80,7 @@ describe('short lived tokens', () => {
.post('/api/auth/token') .post('/api/auth/token')
.reply(200, 'token2') .reply(200, 'token2')
expect.assertions(1) expect.assertions(1)
await expect(getToken('dev=key1;prod=key2', '', false)) await expect(getToken('dev=key1;prod=key2', false, ''))
.resolves .resolves
.toEqual({"keys": [{"hostname": "dev", "key": "token1"}, {"hostname": "prod", "key": "token2"}]}) .toEqual({"keys": [{"hostname": "dev", "key": "token1"}, {"hostname": "prod", "key": "token2"}]})
}) })
@ -97,7 +97,7 @@ describe('short lived tokens', () => {
.post('/api/auth/token') .post('/api/auth/token')
.reply(200, 'token2') .reply(200, 'token2')
expect.assertions(1) expect.assertions(1)
await expect(getToken('dev=key1;bogus=key0;prod=key2', '', false)) await expect(getToken('dev=key1;bogus=key0;prod=key2', false, ''))
.resolves .resolves
.toEqual({"keys": [{"hostname": "dev", "key": "token1"}, {"hostname": "prod", "key": "token2"}]}) .toEqual({"keys": [{"hostname": "dev", "key": "token1"}, {"hostname": "prod", "key": "token2"}]})
}) })
@ -112,7 +112,7 @@ describe('short lived tokens', () => {
.times(3) .times(3)
.reply(500, 'Internal Error') .reply(500, 'Internal Error')
expect.assertions(1) expect.assertions(1)
await expect(getToken('dev=key1;bogus=key0', '', false)) await expect(getToken('dev=key1;bogus=key0', false, ''))
.resolves .resolves
.toBeNull() .toBeNull()
}) })
@ -122,7 +122,7 @@ describe('short lived tokens', () => {
.post('/api/auth/token?expiresInHours=4') .post('/api/auth/token?expiresInHours=4')
.reply(200, 'token') .reply(200, 'token')
expect.assertions(1) expect.assertions(1)
await expect(getToken('dev=key1', '4', false)) await expect(getToken('dev=key1', false, '4'))
.resolves .resolves
.toEqual({"keys": [{"hostname": "dev", "key": "token"}]}) .toEqual({"keys": [{"hostname": "dev", "key": "token"}]})
}) })