@budibase/server 2.4.44-alpha.7 → 2.4.44-alpha.8

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/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.4.44-alpha.7",
4
+ "version": "2.4.44-alpha.8",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -44,12 +44,12 @@
44
44
  "license": "GPL-3.0",
45
45
  "dependencies": {
46
46
  "@apidevtools/swagger-parser": "10.0.3",
47
- "@budibase/backend-core": "2.4.44-alpha.7",
48
- "@budibase/client": "2.4.44-alpha.7",
49
- "@budibase/pro": "2.4.44-alpha.6",
50
- "@budibase/shared-core": "2.4.44-alpha.7",
51
- "@budibase/string-templates": "2.4.44-alpha.7",
52
- "@budibase/types": "2.4.44-alpha.7",
47
+ "@budibase/backend-core": "2.4.44-alpha.8",
48
+ "@budibase/client": "2.4.44-alpha.8",
49
+ "@budibase/pro": "2.4.44-alpha.7",
50
+ "@budibase/shared-core": "2.4.44-alpha.8",
51
+ "@budibase/string-templates": "2.4.44-alpha.8",
52
+ "@budibase/types": "2.4.44-alpha.8",
53
53
  "@bull-board/api": "3.7.0",
54
54
  "@bull-board/koa": "3.9.4",
55
55
  "@elastic/elasticsearch": "7.10.0",
@@ -174,5 +174,5 @@
174
174
  "optionalDependencies": {
175
175
  "oracledb": "5.3.0"
176
176
  },
177
- "gitHead": "a43e7fab7056a6be54f056b0c7aca083ce490b52"
177
+ "gitHead": "104f6ac507d12cd6a9a846badb26790f1469e0ba"
178
178
  }
@@ -57,6 +57,7 @@ describe("/users", () => {
57
57
  it("should be able to update the user", async () => {
58
58
  const user = await config.createUser({ id: `us_update${utils.newid()}` })
59
59
  user.roleId = BUILTIN_ROLE_IDS.BASIC
60
+ delete user._rev
60
61
  const res = await request
61
62
  .put(`/api/users/metadata`)
62
63
  .set(config.defaultHeaders())
@@ -65,6 +66,46 @@ describe("/users", () => {
65
66
  .expect("Content-Type", /json/)
66
67
  expect(res.body.ok).toEqual(true)
67
68
  })
69
+
70
+ it("should be able to update the user multiple times", async () => {
71
+ const user = await config.createUser()
72
+ delete user._rev
73
+
74
+ const res1 = await request
75
+ .put(`/api/users/metadata`)
76
+ .set(config.defaultHeaders())
77
+ .send({ ...user, roleId: BUILTIN_ROLE_IDS.BASIC })
78
+ .expect(200)
79
+ .expect("Content-Type", /json/)
80
+
81
+ const res = await request
82
+ .put(`/api/users/metadata`)
83
+ .set(config.defaultHeaders())
84
+ .send({ ...user, _rev: res1.body.rev, roleId: BUILTIN_ROLE_IDS.POWER })
85
+ .expect(200)
86
+ .expect("Content-Type", /json/)
87
+
88
+ expect(res.body.ok).toEqual(true)
89
+ })
90
+
91
+ it("should require the _rev field for multiple updates", async () => {
92
+ const user = await config.createUser()
93
+ delete user._rev
94
+
95
+ await request
96
+ .put(`/api/users/metadata`)
97
+ .set(config.defaultHeaders())
98
+ .send({ ...user, roleId: BUILTIN_ROLE_IDS.BASIC })
99
+ .expect(200)
100
+ .expect("Content-Type", /json/)
101
+
102
+ await request
103
+ .put(`/api/users/metadata`)
104
+ .set(config.defaultHeaders())
105
+ .send({ ...user, roleId: BUILTIN_ROLE_IDS.POWER })
106
+ .expect(409)
107
+ .expect("Content-Type", /json/)
108
+ })
68
109
  })
69
110
 
70
111
  describe("destroy", () => {
@@ -92,6 +133,7 @@ describe("/users", () => {
92
133
  expect(res.body.tableId).toBeDefined()
93
134
  })
94
135
  })
136
+
95
137
  describe("setFlag", () => {
96
138
  it("should throw an error if a flag is not provided", async () => {
97
139
  await config.createUser()
@@ -101,8 +143,9 @@ describe("/users", () => {
101
143
  .send({ value: "test" })
102
144
  .expect(400)
103
145
  .expect("Content-Type", /json/)
104
- expect(res.body.message).toEqual("Must supply a 'flag' field in request body.")
105
-
146
+ expect(res.body.message).toEqual(
147
+ "Must supply a 'flag' field in request body."
148
+ )
106
149
  })
107
150
 
108
151
  it("should be able to set a flag on the user", async () => {
@@ -146,8 +189,9 @@ describe("/users", () => {
146
189
  .send({ value: "test" })
147
190
  .expect(400)
148
191
  .expect("Content-Type", /json/)
149
- expect(res.body.message).toEqual("Must supply a 'flag' field in request body.")
150
-
192
+ expect(res.body.message).toEqual(
193
+ "Must supply a 'flag' field in request body."
194
+ )
151
195
  })
152
196
 
153
197
  it("should be able to set a flag on the user", async () => {
@@ -165,33 +209,37 @@ describe("/users", () => {
165
209
  describe("syncUser", () => {
166
210
  it("should sync the user", async () => {
167
211
  let user = await config.createUser()
168
- await config.createApp('New App')
212
+ await config.createApp("New App")
169
213
  let res = await request
170
214
  .post(`/api/users/metadata/sync/${user._id}`)
171
215
  .set(config.defaultHeaders())
172
216
  .expect(200)
173
217
  .expect("Content-Type", /json/)
174
- expect(res.body.message).toEqual('User synced.')
218
+ expect(res.body.message).toEqual("User synced.")
175
219
  })
176
220
 
177
-
178
221
  it("should sync the user when a previous user is specified", async () => {
179
- const app1 = await config.createApp('App 1')
180
- const app2 = await config.createApp('App 2')
222
+ const app1 = await config.createApp("App 1")
223
+ const app2 = await config.createApp("App 2")
181
224
 
182
225
  let user = await config.createUser({
183
226
  builder: false,
184
227
  admin: true,
185
- roles: { [app1.appId]: 'ADMIN' }
186
- })
228
+ roles: { [app1.appId]: "ADMIN" },
229
+ })
187
230
  let res = await request
188
231
  .post(`/api/users/metadata/sync/${user._id}`)
189
232
  .set(config.defaultHeaders())
190
- .send({ previousUser: { ...user, roles: { ...user.roles, [app2.appId]: 'BASIC' } } })
233
+ .send({
234
+ previousUser: {
235
+ ...user,
236
+ roles: { ...user.roles, [app2.appId]: "BASIC" },
237
+ },
238
+ })
191
239
  .expect(200)
192
240
  .expect("Content-Type", /json/)
193
241
 
194
- expect(res.body.message).toEqual('User synced.')
242
+ expect(res.body.message).toEqual("User synced.")
195
243
  })
196
244
  })
197
245
  })