-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc46b13
commit ccc6fb8
Showing
5 changed files
with
100 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
'use strict'; | ||
|
||
const { mwn, expect, verifyTokenAndSiteInfo } = require('./test_base'); | ||
|
||
const oauthCredentials = require('./mocking/loginCredentials.js').account1_oauth2; | ||
|
||
let bot = new mwn({ | ||
...oauthCredentials, | ||
}); | ||
|
||
bot.initOAuth(); | ||
|
||
describe('OAuth 2', async function () { | ||
it('gets tokens (GET request)', function () { | ||
return bot.getTokensAndSiteInfo().then(() => { | ||
verifyTokenAndSiteInfo(bot); | ||
}); | ||
}); | ||
|
||
it('gets a token (POST request)', function () { | ||
return bot | ||
.request( | ||
{ | ||
action: 'query', | ||
meta: 'tokens', | ||
type: 'csrf', | ||
}, | ||
{ | ||
method: 'post', | ||
} | ||
) | ||
.then((data) => { | ||
expect(data.query.tokens.csrftoken.length).to.be.gt(10); | ||
}); | ||
}); | ||
|
||
it('purges a page (has to be POST request)', function () { | ||
return bot.purge([11791]).then(function (response) { | ||
expect(response).to.be.instanceOf(Array); | ||
expect(response[0].purged).to.equal(true); | ||
}); | ||
}); | ||
|
||
it('gets a token (multipart/form-data POST request)', function () { | ||
return bot | ||
.request( | ||
{ | ||
action: 'query', | ||
meta: 'tokens', | ||
type: 'csrf', | ||
}, | ||
{ | ||
method: 'post', | ||
headers: { | ||
'Content-Type': 'multipart/form-data', | ||
}, | ||
} | ||
) | ||
.then((data) => { | ||
expect(data.query.tokens.csrftoken.length).to.be.gt(10); | ||
}); | ||
}); | ||
|
||
it('gets a page text', function () { | ||
return bot | ||
.request({ | ||
action: 'query', | ||
titles: 'Main Page', | ||
}) | ||
.then((data) => { | ||
expect(data.query.pages[0].title).to.be.a('string'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters