|
10 | 10 | var request = require('request'); |
11 | 11 | var passwordCrypto = require('../src/password'); |
12 | 12 | var Config = require('../src/Config'); |
| 13 | +const rp = require('request-promise'); |
13 | 14 |
|
14 | 15 | function verifyACL(user) { |
15 | 16 | const ACL = user.getACL(); |
@@ -2131,7 +2132,7 @@ describe('Parse.User testing', () => { |
2131 | 2132 | let database = new Config(Parse.applicationId).database; |
2132 | 2133 | database.create('_User', { |
2133 | 2134 | username: 'user', |
2134 | | - password: '$2a$10$8/wZJyEuiEaobBBqzTG.jeY.XSFJd0rzaN//ososvEI4yLqI.4aie', |
| 2135 | + _hashed_password: '$2a$10$8/wZJyEuiEaobBBqzTG.jeY.XSFJd0rzaN//ososvEI4yLqI.4aie', |
2135 | 2136 | _auth_data_facebook: null |
2136 | 2137 | }, {}).then(() => { |
2137 | 2138 | return new Promise((resolve, reject) => { |
@@ -2258,42 +2259,43 @@ describe('Parse.User testing', () => { |
2258 | 2259 | }); |
2259 | 2260 |
|
2260 | 2261 | it('should fail to become user with expired token', (done) => { |
2261 | | - Parse.User.signUp("auser", "somepass", null, { |
2262 | | - success: function(user) { |
2263 | | - request.get({ |
2264 | | - url: 'http://localhost:8378/1/classes/_Session', |
2265 | | - json: true, |
2266 | | - headers: { |
2267 | | - 'X-Parse-Application-Id': 'test', |
2268 | | - 'X-Parse-Master-Key': 'test', |
2269 | | - }, |
2270 | | - }, (error, response, body) => { |
2271 | | - var id = body.results[0].objectId; |
2272 | | - var expiresAt = new Date((new Date()).setYear(2015)); |
2273 | | - var token = body.results[0].sessionToken; |
2274 | | - request.put({ |
2275 | | - url: "http://localhost:8378/1/classes/_Session/" + id, |
2276 | | - json: true, |
2277 | | - headers: { |
2278 | | - 'X-Parse-Application-Id': 'test', |
2279 | | - 'X-Parse-Master-Key': 'test', |
2280 | | - }, |
2281 | | - body: { |
2282 | | - expiresAt: { __type: "Date", iso: expiresAt.toISOString() }, |
2283 | | - }, |
2284 | | - }, (error, response, body) => { |
2285 | | - Parse.User.become(token) |
2286 | | - .then(() => { fail("Should not have succeded"); }) |
2287 | | - .fail((err) => { |
2288 | | - expect(err.code).toEqual(209); |
2289 | | - expect(err.message).toEqual("Session token is expired."); |
2290 | | - Parse.User.logOut() // Logout to prevent polluting CLI with messages |
2291 | | - .then(done()); |
2292 | | - }); |
2293 | | - }); |
2294 | | - }); |
2295 | | - } |
2296 | | - }); |
| 2262 | + let token; |
| 2263 | + Parse.User.signUp("auser", "somepass", null) |
| 2264 | + .then(user => rp({ |
| 2265 | + method: 'GET', |
| 2266 | + url: 'http://localhost:8378/1/classes/_Session', |
| 2267 | + json: true, |
| 2268 | + headers: { |
| 2269 | + 'X-Parse-Application-Id': 'test', |
| 2270 | + 'X-Parse-Master-Key': 'test', |
| 2271 | + }, |
| 2272 | + })) |
| 2273 | + .then(body => { |
| 2274 | + var id = body.results[0].objectId; |
| 2275 | + var expiresAt = new Date((new Date()).setYear(2015)); |
| 2276 | + token = body.results[0].sessionToken; |
| 2277 | + return rp({ |
| 2278 | + method: 'PUT', |
| 2279 | + url: "http://localhost:8378/1/classes/_Session/" + id, |
| 2280 | + json: true, |
| 2281 | + headers: { |
| 2282 | + 'X-Parse-Application-Id': 'test', |
| 2283 | + 'X-Parse-Master-Key': 'test', |
| 2284 | + }, |
| 2285 | + body: { |
| 2286 | + expiresAt: { __type: "Date", iso: expiresAt.toISOString() }, |
| 2287 | + }, |
| 2288 | + }) |
| 2289 | + }) |
| 2290 | + .then(() => Parse.User.become(token)) |
| 2291 | + .then(() => { |
| 2292 | + fail("Should not have succeded") |
| 2293 | + done(); |
| 2294 | + }, error => { |
| 2295 | + expect(error.code).toEqual(209); |
| 2296 | + expect(error.message).toEqual("Session token is expired."); |
| 2297 | + done(); |
| 2298 | + }) |
2297 | 2299 | }); |
2298 | 2300 |
|
2299 | 2301 | it('should not create extraneous session tokens', (done) => { |
|
0 commit comments