ti2 1.0.114 → 1.0.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -106,10 +106,10 @@ describe('user: bookings controller', () => {
106
106
  token: userToken,
107
107
  payload,
108
108
  });
109
- expect(plugins[0].searchHotelBooking).toHaveBeenCalled();
109
+ expect(plugins[0].searchItineraries).toHaveBeenCalled();
110
110
  expect(Array.isArray(bookings)).toBeTruthy();
111
- expect(plugins[0].searchHotelBooking.mock.calls[0][0].payload).toEqual(payload);
112
- expect(plugins[0].searchHotelBooking.mock.calls[0][0].token).toEqual(token);
111
+ expect(plugins[0].searchItineraries.mock.calls[0][0].payload).toEqual(payload);
112
+ expect(plugins[0].searchItineraries.mock.calls[0][0].token).toEqual(token);
113
113
  });
114
114
 
115
115
  });
@@ -222,6 +222,19 @@ describe('user', () => {
222
222
  expect(plugins[0].validateToken.mock.calls[0][0].payload).toEqual({
223
223
  tokenHint: apiKey.split('-')[0],
224
224
  });
225
+ expect(plugins[0].validateToken.mock.calls[0][0].userId).toBe(userId);
226
+ expect(plugins[0].validateToken.mock.calls[0][0].hint).toBe(apiKey.split('-')[0]);
227
+ });
228
+ it('testing the user token should not infer a hint when no hint is provided', async () => {
229
+ const { valid } = await doApiPost({
230
+ url: `/${appName}/${userId}/validate`,
231
+ token: userKey,
232
+ payload: {},
233
+ });
234
+ expect(plugins[0].validateToken).toHaveBeenCalled();
235
+ expect(valid).toBe(true);
236
+ expect(plugins[0].validateToken.mock.calls[0][0].userId).toBe(userId);
237
+ expect(plugins[0].validateToken.mock.calls[0][0].hint).toBeUndefined();
225
238
  });
226
239
  it('should be able to delete an app settings', async () => {
227
240
  const returnValue = await doApiDelete({
@@ -261,6 +261,8 @@ const validateAppToken = plugins => async (req, res, next) => {
261
261
  axios,
262
262
  token,
263
263
  payload: req.body,
264
+ userId,
265
+ hint,
264
266
  requestId: req.requestId,
265
267
  });
266
268
  return res.json({ valid });
@@ -52,7 +52,8 @@ const bookingsSearch = plugins => async (req, res, next) => {
52
52
  try {
53
53
  const { app, token } = await getAppAndToken({ plugins, appKey, userId, hint });
54
54
  assert(app.searchItineraries || app.searchHotelBooking || app.searchBooking, `searchItineraries or searchHotelBooking or searchBooking is not available for ${appKey}`);
55
- const search = (app.searchHotelBooking || app.searchBooking || app.searchItineraries).bind(app);
55
+ // Prefer the dedicated itinerary endpoint so date/filter payloads used by mining are preserved.
56
+ const search = (app.searchItineraries || app.searchHotelBooking || app.searchBooking).bind(app);
56
57
  const results = await search({
57
58
  axios,
58
59
  token,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2",
3
- "version": "1.0.114",
3
+ "version": "1.0.115",
4
4
  "description": "Tourist Industry Exchange (TI2)",
5
5
  "main": "index.js",
6
6
  "scripts": {