mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
handle auth fails
This commit is contained in:
parent
88b3d99fbd
commit
16f3ebb3ba
2 changed files with 4 additions and 4 deletions
|
@ -450,6 +450,7 @@ exports.handle = function(apiVersion, functionName, fields, req, res)
|
||||||
|
|
||||||
if(fields["apikey"] != apikey.trim())
|
if(fields["apikey"] != apikey.trim())
|
||||||
{
|
{
|
||||||
|
res.statusCode = 401;
|
||||||
res.send({code: 4, message: "no or wrong API Key", data: null});
|
res.send({code: 4, message: "no or wrong API Key", data: null});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,9 @@ describe('Permission', function(){
|
||||||
it('errors if can connect without correct APIKey', function(done) {
|
it('errors if can connect without correct APIKey', function(done) {
|
||||||
// This is broken because Etherpad doesn't handle HTTP codes properly see #2343
|
// This is broken because Etherpad doesn't handle HTTP codes properly see #2343
|
||||||
// If your APIKey is password you deserve to fail all tests anyway
|
// If your APIKey is password you deserve to fail all tests anyway
|
||||||
throw new Error("Erroring anyway just because the API seems broken here");
|
var permErrorURL = '/api/'+apiVersion+'/createPad?apikey=password&padID=test';
|
||||||
api.get('/api/'+apiVersion+'/createPad&apikey=password&padID=test')
|
api.get(permErrorURL)
|
||||||
.expect('Content-Type', /json/)
|
.expect(401, done)
|
||||||
.expect(200, done)
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue