mirror of
https://github.com/actions/setup-node.git
synced 2026-12-01 19:44:41 +00:00
fix: send GitHub token instead of mirror-token to GitHub endpoints (#1669)
This commit is contained in:
@@ -479,6 +479,69 @@ describe('setup-node', () => {
|
||||
expect(addPathSpy).toHaveBeenCalledWith(expPath);
|
||||
});
|
||||
|
||||
it('sends GitHub token to GitHub manifest and release downloads when mirror and mirror-token are set', async () => {
|
||||
os.platform = 'linux';
|
||||
os.arch = 'x64';
|
||||
|
||||
const versionSpec = '12.16.2';
|
||||
inputs['node-version'] = versionSpec;
|
||||
inputs['token'] = 'github-secret-token';
|
||||
inputs['mirror'] = 'https://my_mirror_url';
|
||||
inputs['mirror-token'] = 'mirror-secret-token';
|
||||
|
||||
findSpy.mockImplementation(() => '');
|
||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||
const toolPath = path.normalize('/cache/node/12.16.2/x64');
|
||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||
cacheSpy.mockImplementation(async () => toolPath);
|
||||
|
||||
await main.run();
|
||||
|
||||
expect(getManifestSpy).toHaveBeenCalledWith(
|
||||
'actions',
|
||||
'node-versions',
|
||||
'token github-secret-token',
|
||||
'main'
|
||||
);
|
||||
expect(dlSpy).toHaveBeenCalledWith(
|
||||
'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz',
|
||||
undefined,
|
||||
'token github-secret-token'
|
||||
);
|
||||
});
|
||||
|
||||
it('sends GitHub token to manifest and mirror-token to mirror when falling back to mirror', async () => {
|
||||
os.platform = 'linux';
|
||||
os.arch = 'x64';
|
||||
|
||||
const versionSpec = '11.15.0';
|
||||
const mirror = 'https://my_mirror_url';
|
||||
inputs['node-version'] = versionSpec;
|
||||
inputs['token'] = 'github-secret-token';
|
||||
inputs['mirror'] = mirror;
|
||||
inputs['mirror-token'] = 'mirror-secret-token';
|
||||
|
||||
findSpy.mockImplementation(() => '');
|
||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||
const toolPath = path.normalize('/cache/node/11.15.0/x64');
|
||||
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||
cacheSpy.mockImplementation(async () => toolPath);
|
||||
|
||||
await main.run();
|
||||
|
||||
expect(getManifestSpy).toHaveBeenCalledWith(
|
||||
'actions',
|
||||
'node-versions',
|
||||
'token github-secret-token',
|
||||
'main'
|
||||
);
|
||||
expect(dlSpy).toHaveBeenCalledWith(
|
||||
`${mirror}/dist/v11.15.0/node-v11.15.0-linux-x64.tar.gz`,
|
||||
undefined,
|
||||
'mirror-secret-token'
|
||||
);
|
||||
});
|
||||
|
||||
it('falls back to a version from node dist', async () => {
|
||||
os.platform = 'linux';
|
||||
os.arch = 'x64';
|
||||
|
||||
Vendored
+2
-6
@@ -99051,9 +99051,7 @@ class OfficialBuilds extends BaseDistribution {
|
||||
const versionInfo = await this.getInfoFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest);
|
||||
if (versionInfo) {
|
||||
core_info(`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`);
|
||||
downloadPath = await downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.mirror && this.nodeInfo.mirrorToken
|
||||
? this.nodeInfo.mirrorToken
|
||||
: this.nodeInfo.auth);
|
||||
downloadPath = await downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.auth);
|
||||
if (downloadPath) {
|
||||
toolPath = await this.extractArchive(downloadPath, versionInfo, false);
|
||||
}
|
||||
@@ -99174,9 +99172,7 @@ class OfficialBuilds extends BaseDistribution {
|
||||
core_debug('Getting manifest from actions/node-versions@main');
|
||||
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
||||
try {
|
||||
const manifest = await getManifestFromRepo('actions', 'node-versions', this.nodeInfo.mirror && this.nodeInfo.mirrorToken
|
||||
? this.nodeInfo.mirrorToken
|
||||
: this.nodeInfo.auth, 'main');
|
||||
const manifest = await getManifestFromRepo('actions', 'node-versions', this.nodeInfo.auth, 'main');
|
||||
if (isValidManifest(manifest)) {
|
||||
return manifest;
|
||||
}
|
||||
|
||||
@@ -106,9 +106,7 @@ export default class OfficialBuilds extends BaseDistribution {
|
||||
downloadPath = await tc.downloadTool(
|
||||
versionInfo.downloadUrl,
|
||||
undefined,
|
||||
this.nodeInfo.mirror && this.nodeInfo.mirrorToken
|
||||
? this.nodeInfo.mirrorToken
|
||||
: this.nodeInfo.auth
|
||||
this.nodeInfo.auth
|
||||
);
|
||||
|
||||
if (downloadPath) {
|
||||
@@ -287,9 +285,7 @@ export default class OfficialBuilds extends BaseDistribution {
|
||||
const manifest = await tc.getManifestFromRepo(
|
||||
'actions',
|
||||
'node-versions',
|
||||
this.nodeInfo.mirror && this.nodeInfo.mirrorToken
|
||||
? this.nodeInfo.mirrorToken
|
||||
: this.nodeInfo.auth,
|
||||
this.nodeInfo.auth,
|
||||
'main'
|
||||
);
|
||||
if (isValidManifest(manifest)) {
|
||||
|
||||
Reference in New Issue
Block a user