|
3 | 3 | //
|
4 | 4 |
|
5 | 5 | 'use strict';
|
| 6 | +const request = require('../lib/request'); |
6 | 7 |
|
7 | 8 | function setupTestUsers() {
|
8 | 9 | const user1 = new Parse.User();
|
@@ -135,4 +136,31 @@ describe('Parse.Session', () => {
|
135 | 136 | fail(err);
|
136 | 137 | });
|
137 | 138 | });
|
| 139 | + |
| 140 | + it('cannot edit session with known ID', async () => { |
| 141 | + await setupTestUsers(); |
| 142 | + const [first, second] = await new Parse.Query(Parse.Session).find({ useMasterKey: true }); |
| 143 | + const headers = { |
| 144 | + 'X-Parse-Application-Id': 'test', |
| 145 | + 'X-Parse-Rest-API-Key': 'rest', |
| 146 | + 'X-Parse-Session-Token': second.get('sessionToken'), |
| 147 | + 'Content-Type': 'application/json', |
| 148 | + }; |
| 149 | + const firstUser = first.get('user').id; |
| 150 | + const secondUser = second.get('user').id; |
| 151 | + const e = await request({ |
| 152 | + method: 'PUT', |
| 153 | + headers, |
| 154 | + url: `http://localhost:8378/1/sessions/${first.id}`, |
| 155 | + body: JSON.stringify({ |
| 156 | + foo: 'bar', |
| 157 | + user: { __type: 'Pointer', className: '_User', objectId: secondUser }, |
| 158 | + }), |
| 159 | + }).catch(e => e.data); |
| 160 | + expect(e.code).toBe(Parse.Error.OBJECT_NOT_FOUND); |
| 161 | + expect(e.error).toBe('Object not found.'); |
| 162 | + await Parse.Object.fetchAll([first, second], { useMasterKey: true }); |
| 163 | + expect(first.get('user').id).toBe(firstUser); |
| 164 | + expect(second.get('user').id).toBe(secondUser); |
| 165 | + }); |
138 | 166 | });
|
0 commit comments