Skip to content

Commit 9d20f74

Browse files
Fix broken azure pipeline (microsoft#316)
* set vmImage to ubuntu-20.04 * skip certificate validation on node 8 * add node 6 * use HTTP instead of disabling certificate validation
1 parent a6b0daf commit 9d20f74

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

azure-pipelines.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
pool:
2+
vmImage: ubuntu-20.04
3+
14
parameters:
25
- name: versionSpec
36
type: object

test/tests/httptests.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import * as path from 'path';
99

1010
let sampleFilePath: string = path.join(__dirname, 'testoutput.txt');
1111

12+
const nodeVersionsWithCertificateErrors = [6, 8];
13+
let redirectProtocol = 'https';
14+
if (nodeVersionsWithCertificateErrors.find((nodeVersion) => process.version.startsWith(`v${nodeVersion}.`))) {
15+
console.log('Using protocol HTTP for redirect tests to avoid certificate errors on this node version');
16+
redirectProtocol = 'http';
17+
}
18+
1219
describe('Http Tests', function () {
1320
let _http: httpm.HttpClient;
1421
let _httpbin: httpm.HttpClient;
@@ -179,30 +186,30 @@ describe('Http Tests', function () {
179186
});
180187

181188
it('does basic get request with redirects', async() => {
182-
let res: httpm.HttpClientResponse = await _http.get("https://httpbingo.org/redirect-to?url=" + encodeURIComponent("https://httpbin.org/get"))
189+
let res: httpm.HttpClientResponse = await _http.get(`${redirectProtocol}://httpbingo.org/redirect-to?url=` + encodeURIComponent("https://httpbin.org/get"))
183190
assert(res.message.statusCode == 200, "status code should be 200");
184191
let body: string = await res.readBody();
185192
let obj:any = JSON.parse(body);
186193
assert(obj.url === "https://httpbin.org/get");
187194
});
188195

189196
it('does basic get request with redirects (303)', async() => {
190-
let res: httpm.HttpClientResponse = await _http.get("https://httpbingo.org/redirect-to?url=" + encodeURIComponent("https://httpbin.org/get") + '&status_code=303')
197+
let res: httpm.HttpClientResponse = await _http.get(`${redirectProtocol}://httpbingo.org/redirect-to?url=` + encodeURIComponent("https://httpbin.org/get") + '&status_code=303')
191198
assert(res.message.statusCode == 200, "status code should be 200");
192199
let body: string = await res.readBody();
193200
let obj:any = JSON.parse(body);
194201
assert(obj.url === "https://httpbin.org/get");
195202
});
196203

197204
it('returns 404 for not found get request on redirect', async() => {
198-
let res: httpm.HttpClientResponse = await _http.get("https://httpbingo.org/redirect-to?url=" + encodeURIComponent("https://httpbin.org/status/404") + '&status_code=303')
205+
let res: httpm.HttpClientResponse = await _http.get(`${redirectProtocol}://httpbingo.org/redirect-to?url=` + encodeURIComponent("https://httpbin.org/status/404") + '&status_code=303')
199206
assert(res.message.statusCode == 404, "status code should be 404");
200207
let body: string = await res.readBody();
201208
});
202209

203210
it('does not follow redirects if disabled', async() => {
204211
let http: httpm.HttpClient = new httpm.HttpClient('typed-test-client-tests', null, { allowRedirects: false });
205-
let res: httpm.HttpClientResponse = await http.get("https://httpbingo.org/redirect-to?url=" + encodeURIComponent("https://httpbin.org/get"))
212+
let res: httpm.HttpClientResponse = await http.get(`${redirectProtocol}://httpbingo.org/redirect-to?url=` + encodeURIComponent("https://httpbin.org/get"))
206213
assert(res.message.statusCode == 302, "status code should be 302");
207214
let body: string = await res.readBody();
208215
});

0 commit comments

Comments
 (0)