Skip to content

Commit 1d50450

Browse files
williambernardetbryanmacfarlane
authored andcommitted
Update yped-rest-client to 1.0.9, and add unittest to cover 303 case. (#43)
1 parent 27dfacc commit 1d50450

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"semver": "^5.3.0",
2626
"@types/semver": "^5.3.0",
2727
"semver-compare": "^1.0.0",
28-
"typed-rest-client": "1.0.7",
28+
"typed-rest-client": "1.0.9",
2929
"uuid": "^3.0.1",
3030
"@types/uuid": "^3.0.1",
3131
"vsts-task-lib": "2.4.0"

test/toolTests.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,28 @@ describe('Tool Tests', function () {
6666

6767
return new Promise<void>(async (resolve, reject) => {
6868
try {
69-
let downPath: string = await toolLib.downloadTool("https://httpbin.org/redirect-to?url=http%3A%2F%2Fhttpbin.org%2Fbytes%2F100&status_code=302");
69+
70+
let downPath: string = await toolLib.downloadTool("https://httpbin.org/redirect-to?url=" + encodeURI('http://httpbin.org/bytes/100') + "&status_code=302");
71+
toolLib.debug('downloaded path: ' + downPath);
72+
73+
assert(tl.exist(downPath), 'downloaded file exists');
74+
assert.equal(fs.statSync(downPath).size, 100, 'downloaded file is the correct size');
75+
76+
resolve();
77+
}
78+
catch (err) {
79+
reject(err);
80+
}
81+
});
82+
});
83+
84+
it('downloads a 100 byte file after a redirect 303 (See Other)', function () {
85+
this.timeout(5000);
86+
87+
return new Promise<void>(async (resolve, reject) => {
88+
try {
89+
90+
let downPath: string = await toolLib.downloadTool("https://httpbin.org/redirect-to?url=" + encodeURI('http://httpbin.org/bytes/100') + "&status_code=303");
7091
toolLib.debug('downloaded path: ' + downPath);
7192

7293
assert(tl.exist(downPath), 'downloaded file exists');

tool.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ export function findLocalToolVersions(toolName: string, arch?: string) {
183183

184184
//
185185
// TODO: keep extension intact
186-
// TODO: support 302 redirect
187186
//
188187
/**
189188
* Download a tool from an url and stream it into a file

0 commit comments

Comments
 (0)