2016-03-01 16:03:37 -08:00
|
|
|
'use strict';
|
|
|
|
|
|
2018-09-24 17:07:51 -04:00
|
|
|
const request = require('../lib/request');
|
2016-03-01 07:35:28 -08:00
|
|
|
|
|
|
|
|
describe('features', () => {
|
2019-06-03 23:58:21 +02:00
|
|
|
it('should return the serverInfo', async () => {
|
|
|
|
|
const response = await request({
|
2018-09-24 17:07:51 -04:00
|
|
|
url: 'http://localhost:8378/1/serverInfo',
|
|
|
|
|
json: true,
|
|
|
|
|
headers: {
|
|
|
|
|
'X-Parse-Application-Id': 'test',
|
|
|
|
|
'X-Parse-REST-API-Key': 'rest',
|
2019-06-03 23:58:21 +02:00
|
|
|
'X-Parse-Master-Key': 'test',
|
2018-09-01 13:58:06 -04:00
|
|
|
},
|
2019-06-03 23:58:21 +02:00
|
|
|
});
|
|
|
|
|
const data = response.data;
|
|
|
|
|
expect(data).toBeDefined();
|
|
|
|
|
expect(data.features).toBeDefined();
|
|
|
|
|
expect(data.parseServerVersion).toBeDefined();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('requires the master key to get features', async done => {
|
2025-11-23 13:51:42 +01:00
|
|
|
const logger = require('../lib/logger').default;
|
|
|
|
|
const loggerErrorSpy = spyOn(logger, 'error').and.callThrough();
|
|
|
|
|
loggerErrorSpy.calls.reset();
|
2019-06-03 23:58:21 +02:00
|
|
|
try {
|
|
|
|
|
await request({
|
|
|
|
|
url: 'http://localhost:8378/1/serverInfo',
|
|
|
|
|
json: true,
|
|
|
|
|
headers: {
|
|
|
|
|
'X-Parse-Application-Id': 'test',
|
|
|
|
|
'X-Parse-REST-API-Key': 'rest',
|
|
|
|
|
},
|
|
|
|
|
});
|
2020-10-25 15:06:58 -05:00
|
|
|
done.fail('The serverInfo request should be rejected without the master key');
|
2019-06-03 23:58:21 +02:00
|
|
|
} catch (error) {
|
|
|
|
|
expect(error.status).toEqual(403);
|
2025-11-23 13:51:42 +01:00
|
|
|
expect(error.data.error).toEqual('Permission denied');
|
|
|
|
|
expect(loggerErrorSpy).toHaveBeenCalledWith('Sanitized error:', jasmine.stringContaining('unauthorized: master key is required'));
|
2018-09-24 17:07:51 -04:00
|
|
|
done();
|
2019-06-03 23:58:21 +02:00
|
|
|
}
|
2016-03-01 16:03:37 -08:00
|
|
|
});
|
2016-03-01 07:35:28 -08:00
|
|
|
});
|