mirror of https://github.com/actions/toolkit
Addressed Comments
parent
5d9c674092
commit
cca2b1808b
|
@ -232,7 +232,6 @@ async function getIDTokenAction(): Promise<void> {
|
|||
if (audience !== undefined)
|
||||
aud = `${audience}`
|
||||
const id_token = await core.getIDToken(aud)
|
||||
core.setSecret(id_token)
|
||||
core.setOutput('id_token', id_token)
|
||||
|
||||
}
|
||||
|
|
|
@ -427,7 +427,7 @@ describe('oidc-client-tests', () => {
|
|||
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/"
|
||||
expect(oidcClient.getIDTokenUrl()).toBe("https://www.example.com/?api-version=" + oidcClient.getApiVersion())
|
||||
})
|
||||
|
@ -436,7 +436,7 @@ describe('oidc-client-tests', () => {
|
|||
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")
|
||||
})
|
||||
})
|
|
@ -2,7 +2,7 @@ import * as actions_http_client from '@actions/http-client'
|
|||
import {IHeaders,IRequestOptions} from '@actions/http-client/interfaces'
|
||||
import {HttpClient} from '@actions/http-client'
|
||||
import {BearerCredentialHandler} from '@actions/http-client/auth'
|
||||
import {debug} from './core'
|
||||
import {debug, setSecret} from './core'
|
||||
|
||||
interface IOidcClient {
|
||||
|
||||
|
@ -80,7 +80,9 @@ export class OidcClient implements IOidcClient {
|
|||
|
||||
if (!this.isSuccessStatusCode(response.message.statusCode)) {
|
||||
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 {
|
||||
throw new Error('Response json body do not have ID Token field')
|
||||
}
|
||||
setSecret(id_token)
|
||||
return id_token
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue