Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: LayoutTests/http/tests/fetch/script-tests/fetch-access-control-auth.js

Issue 1267263003: Rename fetch layout tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 if (self.importScripts) {
2 importScripts('../resources/fetch-test-helpers.js');
3 importScripts('../resources/fetch-access-control-util.js');
4 }
5
6 var TEST_TARGETS = [
7 // Auth check
8 [BASE_URL + 'Auth&mode=same-origin&credentials=omit',
9 [fetchResolved, hasBody], [checkJsonpError]],
10 [BASE_URL + 'Auth&mode=same-origin&credentials=include',
11 [fetchResolved, hasBody], [authCheck1]],
12 [BASE_URL + 'Auth&mode=same-origin&credentials=same-origin',
13 [fetchResolved, hasBody], [authCheck1]],
14
15 [BASE_URL + 'Auth&mode=cors&credentials=omit',
16 [fetchResolved, hasBody], [checkJsonpError]],
17 [BASE_URL + 'Auth&mode=cors&credentials=include',
18 [fetchResolved, hasBody], [authCheck1]],
19 [BASE_URL + 'Auth&mode=cors&credentials=same-origin',
20 [fetchResolved, hasBody], [authCheck1]],
21
22 [OTHER_BASE_URL + 'Auth&mode=same-origin&credentials=omit',
23 [fetchRejected]],
24 [OTHER_BASE_URL + 'Auth&mode=same-origin&credentials=include',
25 [fetchRejected]],
26 [OTHER_BASE_URL + 'Auth&mode=same-origin&credentials=same-origin',
27 [fetchRejected]],
28
29 // CORS check tests
30 // Spec: https://fetch.spec.whatwg.org/#concept-cors-check
31
32 // If origin is null or failure, return failure.
33 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=omit',
34 [fetchRejected]],
35 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include',
36 [fetchRejected]],
37 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=same-origin',
38 [fetchRejected]],
39
40 // If credentials mode is not include,
41 // success if ACAOrigin is * or request's origin, or failure otherwise.
42 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=omit&ACAOrigin=*',
43 [fetchResolved, hasBody], [checkJsonpError]],
44 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=omit&ACAOrigin=' +
45 BASE_ORIGIN,
46 [fetchResolved, hasBody], [checkJsonpError]],
47 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=omit&ACAOrigin=http://www.exampl e.com',
48 [fetchRejected]],
49
50 // If credentials mode is include,
51 // success if ACAOrigin is request's origin and ACACredentials=true,
52 // or failure otherwise.
53 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&ACAOrigin=*',
54 [fetchRejected]],
55 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&ACAOrigin=' +
56 BASE_ORIGIN,
57 [fetchRejected]],
58 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&ACAOrigin=http://www.exa mple.com',
59 [fetchRejected]],
60 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&ACAOrigin=*&ACACredentia ls=true',
61 [fetchRejected]],
62 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&ACAOrigin=' +
63 BASE_ORIGIN + '&ACACredentials=true',
64 [fetchResolved, hasBody, typeCors], [authCheck2]],
65 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&ACAOrigin=http://www.exa mple.com&ACACredentials=true',
66 [fetchRejected]],
67
68 // Test that Access-Control-Allow-Credentials is case-sensitive.
69 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&ACAOrigin=' +
70 BASE_ORIGIN + '&ACACredentials=True',
71 [fetchRejected]],
72
73 // If credentials mode is not include,
74 // success if ACAOrigin is * or request's origin, or failure otherwise.
75 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=same-origin&ACAOrigin=*',
76 [fetchResolved, hasBody], [checkJsonpError]],
77 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=same-origin&ACAOrigin=' +
78 BASE_ORIGIN,
79 [fetchResolved, hasBody], [checkJsonpError]],
80 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=same-origin&ACAOrigin=http://www .example.com',
81 [fetchRejected]],
82
83 // Credential check with CORS preflight.
84
85 // Resolved because Authentication is not applied to CORS preflight.
86 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=omit&ACAOrigin=*&PACAOrigin=*&me thod=PUT&PACAMethods=PUT&PreflightTest=200',
87 [fetchResolved, hasBody], [checkJsonpError]],
88 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=same-origin&ACAOrigin=*&PACAOrig in=*&method=PUT&PACAMethods=PUT&PreflightTest=200',
89 [fetchResolved, hasBody], [checkJsonpError]],
90 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&ACAOrigin=' +
91 BASE_ORIGIN + '&PACAOrigin=' + BASE_ORIGIN +
92 '&ACACredentials=true&PACACredentials=true&method=PUT&PACAMethods=PUT&Preflig htTest=200',
93 [fetchResolved, hasBody, typeCors], [authCheck2]],
94
95 // Rejected because CORS preflight response returns 401.
96 [OTHER_BASE_URL + 'PAuth&mode=cors&credentials=omit&ACAOrigin=*&PACAOrigin=*&m ethod=PUT&PACAMethods=PUT&PreflightTest=200',
97 [fetchRejected]],
98 [OTHER_BASE_URL + 'PAuth&mode=cors&credentials=same-origin&ACAOrigin=*&pACAOri gin=*&method=PUT&PACAMethods=PUT&PreflightTest=200',
99 [fetchRejected]],
100 [OTHER_BASE_URL + 'PAuth&mode=cors&credentials=include&ACAOrigin=' +
101 BASE_ORIGIN + '&PACAOrigin=' + BASE_ORIGIN +
102 '&ACACredentials=true&PACACredentials=true&method=PUT&PACAMethods=PUT&Preflig htTest=200',
103 [fetchRejected]],
104
105 // Check that Access-Control-Allow-Origin/Access-Control-Allow-Credentials
106 // headers are checked in both CORS preflight and main fetch.
107 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&ACAOrigin=' +
108 BASE_ORIGIN +
109 '&ACACredentials=true&PACACredentials=true&method=PUT&PACAMethods=PUT&Preflig htTest=200',
110 [fetchRejected]],
111 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&PACAOrigin=' +
112 BASE_ORIGIN +
113 '&ACACredentials=true&PACACredentials=true&method=PUT&PACAMethods=PUT&Preflig htTest=200',
114 [fetchRejected]],
115 [OTHER_BASE_URL +
116 'Auth&mode=cors&credentials=include&ACAOrigin=*&PACAOrigin=' + BASE_ORIGIN +
117 '&ACACredentials=true&PACACredentials=true&method=PUT&PACAMethods=PUT&Preflig htTest=200',
118 [fetchRejected]],
119 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&ACAOrigin=' +
120 BASE_ORIGIN +
121 '&PACAOrigin=*&ACACredentials=true&PACACredentials=true&method=PUT&PACAMethod s=PUT&PreflightTest=200',
122 [fetchRejected]],
123 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&ACAOrigin=' +
124 BASE_ORIGIN + '&PACAOrigin=' + BASE_ORIGIN +
125 '&ACACredentials=true&method=PUT&PACAMethods=PUT&PreflightTest=200',
126 [fetchRejected]],
127 [OTHER_BASE_URL + 'Auth&mode=cors&credentials=include&ACAOrigin=' +
128 BASE_ORIGIN + '&PACAOrigin=' + BASE_ORIGIN +
129 '&PACACredentials=true&method=PUT&PACAMethods=PUT&PreflightTest=200',
130 [fetchRejected]],
131 ];
132
133 if (self.importScripts) {
134 executeTests(TEST_TARGETS);
135 done();
136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698