mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2025-08-25 03:39:08 +08:00
Addressed Comments
This commit is contained in:
parent
5d9c674092
commit
cca2b1808b
@ -232,7 +232,6 @@ async function getIDTokenAction(): Promise<void> {
|
|||||||
if (audience !== undefined)
|
if (audience !== undefined)
|
||||||
aud = `${audience}`
|
aud = `${audience}`
|
||||||
const id_token = await core.getIDToken(aud)
|
const id_token = await core.getIDToken(aud)
|
||||||
core.setSecret(id_token)
|
|
||||||
core.setOutput('id_token', id_token)
|
core.setOutput('id_token', id_token)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -427,7 +427,7 @@ describe('oidc-client-tests', () => {
|
|||||||
expect(oidcClient.isSuccessStatusCode(400)).toBeFalsy()
|
expect(oidcClient.isSuccessStatusCode(400)).toBeFalsy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('check if we get correct ID Token Request url with correct api version', () => {
|
it('check if we get correct ID Token Request url with right api version', () => {
|
||||||
process.env.ACTIONS_ID_TOKEN_REQUEST_URL = "https://www.example.com/"
|
process.env.ACTIONS_ID_TOKEN_REQUEST_URL = "https://www.example.com/"
|
||||||
expect(oidcClient.getIDTokenUrl()).toBe("https://www.example.com/?api-version=" + oidcClient.getApiVersion())
|
expect(oidcClient.getIDTokenUrl()).toBe("https://www.example.com/?api-version=" + oidcClient.getApiVersion())
|
||||||
})
|
})
|
||||||
@ -436,7 +436,7 @@ describe('oidc-client-tests', () => {
|
|||||||
expect(() => oidcClient.parseJson("{}")).toThrow()
|
expect(() => oidcClient.parseJson("{}")).toThrow()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('check if invalid json throws error', () => {
|
it('check if valid json returns parsed id token', () => {
|
||||||
expect(oidcClient.parseJson('{"value" : "abc" }')).toBe("abc")
|
expect(oidcClient.parseJson('{"value" : "abc" }')).toBe("abc")
|
||||||
})
|
})
|
||||||
})
|
})
|
@ -2,7 +2,7 @@ import * as actions_http_client from '@actions/http-client'
|
|||||||
import {IHeaders,IRequestOptions} from '@actions/http-client/interfaces'
|
import {IHeaders,IRequestOptions} from '@actions/http-client/interfaces'
|
||||||
import {HttpClient} from '@actions/http-client'
|
import {HttpClient} from '@actions/http-client'
|
||||||
import {BearerCredentialHandler} from '@actions/http-client/auth'
|
import {BearerCredentialHandler} from '@actions/http-client/auth'
|
||||||
import {debug} from './core'
|
import {debug, setSecret} from './core'
|
||||||
|
|
||||||
interface IOidcClient {
|
interface IOidcClient {
|
||||||
|
|
||||||
@ -80,7 +80,9 @@ export class OidcClient implements IOidcClient {
|
|||||||
|
|
||||||
if (!this.isSuccessStatusCode(response.message.statusCode)) {
|
if (!this.isSuccessStatusCode(response.message.statusCode)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Failed to get ID Token. \n Error Code : ${response.message.statusCode} Error message : ${response.message.statusMessage} \n Response body: ${body}`
|
`Failed to get ID Token. \n
|
||||||
|
Error Code : ${response.message.statusCode} Error message : ${response.message.statusMessage} \n
|
||||||
|
Response body: ${body}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +97,7 @@ export class OidcClient implements IOidcClient {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error('Response json body do not have ID Token field')
|
throw new Error('Response json body do not have ID Token field')
|
||||||
}
|
}
|
||||||
|
setSecret(id_token)
|
||||||
return id_token
|
return id_token
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user