Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4122254
mediawiki.ForeignApi.test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
mediawiki.ForeignApi.test.js
View Options
QUnit
.
module
(
'mediawiki.ForeignApi'
,
(
hooks
)
=>
{
const
CoreForeignApi
=
require
(
'mediawiki.ForeignApi.core'
).
ForeignApi
;
hooks
.
beforeEach
(
function
()
{
this
.
server
=
this
.
sandbox
.
useFakeServer
();
this
.
server
.
respondImmediately
=
true
;
}
);
QUnit
.
test
(
'origin is included in GET requests'
,
function
(
assert
)
{
const
api
=
new
CoreForeignApi
(
'//localhost:4242/w/api.php'
);
this
.
server
.
respond
(
(
request
)
=>
{
assert
.
true
(
/origin=/
.
test
(
request
.
url
),
'origin is included in GET requests'
);
request
.
respond
(
200
,
{
'Content-Type'
:
'application/json'
},
'[]'
);
}
);
return
api
.
get
(
{}
);
}
);
QUnit
.
test
(
'origin is included in POST requests'
,
function
(
assert
)
{
const
api
=
new
CoreForeignApi
(
'//localhost:4242/w/api.php'
);
this
.
server
.
respond
(
(
request
)
=>
{
assert
.
true
(
/origin=/
.
test
(
request
.
requestBody
),
'origin is included in POST request body'
);
assert
.
true
(
/origin=/
.
test
(
request
.
url
),
'origin is included in POST request URL, too'
);
request
.
respond
(
200
,
{
'Content-Type'
:
'application/json'
},
'[]'
);
}
);
return
api
.
post
(
{}
);
}
);
QUnit
.
test
(
'origin is not included in same-origin GET requests'
,
function
(
assert
)
{
const
apiUrl
=
location
.
protocol
+
'//'
+
location
.
host
+
'/w/api.php'
,
api
=
new
CoreForeignApi
(
apiUrl
);
this
.
server
.
respond
(
(
request
)
=>
{
assert
.
strictEqual
(
request
.
url
.
match
(
/origin=.*?(?:&|$)/
),
null
,
'origin is not included in GET requests'
);
request
.
respond
(
200
,
{
'Content-Type'
:
'application/json'
},
'[]'
);
}
);
return
api
.
get
(
{}
);
}
);
QUnit
.
test
(
'origin is not included in same-origin POST requests'
,
function
(
assert
)
{
const
apiUrl
=
location
.
protocol
+
'//'
+
location
.
host
+
'/w/api.php'
,
api
=
new
CoreForeignApi
(
apiUrl
);
this
.
server
.
respond
(
(
request
)
=>
{
assert
.
strictEqual
(
request
.
requestBody
.
match
(
/origin=.*?(?:&|$)/
),
null
,
'origin is not included in POST request body'
);
assert
.
strictEqual
(
request
.
url
.
match
(
/origin=.*?(?:&|$)/
),
null
,
'origin is not included in POST request URL, either'
);
request
.
respond
(
200
,
{
'Content-Type'
:
'application/json'
},
'[]'
);
}
);
return
api
.
post
(
{}
);
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 19, 05:15 (1 d, 17 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
78/75/816e391fdbb192d6d0422f58a16b
Default Alt Text
mediawiki.ForeignApi.test.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment