deno.land / x / oauth4webapi@v1.2.2 / test / www_authenticate.test.ts

www_authenticate.test.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import test from 'ava'import { getResponse } from './_setup.js'import * as lib from '../src/index.js'
function response(headers: Headers) { return getResponse('', { status: 401, headers })}
const name = 'www-authenticate'
test('parseWwwAuthenticateChallenges()', (t) => { { const headers = new Headers() t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), undefined) }
{ const headers = new Headers() headers.append(name, 'invalid=true') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), undefined) }
{ const headers = new Headers() headers.append(name, 'Basic realm="Access to the staging site", charset="UTF-8"') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'basic', parameters: { charset: 'UTF-8', realm: 'Access to the staging site' } }, ]) }
{ const headers = new Headers() headers.append(name, 'Basic') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'basic', parameters: {} }, ]) }
{ const headers = new Headers() headers.append(name, 'Basic realm=realm') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'basic', parameters: { realm: 'realm' } }, ]) }
{ const headers = new Headers() headers.append(name, 'BASIC REALM=realM') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'basic', parameters: { realm: 'realM' } }, ]) }
{ const headers = new Headers() headers.append(name, 'Basic realm="realm"') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'basic', parameters: { realm: 'realm' } }, ]) }
{ const headers = new Headers() headers.append(name, 'Basic auth-param1="value"') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'basic', parameters: { 'auth-param1': 'value' } }, ]) }
{ const headers = new Headers() headers.append( name, 'Digest realm="http-auth@example.org", qop="auth, auth-int", algorithm=SHA-256, nonce="7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v", opaque="FQhe/qaU925kfnzjCev0ciny7QMkPqMAFRtzCUYo5tdS"', ) headers.append( name, 'Digest realm="http-auth@example.org", qop="auth, auth-int", algorithm=MD5, nonce="7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v", opaque="FQhe/qaU925kfnzjCev0ciny7QMkPqMAFRtzCUYo5tdS"', )
t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'digest', parameters: { realm: 'http-auth@example.org', qop: 'auth, auth-int', algorithm: 'SHA-256', nonce: '7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v', opaque: 'FQhe/qaU925kfnzjCev0ciny7QMkPqMAFRtzCUYo5tdS', }, }, { scheme: 'digest', parameters: { realm: 'http-auth@example.org', qop: 'auth, auth-int', algorithm: 'MD5', nonce: '7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v', opaque: 'FQhe/qaU925kfnzjCev0ciny7QMkPqMAFRtzCUYo5tdS', }, }, ]) }
{ const headers = new Headers() headers.append( name, 'Newauth realm="apps", type=1, title="Login to "apps"", Basic realm="simple"', ) t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'newauth', parameters: { realm: 'apps', type: '1', title: 'Login to "apps"', }, }, { scheme: 'basic', parameters: { realm: 'simple', }, }, ]) }
{ const headers = new Headers() headers.append(name, 'Basic') headers.append(name, 'DPoP') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'basic', parameters: {} }, { scheme: 'dpop', parameters: {} }, ]) }
{ const headers = new Headers() headers.append(name, 'Newauth realm="apps", type=1, title="Login to "apps","') headers.append(name, 'Newauth realm="apps", type=1, title="Login to "apps"') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'newauth', parameters: { realm: 'apps', type: '1', title: 'Login to "apps",' } }, { scheme: 'newauth', parameters: { realm: 'apps', type: '1', title: 'Login to "apps' } }, ]) }
{ const headers = new Headers() headers.append(name, 'Newauth realm="apps", type=1, title="Login to "apps",",') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'newauth', parameters: { realm: 'apps', type: '1', title: 'Login to "apps",' } }, ]) }
{ const headers = new Headers() headers.append(name, 'Newauth realm="apps", type=1, title="Login to "apps",') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'newauth', parameters: { realm: 'apps', type: '1', title: 'Login to "apps' } }, ]) }
{ const headers = new Headers() headers.append(name, 'Newauth realm="apps", type=1, title="Login to "apps","') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'newauth', parameters: { realm: 'apps', type: '1', title: 'Login to "apps",' } }, ]) }
{ const headers = new Headers() headers.append(name, 'Newauth realm="apps", type=1, title="Login to apps=asd"') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'newauth', parameters: { realm: 'apps', type: '1', title: 'Login to apps=asd' } }, ]) }
{ const headers = new Headers() headers.append(name, 'Newauth realm="apps", title="Login to, apps=asd", type=1') t.deepEqual(lib.parseWwwAuthenticateChallenges(response(headers)), [ { scheme: 'newauth', parameters: { realm: 'apps', type: '1', title: 'Login to, apps=asd' } }, ]) }})
oauth4webapi

Version Info

Tagged at
2 years ago