Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5963022
ext.centralauth.ForeignApi.test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ext.centralauth.ForeignApi.test.js
View Options
QUnit
.
module
(
'ext.centralauth.ForeignApi'
,
QUnit
.
newMwEnvironment
(
{
beforeEach
:
function
()
{
this
.
server
=
this
.
sandbox
.
useFakeServer
();
this
.
server
.
respondImmediately
=
true
;
}
}
)
);
QUnit
.
test
(
'Anonymous users do not get centralauthtoken'
,
function
(
assert
)
{
mw
.
config
.
set
(
'wgUserName'
,
null
);
this
.
server
.
respond
(
function
(
request
)
{
request
.
respond
(
200
,
{
'Content-Type'
:
'application/json'
},
'[]'
);
}
);
var
api
=
new
mw
.
ForeignApi
(
'//localhost:4242/w/api.php'
);
var
spy
=
this
.
sandbox
.
spy
(
api
,
'getCentralAuthToken'
);
return
api
.
get
(
{}
).
then
(
function
()
{
assert
.
false
(
spy
.
called
,
'Not called'
);
}
);
}
);
QUnit
.
test
(
'Logged in users get centralauthtoken if not logged in remotely'
,
function
(
assert
)
{
mw
.
config
.
set
(
'wgUserName'
,
'User'
);
this
.
sandbox
.
stub
(
mw
.
ForeignApi
.
prototype
,
'checkForeignLogin'
).
returns
(
$
.
Deferred
().
reject
()
);
this
.
server
.
respond
(
function
(
request
)
{
request
.
respond
(
200
,
{
'Content-Type'
:
'application/json'
},
'[]'
);
}
);
var
api
=
new
mw
.
ForeignApi
(
'//localhost:4242/w/api.php'
);
var
spy
=
this
.
sandbox
.
stub
(
api
,
'getCentralAuthToken'
).
returns
(
$
.
Deferred
().
resolve
(
'CENTRALAUTHTOKEN'
)
);
return
api
.
get
(
{}
).
then
(
function
()
{
assert
.
true
(
spy
.
called
,
'Called'
);
}
);
}
);
QUnit
.
test
(
'Logged in users do not get centralauthtoken if logged in remotely'
,
function
(
assert
)
{
mw
.
config
.
set
(
'wgUserName'
,
'User'
);
this
.
sandbox
.
stub
(
mw
.
ForeignApi
.
prototype
,
'checkForeignLogin'
).
returns
(
$
.
Deferred
().
resolve
()
);
this
.
server
.
respond
(
function
(
request
)
{
request
.
respond
(
200
,
{
'Content-Type'
:
'application/json'
},
'[]'
);
}
);
var
api
=
new
mw
.
ForeignApi
(
'//localhost:4242/w/api.php'
);
var
spy
=
this
.
sandbox
.
stub
(
api
,
'getCentralAuthToken'
).
returns
(
$
.
Deferred
().
resolve
(
'CENTRALAUTHTOKEN'
)
);
return
api
.
get
(
{}
).
then
(
function
()
{
assert
.
false
(
spy
.
called
,
'Called'
);
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 3, 09:21 (1 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
cd/04/04bb90fbb2d4235c99c43c32413e
Default Alt Text
ext.centralauth.ForeignApi.test.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment