/** * Delete the plugin * * @param {object} [query] - query object parameter * @param {Function} [fn] - callback function * @returns {Promise} Promise */ delete( query, fn ) { return this.wpcom.req.put( `${ this.pluginPath }/delete`, query, fn ); }
net.put("/interface/merge",{ id:id }).then(function (data) { if(data.code==200) { context.dispatch("refreshData",data.data); } return data; })
it('should find un-expired records', (done) => { const cache = new RedisCacheAdapter(null, 5); cache .put(KEY, VALUE) .then(() => cache.get(KEY)) .then((value) => expect(value).toEqual(VALUE)) .then(wait.bind(null, 1)) .then(() => cache.get(KEY)) .then((value) => expect(value).not.toEqual(null)) .then(done); });
router.put('/users/:userId', (req, res) => { const user = getUser(req.params.userId) if (!user) return res.status(404).json({}) user.name = req.body.name res.json(user) })
it('should succeed if xff header with one ip does belong to masterKeyIps', (done) => { AppCache.put(fakeReq.body._ApplicationId, { masterKey: 'masterKey', masterKeyIps: ['ip1'], }); fakeReq.headers['x-parse-master-key'] = 'masterKey'; fakeReq.headers['x-forwarded-for'] = 'ip1'; middlewares.handleParseHeaders(fakeReq, fakeRes, () => { expect(fakeRes.status).not.toHaveBeenCalled(); done(); }); });
static linkUser(id, data) { ApiActions.put( `/api/admins/${id}/user`, data, Store, Constants.LINK_USER, Constants.LINK_USER_RESPONSE ); }
it('should use user provided on field userFromJWT', (done) => { AppCache.put(fakeReq.body._ApplicationId, { masterKey: 'masterKey', }); fakeReq.userFromJWT = 'fake-user'; middlewares.handleParseHeaders(fakeReq, fakeRes, () => { expect(fakeReq.auth.user).toEqual('fake-user'); done(); }); });
it('should succeed when any one of the configured keys supplied', (done) => { AppCache.put(fakeReq.body._ApplicationId, { clientKey: 'clientKey', masterKey: 'masterKey', restAPIKey: 'restAPIKey', }); fakeReq.headers['x-parse-rest-api-key'] = 'restAPIKey'; middlewares.handleParseHeaders(fakeReq, fakeRes, () => { expect(fakeRes.status).not.toHaveBeenCalled(); done(); }); });
/** * Edit post * * @param {object} [query] - query object parameter * @param {object} body - body object parameter * @param {Function} fn - callback function * @returns {Function} request handler */ update( query, body, fn ) { return this.wpcom.req.put( this.getPostPath(), query, body, fn ); }
it('should not succeed if the socket.remoteAddress does not belong to masterKeyIps list', () => { AppCache.put(fakeReq.body._ApplicationId, { masterKey: 'masterKey', masterKeyIps: ['ip1', 'ip2'], }); fakeReq.socket = { remoteAddress: 'ip3' }; fakeReq.headers['x-parse-master-key'] = 'masterKey'; middlewares.handleParseHeaders(fakeReq, fakeRes); expect(fakeRes.status).toHaveBeenCalledWith(403); });
/** * Update site-settings * * @param {object} [query] - query object parameter * @param {object} body - body object parameter * @param {Function} fn - callback function * @returns {Function} request handler */ update( query, body, fn ) { return this.wpcom.req.put( this.path, query, body, fn ); }
it('should succeed if the ip does belong to masterKeyIps list', (done) => { AppCache.put(fakeReq.body._ApplicationId, { masterKey: 'masterKey', masterKeyIps: ['ip1', 'ip2'], }); fakeReq.ip = 'ip1'; fakeReq.headers['x-parse-master-key'] = 'masterKey'; middlewares.handleParseHeaders(fakeReq, fakeRes, () => { expect(fakeRes.status).not.toHaveBeenCalled(); done(); }); });
it('should succeed if the connection.socket.remoteAddress does belong to masterKeyIps list', (done) => { AppCache.put(fakeReq.body._ApplicationId, { masterKey: 'masterKey', masterKeyIps: ['ip1', 'ip2'], }); fakeReq.connection = { socket: { remoteAddress: 'ip1' } }; fakeReq.headers['x-parse-master-key'] = 'masterKey'; middlewares.handleParseHeaders(fakeReq, fakeRes, () => { expect(fakeRes.status).not.toHaveBeenCalled(); done(); }); });
router.put('/users/:userId', (req, res) => { const user = getUser(req.params.userId) if (!user) return res.status(404).json({}) user.name = req.body.name res.json(user) })
/** * Update the plugin version * * @param {object} [query] - query object parameter * @param {Function} [fn] - callback function * @returns {Promise} Promise */ updateVersion( query, fn ) { return this.wpcom.req.put( `${ this.pluginPath }/update`, query, fn ); }