@budibase/worker 3.18.1 → 3.18.2

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/worker",
3
3
  "email": "hi@budibase.com",
4
- "version": "3.18.1",
4
+ "version": "3.18.2",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -109,5 +109,5 @@
109
109
  }
110
110
  }
111
111
  },
112
- "gitHead": "cac7191488dabe0144f8f427686875c91cc7a548"
112
+ "gitHead": "43d59f5579dd910575d8aebefb40fae25570c05d"
113
113
  }
@@ -17,10 +17,14 @@ import nock from "nock"
17
17
  import * as jwt from "jsonwebtoken"
18
18
 
19
19
  function getAuthCookie(response: Response) {
20
- return response.headers["set-cookie"]
21
- .find((s: string) => s.startsWith(`${constants.Cookie.Auth}=`))
22
- .split("=")[1]
23
- .split(";")[0]
20
+ const cookies = response.headers["set-cookie"]
21
+ if (!cookies) throw new Error("No cookies found")
22
+ const cookieArray = Array.isArray(cookies) ? cookies : [cookies]
23
+ const authCookie = cookieArray.find((s: string) =>
24
+ s.startsWith(`${constants.Cookie.Auth}=`)
25
+ )
26
+ if (!authCookie) throw new Error("No auth cookie found")
27
+ return authCookie.split("=")[1].split(";")[0]
24
28
  }
25
29
 
26
30
  const expectSetAuthCookie = (response: Response) => {
@@ -302,9 +306,10 @@ describe("/api/global/auth", () => {
302
306
  const res = await config.api.configs.getOIDCConfig(configId)
303
307
 
304
308
  expect(res.status).toBe(302)
305
- const location: string = res.get("location")
309
+ const location = res.get("location")
310
+ expect(location).toBeDefined()
306
311
  expect(
307
- location.startsWith(
312
+ location!.startsWith(
308
313
  `http://example.com/auth?response_type=code&client_id=clientId&redirect_uri=http%3A%2F%2Flocalhost%3A10000%2Fapi%2Fglobal%2Fauth%2F${config.tenantId}%2Foidc%2Fcallback&scope=openid%20profile%20email%20offline_access`
309
314
  )
310
315
  ).toBe(true)
@@ -356,7 +361,7 @@ describe("/api/global/auth", () => {
356
361
  expect(events.auth.login).toHaveBeenCalledWith("oidc", email)
357
362
  expect(events.auth.login).toHaveBeenCalledTimes(1)
358
363
  expect(res.status).toBe(302)
359
- const location: string = res.get("location")
364
+ const location = res.get("location")
360
365
  expect(location).toBe("/")
361
366
  expectSetAuthCookie(res)
362
367
  })