Skip to content
This repository was archived by the owner on May 3, 2022. It is now read-only.

Commit ab10999

Browse files
Merge pull request #23 from actions/format
apply formatting
2 parents c715044 + c0e4c90 commit ab10999

12 files changed

+1619
-1276
lines changed

.github/workflows/test.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ jobs:
4040
- name: npm test
4141
run: npm test
4242

43-
# - name: Format
44-
# run: npm run format-check
43+
- name: Format
44+
shell: bash
45+
run: npm run format-check
46+
if: matrix.runs-on == 'ubuntu-latest'
4547

4648
- name: audit security
49+
continue-on-error: true
4750
run: npm audit --audit-level=moderate
51+
if: matrix.runs-on == 'ubuntu-latest'

__tests__/auth.test.ts

+53-48
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,61 @@
1-
import * as httpm from '../_out';
2-
import * as am from '../_out/auth';
1+
import * as httpm from '../_out'
2+
import * as am from '../_out/auth'
33

44
describe('auth', () => {
5-
beforeEach(() => {
5+
beforeEach(() => {})
66

7-
})
8-
9-
afterEach(() => {
7+
afterEach(() => {})
108

11-
})
12-
13-
it('does basic http get request with basic auth', async() => {
14-
let bh: am.BasicCredentialHandler = new am.BasicCredentialHandler('johndoe', 'password');
15-
let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [bh]);
16-
let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get');
17-
expect(res.message.statusCode).toBe(200);
18-
let body: string = await res.readBody();
19-
let obj:any = JSON.parse(body);
20-
let auth: string = obj.headers.Authorization;
21-
let creds: string = Buffer.from(auth.substring('Basic '.length), 'base64').toString();
22-
expect(creds).toBe('johndoe:password');
23-
expect(obj.url).toBe("http://httpbin.org/get");
24-
});
9+
it('does basic http get request with basic auth', async () => {
10+
let bh: am.BasicCredentialHandler = new am.BasicCredentialHandler(
11+
'johndoe',
12+
'password'
13+
)
14+
let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [bh])
15+
let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get')
16+
expect(res.message.statusCode).toBe(200)
17+
let body: string = await res.readBody()
18+
let obj: any = JSON.parse(body)
19+
let auth: string = obj.headers.Authorization
20+
let creds: string = Buffer.from(
21+
auth.substring('Basic '.length),
22+
'base64'
23+
).toString()
24+
expect(creds).toBe('johndoe:password')
25+
expect(obj.url).toBe('http://httpbin.org/get')
26+
})
2527

26-
it('does basic http get request with pat token auth', async() => {
27-
let token: string = 'scbfb44vxzku5l4xgc3qfazn3lpk4awflfryc76esaiq7aypcbhs';
28-
let ph: am.PersonalAccessTokenCredentialHandler =
29-
new am.PersonalAccessTokenCredentialHandler(token);
28+
it('does basic http get request with pat token auth', async () => {
29+
let token: string = 'scbfb44vxzku5l4xgc3qfazn3lpk4awflfryc76esaiq7aypcbhs'
30+
let ph: am.PersonalAccessTokenCredentialHandler = new am.PersonalAccessTokenCredentialHandler(
31+
token
32+
)
3033

31-
let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [ph]);
32-
let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get');
33-
expect(res.message.statusCode).toBe(200);
34-
let body: string = await res.readBody();
35-
let obj:any = JSON.parse(body);
36-
let auth: string = obj.headers.Authorization;
37-
let creds: string = Buffer.from(auth.substring('Basic '.length), 'base64').toString();
38-
expect(creds).toBe('PAT:' + token);
39-
expect(obj.url).toBe("http://httpbin.org/get");
40-
});
41-
42-
it('does basic http get request with pat token auth', async() => {
43-
let token: string = 'scbfb44vxzku5l4xgc3qfazn3lpk4awflfryc76esaiq7aypcbhs';
44-
let ph: am.BearerCredentialHandler =
45-
new am.BearerCredentialHandler(token);
34+
let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [ph])
35+
let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get')
36+
expect(res.message.statusCode).toBe(200)
37+
let body: string = await res.readBody()
38+
let obj: any = JSON.parse(body)
39+
let auth: string = obj.headers.Authorization
40+
let creds: string = Buffer.from(
41+
auth.substring('Basic '.length),
42+
'base64'
43+
).toString()
44+
expect(creds).toBe('PAT:' + token)
45+
expect(obj.url).toBe('http://httpbin.org/get')
46+
})
4647

47-
let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [ph]);
48-
let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get');
49-
expect(res.message.statusCode).toBe(200);
50-
let body: string = await res.readBody();
51-
let obj:any = JSON.parse(body);
52-
let auth: string = obj.headers.Authorization;
53-
expect(auth).toBe('Bearer ' + token);
54-
expect(obj.url).toBe("http://httpbin.org/get");
55-
});
48+
it('does basic http get request with pat token auth', async () => {
49+
let token: string = 'scbfb44vxzku5l4xgc3qfazn3lpk4awflfryc76esaiq7aypcbhs'
50+
let ph: am.BearerCredentialHandler = new am.BearerCredentialHandler(token)
51+
52+
let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [ph])
53+
let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get')
54+
expect(res.message.statusCode).toBe(200)
55+
let body: string = await res.readBody()
56+
let obj: any = JSON.parse(body)
57+
let auth: string = obj.headers.Authorization
58+
expect(auth).toBe('Bearer ' + token)
59+
expect(obj.url).toBe('http://httpbin.org/get')
60+
})
5661
})

0 commit comments

Comments
 (0)