Allow single server instance in test suite (#7262)
* initial pass * reconfigureServer when needed * finish postgres tests * mongo tests * more tests * clean up * re-add skipped test * Fix transaction tests * handle batch * AuthenticationAdapter fix * More reconfiguration * clean up * properly terminate cli servers * handle Parse.Push * Flaky PushController * ensure reconfigureServer when changed * fix postgres tests * remove console.log * LiveQuery spec remove duplicates and listeners
This commit is contained in:
@@ -821,42 +821,42 @@ describe('read-only masterKey', () => {
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
it('properly blocks writes', done => {
|
||||
reconfigureServer({
|
||||
it('properly blocks writes', async () => {
|
||||
await reconfigureServer({
|
||||
readOnlyMasterKey: 'yolo-read-only',
|
||||
})
|
||||
.then(() => {
|
||||
return request({
|
||||
url: `${Parse.serverURL}/classes/MyYolo`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': 'yolo-read-only',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: { foo: 'bar' },
|
||||
});
|
||||
})
|
||||
.then(done.fail)
|
||||
.catch(res => {
|
||||
expect(res.data.code).toBe(Parse.Error.OPERATION_FORBIDDEN);
|
||||
expect(res.data.error).toBe(
|
||||
"read-only masterKey isn't allowed to perform the create operation."
|
||||
);
|
||||
done();
|
||||
});
|
||||
try {
|
||||
await request({
|
||||
url: `${Parse.serverURL}/classes/MyYolo`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': 'yolo-read-only',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: { foo: 'bar' },
|
||||
});
|
||||
fail();
|
||||
} catch (res) {
|
||||
expect(res.data.code).toBe(Parse.Error.OPERATION_FORBIDDEN);
|
||||
expect(res.data.error).toBe(
|
||||
"read-only masterKey isn't allowed to perform the create operation."
|
||||
);
|
||||
}
|
||||
await reconfigureServer();
|
||||
});
|
||||
|
||||
it('should throw when masterKey and readOnlyMasterKey are the same', done => {
|
||||
reconfigureServer({
|
||||
masterKey: 'yolo',
|
||||
readOnlyMasterKey: 'yolo',
|
||||
})
|
||||
.then(done.fail)
|
||||
.catch(err => {
|
||||
expect(err).toEqual(new Error('masterKey and readOnlyMasterKey should be different'));
|
||||
done();
|
||||
it('should throw when masterKey and readOnlyMasterKey are the same', async () => {
|
||||
try {
|
||||
await reconfigureServer({
|
||||
masterKey: 'yolo',
|
||||
readOnlyMasterKey: 'yolo',
|
||||
});
|
||||
fail();
|
||||
} catch (err) {
|
||||
expect(err).toEqual(new Error('masterKey and readOnlyMasterKey should be different'));
|
||||
}
|
||||
await reconfigureServer();
|
||||
});
|
||||
|
||||
it('should throw when trying to create RestWrite', () => {
|
||||
@@ -872,7 +872,7 @@ describe('read-only masterKey', () => {
|
||||
});
|
||||
|
||||
it('should throw when trying to create schema', done => {
|
||||
return request({
|
||||
request({
|
||||
method: 'POST',
|
||||
url: `${Parse.serverURL}/schemas`,
|
||||
headers: {
|
||||
@@ -891,7 +891,7 @@ describe('read-only masterKey', () => {
|
||||
});
|
||||
|
||||
it('should throw when trying to create schema with a name', done => {
|
||||
return request({
|
||||
request({
|
||||
url: `${Parse.serverURL}/schemas/MyClass`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -910,7 +910,7 @@ describe('read-only masterKey', () => {
|
||||
});
|
||||
|
||||
it('should throw when trying to update schema', done => {
|
||||
return request({
|
||||
request({
|
||||
url: `${Parse.serverURL}/schemas/MyClass`,
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
@@ -929,7 +929,7 @@ describe('read-only masterKey', () => {
|
||||
});
|
||||
|
||||
it('should throw when trying to delete schema', done => {
|
||||
return request({
|
||||
request({
|
||||
url: `${Parse.serverURL}/schemas/MyClass`,
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
@@ -948,7 +948,7 @@ describe('read-only masterKey', () => {
|
||||
});
|
||||
|
||||
it('should throw when trying to update the global config', done => {
|
||||
return request({
|
||||
request({
|
||||
url: `${Parse.serverURL}/config`,
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
@@ -967,7 +967,7 @@ describe('read-only masterKey', () => {
|
||||
});
|
||||
|
||||
it('should throw when trying to send push', done => {
|
||||
return request({
|
||||
request({
|
||||
url: `${Parse.serverURL}/push`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user