@casual-simulation/aux-records 3.8.1 → 3.10.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/AIChatInterface.d.ts +7 -43
- package/AIChatInterface.js +8 -6
- package/AIChatInterface.js.map +1 -1
- package/AIController.js +44 -49
- package/AIController.js.map +1 -1
- package/AIOpenAIRealtimeInterface.d.ts +1 -1
- package/AnthropicAIChatInterface.js +4 -4
- package/AnthropicAIChatInterface.js.map +1 -1
- package/AuthController.d.ts +78 -10
- package/AuthController.js +230 -166
- package/AuthController.js.map +1 -1
- package/AuthStore.d.ts +317 -4
- package/BigIntPatch.d.ts +1 -0
- package/BigIntPatch.js +24 -0
- package/BigIntPatch.js.map +1 -0
- package/BlockadeLabsGenerateSkyboxInterface.js +4 -4
- package/BlockadeLabsGenerateSkyboxInterface.js.map +1 -1
- package/CachingConfigStore.d.ts +8 -1
- package/CachingConfigStore.js +50 -0
- package/CachingConfigStore.js.map +1 -1
- package/ComIdConfig.d.ts +132 -86
- package/ComIdConfig.js +5 -5
- package/ComIdConfig.js.map +1 -1
- package/ConfigurationStore.d.ts +1393 -3
- package/ConfigurationStore.js +49 -0
- package/ConfigurationStore.js.map +1 -1
- package/DataRecordsController.js +28 -28
- package/DataRecordsController.js.map +1 -1
- package/EventRecordsController.js +9 -9
- package/EventRecordsController.js.map +1 -1
- package/FileRecordsController.js +18 -17
- package/FileRecordsController.js.map +1 -1
- package/GoogleAIChatInterface.js +4 -4
- package/GoogleAIChatInterface.js.map +1 -1
- package/HttpTestUtils.d.ts +48 -0
- package/HttpTestUtils.js +256 -0
- package/HttpTestUtils.js.map +1 -0
- package/LivekitController.js +2 -2
- package/LivekitController.js.map +1 -1
- package/LoomController.js +3 -4
- package/LoomController.js.map +1 -1
- package/MemoryStore.d.ts +60 -7
- package/MemoryStore.js +427 -59
- package/MemoryStore.js.map +1 -1
- package/MetricsStore.d.ts +11 -0
- package/ModerationConfiguration.d.ts +11 -85
- package/ModerationConfiguration.js +17 -17
- package/ModerationConfiguration.js.map +1 -1
- package/ModerationController.js +9 -11
- package/ModerationController.js.map +1 -1
- package/OpenAIChatInterface.js +8 -13
- package/OpenAIChatInterface.js.map +1 -1
- package/OpenAIImageInterface.js +4 -5
- package/OpenAIImageInterface.js.map +1 -1
- package/PolicyController.js +66 -73
- package/PolicyController.js.map +1 -1
- package/PolicyStore.d.ts +59 -33
- package/PolicyStore.js +35 -1
- package/PolicyStore.js.map +1 -1
- package/PrivoClient.d.ts +3 -1
- package/PrivoClient.js +2 -4
- package/PrivoClient.js.map +1 -1
- package/PrivoConfiguration.d.ts +6 -72
- package/PrivoConfiguration.js +30 -31
- package/PrivoConfiguration.js.map +1 -1
- package/README.md +276 -2
- package/RateLimitController.js +2 -2
- package/RateLimitController.js.map +1 -1
- package/RecordsClient.d.ts +3 -1
- package/RecordsClient.js +6 -6
- package/RecordsClient.js.map +1 -1
- package/RecordsController.d.ts +145 -3
- package/RecordsController.js +399 -61
- package/RecordsController.js.map +1 -1
- package/RecordsServer.d.ts +1932 -1109
- package/RecordsStore.d.ts +99 -14
- package/RecordsStore.js +8 -10
- package/RecordsStore.js.map +1 -1
- package/ServerConfig.d.ts +698 -9867
- package/ServerConfig.js +457 -377
- package/ServerConfig.js.map +1 -1
- package/SloydInterface.js +1 -1
- package/SloydInterface.js.map +1 -1
- package/StabilityAIImageInterface.js +6 -9
- package/StabilityAIImageInterface.js.map +1 -1
- package/StripeInterface.d.ts +431 -287
- package/StripeInterface.js +21 -1
- package/StripeInterface.js.map +1 -1
- package/SubscriptionConfigBuilder.d.ts +10 -1
- package/SubscriptionConfigBuilder.js +72 -41
- package/SubscriptionConfigBuilder.js.map +1 -1
- package/SubscriptionConfiguration.d.ts +606 -6334
- package/SubscriptionConfiguration.js +460 -277
- package/SubscriptionConfiguration.js.map +1 -1
- package/SubscriptionController.d.ts +677 -4
- package/SubscriptionController.js +2986 -186
- package/SubscriptionController.js.map +1 -1
- package/SystemNotificationMessenger.d.ts +14 -70
- package/SystemNotificationMessenger.js +17 -20
- package/SystemNotificationMessenger.js.map +1 -1
- package/TestUtils.d.ts +18 -3
- package/TestUtils.js +84 -8
- package/TestUtils.js.map +1 -1
- package/TypeUtils.d.ts +991 -0
- package/TypeUtils.js +2 -0
- package/TypeUtils.js.map +1 -0
- package/Utils.d.ts +59 -0
- package/Utils.js +507 -3
- package/Utils.js.map +1 -1
- package/Validations.d.ts +24 -108
- package/Validations.js +62 -45
- package/Validations.js.map +1 -1
- package/ViewTemplateRenderer.d.ts +39 -0
- package/ViewTemplateRenderer.js +19 -0
- package/ViewTemplateRenderer.js.map +1 -0
- package/contracts/ContractRecordsController.d.ts +58 -0
- package/contracts/ContractRecordsController.js +144 -0
- package/contracts/ContractRecordsController.js.map +1 -0
- package/contracts/ContractRecordsStore.d.ts +285 -0
- package/contracts/ContractRecordsStore.js +19 -0
- package/contracts/ContractRecordsStore.js.map +1 -0
- package/contracts/MemoryContractRecordsStore.d.ts +27 -0
- package/contracts/MemoryContractRecordsStore.js +124 -0
- package/contracts/MemoryContractRecordsStore.js.map +1 -0
- package/contracts/index.d.ts +4 -0
- package/contracts/index.js +21 -0
- package/contracts/index.js.map +1 -0
- package/crud/CrudHelpers.d.ts +25 -26
- package/crud/CrudHelpers.js +1 -1
- package/crud/CrudHelpers.js.map +1 -1
- package/crud/CrudRecordsController.js +13 -16
- package/crud/CrudRecordsController.js.map +1 -1
- package/crud/CrudRecordsControllerTests.d.ts +2 -2
- package/crud/CrudRecordsControllerTests.js +605 -580
- package/crud/CrudRecordsControllerTests.js.map +1 -1
- package/crud/MemoryCrudRecordsStore.js +1 -2
- package/crud/MemoryCrudRecordsStore.js.map +1 -1
- package/crud/sub/MemorySubCrudRecordsStore.js +4 -6
- package/crud/sub/MemorySubCrudRecordsStore.js.map +1 -1
- package/crud/sub/SubCrudRecordsController.js +8 -8
- package/crud/sub/SubCrudRecordsController.js.map +1 -1
- package/database/DatabaseRecordsController.js +1 -2
- package/database/DatabaseRecordsController.js.map +1 -1
- package/database/SqliteDatabaseInterface.js +1 -2
- package/database/SqliteDatabaseInterface.js.map +1 -1
- package/dns/DNSDomainNameValidator.d.ts +11 -0
- package/dns/DNSDomainNameValidator.js +59 -0
- package/dns/DNSDomainNameValidator.js.map +1 -0
- package/dns/DomainNameValidator.d.ts +36 -0
- package/dns/DomainNameValidator.js +19 -0
- package/dns/DomainNameValidator.js.map +1 -0
- package/dns/index.d.ts +3 -0
- package/dns/index.js +20 -0
- package/dns/index.js.map +1 -0
- package/financial/FinancialController.d.ts +272 -0
- package/financial/FinancialController.js +762 -0
- package/financial/FinancialController.js.map +1 -0
- package/financial/FinancialInterface.d.ts +352 -0
- package/financial/FinancialInterface.js +642 -0
- package/financial/FinancialInterface.js.map +1 -0
- package/financial/FinancialStore.d.ts +186 -0
- package/financial/FinancialStore.js +19 -0
- package/financial/FinancialStore.js.map +1 -0
- package/financial/MemoryFinancialInterface.d.ts +23 -0
- package/financial/MemoryFinancialInterface.js +592 -0
- package/financial/MemoryFinancialInterface.js.map +1 -0
- package/financial/TigerBeetleFinancialInterface.d.ts +46 -0
- package/financial/TigerBeetleFinancialInterface.js +109 -0
- package/financial/TigerBeetleFinancialInterface.js.map +1 -0
- package/financial/TigerBeetleTestUtils.d.ts +40 -0
- package/financial/TigerBeetleTestUtils.js +185 -0
- package/financial/TigerBeetleTestUtils.js.map +1 -0
- package/financial/Types.d.ts +1 -0
- package/financial/Types.js +801 -0
- package/financial/Types.js.map +1 -0
- package/financial/index.d.ts +6 -0
- package/financial/index.js +24 -0
- package/financial/index.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/notifications/NotificationRecordsController.js +14 -14
- package/notifications/NotificationRecordsController.js.map +1 -1
- package/notifications/WebPushInterface.d.ts +24 -155
- package/notifications/WebPushInterface.js +2 -2
- package/notifications/WebPushInterface.js.map +1 -1
- package/package.json +72 -70
- package/packages/version/MemoryPackageVersionRecordsStore.js +12 -15
- package/packages/version/MemoryPackageVersionRecordsStore.js.map +1 -1
- package/packages/version/PackageVersionRecordsController.d.ts +19 -0
- package/packages/version/PackageVersionRecordsController.js +102 -22
- package/packages/version/PackageVersionRecordsController.js.map +1 -1
- package/packages/version/PackageVersionRecordsStore.js +6 -8
- package/packages/version/PackageVersionRecordsStore.js.map +1 -1
- package/purchasable-items/MemoryPurchasableItemRecordsStore.d.ts +7 -0
- package/purchasable-items/MemoryPurchasableItemRecordsStore.js +33 -0
- package/purchasable-items/MemoryPurchasableItemRecordsStore.js.map +1 -0
- package/purchasable-items/PurchasableItemRecordsController.d.ts +16 -0
- package/purchasable-items/PurchasableItemRecordsController.js +72 -0
- package/purchasable-items/PurchasableItemRecordsController.js.map +1 -0
- package/purchasable-items/PurchasableItemRecordsStore.d.ts +66 -0
- package/purchasable-items/PurchasableItemRecordsStore.js +2 -0
- package/purchasable-items/PurchasableItemRecordsStore.js.map +1 -0
- package/purchasable-items/index.d.ts +4 -0
- package/purchasable-items/index.js +21 -0
- package/purchasable-items/index.js.map +1 -0
- package/queue/MemoryQueue.js +1 -1
- package/queue/MemoryQueue.js.map +1 -1
- package/search/MemorySearchInterface.js +1 -2
- package/search/MemorySearchInterface.js.map +1 -1
- package/search/SearchRecordsController.d.ts +66 -244
- package/search/SearchRecordsController.js +35 -36
- package/search/SearchRecordsController.js.map +1 -1
- package/search/SearchSyncProcessor.d.ts +7 -83
- package/search/TypesenseSearchInterface.js +8 -11
- package/search/TypesenseSearchInterface.js.map +1 -1
- package/tracing/TracingDecorators.js +5 -8
- package/tracing/TracingDecorators.js.map +1 -1
- package/webhooks/WebhookEnvironment.d.ts +36 -560
- package/webhooks/WebhookEnvironment.js +1 -1
- package/webhooks/WebhookEnvironment.js.map +1 -1
- package/webhooks/WebhookRecordsController.js +14 -16
- package/webhooks/WebhookRecordsController.js.map +1 -1
- package/websockets/MemoryLockStore.d.ts +18 -0
- package/websockets/MemoryLockStore.js +2 -0
- package/websockets/MemoryLockStore.js.map +1 -0
- package/websockets/MemoryTempInstRecordsStore.js +15 -27
- package/websockets/MemoryTempInstRecordsStore.js.map +1 -1
- package/websockets/MemoryWebsocketConnectionStore.js +6 -8
- package/websockets/MemoryWebsocketConnectionStore.js.map +1 -1
- package/websockets/MemoryWebsocketMessenger.js +1 -2
- package/websockets/MemoryWebsocketMessenger.js.map +1 -1
- package/websockets/SplitInstRecordsStore.js +2 -2
- package/websockets/SplitInstRecordsStore.js.map +1 -1
- package/websockets/WebsocketController.d.ts +5 -0
- package/websockets/WebsocketController.js +122 -83
- package/websockets/WebsocketController.js.map +1 -1
- package/RecordsServer.js +0 -6435
- package/RecordsServer.js.map +0 -1
|
@@ -55,7 +55,13 @@ export async function setupTestContext(storeFactory, controllerFactory) {
|
|
|
55
55
|
* @param createStoreItem The factory function that creates a test item.
|
|
56
56
|
* @param configureEnvironment An optional function that can be used to configure the environment before the tests are run.
|
|
57
57
|
*/
|
|
58
|
-
export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFactory, controllerFactory, createStoreItem, createInputItem, configureEnvironment, createOutputItem = createStoreItem, cleanup
|
|
58
|
+
export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFactory, controllerFactory, createStoreItem, createInputItem, configureEnvironment, createOutputItem = createStoreItem, cleanup, allowedActions = [
|
|
59
|
+
'create',
|
|
60
|
+
'update',
|
|
61
|
+
'read',
|
|
62
|
+
'delete',
|
|
63
|
+
'list',
|
|
64
|
+
]) {
|
|
59
65
|
let context;
|
|
60
66
|
let services;
|
|
61
67
|
let store;
|
|
@@ -92,125 +98,394 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
92
98
|
cleanup(context);
|
|
93
99
|
}
|
|
94
100
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
if (allowedActions.includes('create') ||
|
|
102
|
+
allowedActions.includes('update')) {
|
|
103
|
+
describe('recordItem()', () => {
|
|
104
|
+
if (allowedActions.includes('create')) {
|
|
105
|
+
describe('create', () => {
|
|
106
|
+
it('should store the item in the store', async () => {
|
|
107
|
+
const item = createInputItem({
|
|
108
|
+
address: 'address',
|
|
109
|
+
markers: [PUBLIC_READ_MARKER],
|
|
110
|
+
});
|
|
111
|
+
const result = (await manager.recordItem({
|
|
112
|
+
recordKeyOrRecordName: recordName,
|
|
113
|
+
userId,
|
|
114
|
+
item,
|
|
115
|
+
instances: [],
|
|
116
|
+
}));
|
|
117
|
+
expect(result).toEqual({
|
|
118
|
+
success: true,
|
|
119
|
+
recordName: recordName,
|
|
120
|
+
address: 'address',
|
|
121
|
+
});
|
|
122
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(createStoreItem({
|
|
123
|
+
address: 'address',
|
|
124
|
+
markers: [PUBLIC_READ_MARKER],
|
|
125
|
+
}));
|
|
126
|
+
});
|
|
127
|
+
it('should reject the request if given an invalid key', async () => {
|
|
128
|
+
const result = (await manager.recordItem({
|
|
129
|
+
recordKeyOrRecordName: 'not_a_key',
|
|
130
|
+
userId,
|
|
131
|
+
item: createInputItem({
|
|
132
|
+
address: 'address',
|
|
133
|
+
markers: [PUBLIC_READ_MARKER],
|
|
134
|
+
}),
|
|
135
|
+
instances: [],
|
|
136
|
+
}));
|
|
137
|
+
expect(result).toEqual({
|
|
138
|
+
success: false,
|
|
139
|
+
errorCode: 'record_not_found',
|
|
140
|
+
errorMessage: expect.any(String),
|
|
141
|
+
});
|
|
142
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toBeFalsy();
|
|
143
|
+
});
|
|
144
|
+
if (allowRecordKeys) {
|
|
145
|
+
it('should support using a record key', async () => {
|
|
146
|
+
const result = (await manager.recordItem({
|
|
147
|
+
recordKeyOrRecordName: key,
|
|
148
|
+
userId: otherUserId,
|
|
149
|
+
item: createInputItem({
|
|
150
|
+
address: 'address',
|
|
151
|
+
markers: [PUBLIC_READ_MARKER],
|
|
152
|
+
}),
|
|
153
|
+
instances: [],
|
|
154
|
+
}));
|
|
155
|
+
expect(result).toEqual({
|
|
156
|
+
success: true,
|
|
157
|
+
recordName: recordName,
|
|
158
|
+
address: 'address',
|
|
159
|
+
});
|
|
160
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toEqual({
|
|
161
|
+
address: 'address',
|
|
162
|
+
markers: [PUBLIC_READ_MARKER],
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
it('should be able to use subjectless keys', async () => {
|
|
166
|
+
const result = (await manager.recordItem({
|
|
167
|
+
recordKeyOrRecordName: subjectlessKey,
|
|
168
|
+
userId: otherUserId,
|
|
169
|
+
item: createInputItem({
|
|
170
|
+
address: 'address',
|
|
171
|
+
markers: [PUBLIC_READ_MARKER],
|
|
172
|
+
}),
|
|
173
|
+
instances: [],
|
|
174
|
+
}));
|
|
175
|
+
expect(result).toEqual({
|
|
176
|
+
success: true,
|
|
177
|
+
recordName: recordName,
|
|
178
|
+
address: 'address',
|
|
179
|
+
});
|
|
180
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toEqual({
|
|
181
|
+
address: 'address',
|
|
182
|
+
markers: [PUBLIC_READ_MARKER],
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
it('should reject the request if record keys are not allowed', async () => {
|
|
188
|
+
const result = (await manager.recordItem({
|
|
189
|
+
recordKeyOrRecordName: key,
|
|
190
|
+
userId: otherUserId,
|
|
191
|
+
item: createInputItem({
|
|
192
|
+
address: 'address',
|
|
193
|
+
markers: [PUBLIC_READ_MARKER],
|
|
194
|
+
}),
|
|
195
|
+
instances: [],
|
|
196
|
+
}));
|
|
197
|
+
expect(result).toEqual({
|
|
198
|
+
success: false,
|
|
199
|
+
errorCode: 'not_authorized',
|
|
200
|
+
errorMessage: expect.any(String),
|
|
201
|
+
reason: {
|
|
202
|
+
type: 'missing_permission',
|
|
203
|
+
recordName,
|
|
204
|
+
action: 'create',
|
|
205
|
+
resourceKind,
|
|
206
|
+
resourceId: 'address',
|
|
207
|
+
subjectType: 'user',
|
|
208
|
+
subjectId: otherUserId,
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toBeFalsy();
|
|
212
|
+
});
|
|
213
|
+
it('should reject the request if subjectless keys are not allowed', async () => {
|
|
214
|
+
const result = (await manager.recordItem({
|
|
215
|
+
recordKeyOrRecordName: subjectlessKey,
|
|
216
|
+
userId: otherUserId,
|
|
217
|
+
item: createInputItem({
|
|
218
|
+
address: 'address',
|
|
219
|
+
markers: [PUBLIC_READ_MARKER],
|
|
220
|
+
}),
|
|
221
|
+
instances: [],
|
|
222
|
+
}));
|
|
223
|
+
expect(result).toEqual({
|
|
224
|
+
success: false,
|
|
225
|
+
errorCode: 'not_authorized',
|
|
226
|
+
errorMessage: expect.any(String),
|
|
227
|
+
reason: {
|
|
228
|
+
type: 'missing_permission',
|
|
229
|
+
recordName,
|
|
230
|
+
action: 'create',
|
|
231
|
+
resourceKind,
|
|
232
|
+
resourceId: 'address',
|
|
233
|
+
subjectType: 'user',
|
|
234
|
+
subjectId: otherUserId,
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toBeFalsy();
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
if (allowedActions.includes('update')) {
|
|
243
|
+
describe('update', () => {
|
|
244
|
+
beforeEach(async () => {
|
|
245
|
+
await manager.recordItem({
|
|
246
|
+
recordKeyOrRecordName: recordName,
|
|
247
|
+
userId,
|
|
248
|
+
item: createInputItem({
|
|
249
|
+
address: 'address',
|
|
250
|
+
markers: [PUBLIC_READ_MARKER],
|
|
251
|
+
}),
|
|
252
|
+
instances: [],
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
it('should update the markers in the store', async () => {
|
|
256
|
+
const item = createInputItem({
|
|
257
|
+
address: 'address',
|
|
258
|
+
markers: [PRIVATE_MARKER],
|
|
259
|
+
});
|
|
260
|
+
const result = (await manager.recordItem({
|
|
261
|
+
recordKeyOrRecordName: recordName,
|
|
262
|
+
userId,
|
|
263
|
+
item,
|
|
264
|
+
instances: [],
|
|
265
|
+
}));
|
|
266
|
+
expect(result).toEqual({
|
|
267
|
+
success: true,
|
|
268
|
+
recordName: recordName,
|
|
269
|
+
address: 'address',
|
|
270
|
+
});
|
|
271
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(createStoreItem({
|
|
272
|
+
address: 'address',
|
|
273
|
+
markers: [PRIVATE_MARKER],
|
|
274
|
+
}));
|
|
275
|
+
});
|
|
276
|
+
it('should reject the request if given an invalid key', async () => {
|
|
277
|
+
const item = createInputItem({
|
|
278
|
+
address: 'address',
|
|
279
|
+
markers: [PUBLIC_READ_MARKER],
|
|
280
|
+
});
|
|
281
|
+
const result = (await manager.recordItem({
|
|
282
|
+
recordKeyOrRecordName: 'not_a_key',
|
|
283
|
+
userId,
|
|
284
|
+
item,
|
|
285
|
+
instances: [],
|
|
286
|
+
}));
|
|
287
|
+
expect(result).toEqual({
|
|
288
|
+
success: false,
|
|
289
|
+
errorCode: 'record_not_found',
|
|
290
|
+
errorMessage: expect.any(String),
|
|
291
|
+
});
|
|
292
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(createStoreItem({
|
|
293
|
+
address: 'address',
|
|
294
|
+
markers: [PUBLIC_READ_MARKER],
|
|
295
|
+
}));
|
|
296
|
+
});
|
|
297
|
+
if (allowRecordKeys) {
|
|
298
|
+
it('should support using a record key', async () => {
|
|
299
|
+
const item = createInputItem({
|
|
300
|
+
address: 'address',
|
|
301
|
+
markers: [PRIVATE_MARKER],
|
|
302
|
+
});
|
|
303
|
+
const result = (await manager.recordItem({
|
|
304
|
+
recordKeyOrRecordName: key,
|
|
305
|
+
userId,
|
|
306
|
+
item,
|
|
307
|
+
instances: [],
|
|
308
|
+
}));
|
|
309
|
+
expect(result).toEqual({
|
|
310
|
+
success: true,
|
|
311
|
+
recordName: recordName,
|
|
312
|
+
address: 'address',
|
|
313
|
+
});
|
|
314
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(createStoreItem({
|
|
315
|
+
address: 'address',
|
|
316
|
+
markers: [PRIVATE_MARKER],
|
|
317
|
+
}));
|
|
318
|
+
});
|
|
319
|
+
it('should be able to use subjectless keys', async () => {
|
|
320
|
+
const item = createInputItem({
|
|
321
|
+
address: 'address',
|
|
322
|
+
markers: [PRIVATE_MARKER],
|
|
323
|
+
});
|
|
324
|
+
const result = (await manager.recordItem({
|
|
325
|
+
recordKeyOrRecordName: subjectlessKey,
|
|
326
|
+
userId,
|
|
327
|
+
item,
|
|
328
|
+
instances: [],
|
|
329
|
+
}));
|
|
330
|
+
expect(result).toEqual({
|
|
331
|
+
success: true,
|
|
332
|
+
recordName: recordName,
|
|
333
|
+
address: 'address',
|
|
334
|
+
});
|
|
335
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(createStoreItem({
|
|
336
|
+
address: 'address',
|
|
337
|
+
markers: [PRIVATE_MARKER],
|
|
338
|
+
}));
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
it('should reject the request if record keys are not allowed', async () => {
|
|
343
|
+
const item = createInputItem({
|
|
344
|
+
address: 'address',
|
|
345
|
+
markers: [PRIVATE_MARKER],
|
|
346
|
+
});
|
|
347
|
+
const result = (await manager.recordItem({
|
|
348
|
+
recordKeyOrRecordName: key,
|
|
349
|
+
userId: otherUserId,
|
|
350
|
+
item,
|
|
351
|
+
instances: [],
|
|
352
|
+
}));
|
|
353
|
+
expect(result).toEqual({
|
|
354
|
+
success: false,
|
|
355
|
+
errorCode: 'not_authorized',
|
|
356
|
+
errorMessage: expect.any(String),
|
|
357
|
+
reason: {
|
|
358
|
+
type: 'missing_permission',
|
|
359
|
+
recordName,
|
|
360
|
+
action: 'update',
|
|
361
|
+
resourceKind,
|
|
362
|
+
resourceId: 'address',
|
|
363
|
+
subjectType: 'user',
|
|
364
|
+
subjectId: otherUserId,
|
|
365
|
+
},
|
|
366
|
+
});
|
|
367
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(createStoreItem({
|
|
368
|
+
address: 'address',
|
|
369
|
+
markers: [PUBLIC_READ_MARKER],
|
|
370
|
+
}));
|
|
371
|
+
});
|
|
372
|
+
it('should reject the request if subjectless keys are not allowed', async () => {
|
|
373
|
+
const item = createInputItem({
|
|
374
|
+
address: 'address',
|
|
375
|
+
markers: [PRIVATE_MARKER],
|
|
376
|
+
});
|
|
377
|
+
const result = (await manager.recordItem({
|
|
378
|
+
recordKeyOrRecordName: subjectlessKey,
|
|
379
|
+
userId: otherUserId,
|
|
380
|
+
item,
|
|
381
|
+
instances: [],
|
|
382
|
+
}));
|
|
383
|
+
expect(result).toEqual({
|
|
384
|
+
success: false,
|
|
385
|
+
errorCode: 'not_authorized',
|
|
386
|
+
errorMessage: expect.any(String),
|
|
387
|
+
reason: {
|
|
388
|
+
type: 'missing_permission',
|
|
389
|
+
recordName,
|
|
390
|
+
action: 'update',
|
|
391
|
+
resourceKind,
|
|
392
|
+
resourceId: 'address',
|
|
393
|
+
subjectType: 'user',
|
|
394
|
+
subjectId: otherUserId,
|
|
395
|
+
},
|
|
396
|
+
});
|
|
397
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(createStoreItem({
|
|
398
|
+
address: 'address',
|
|
399
|
+
markers: [PUBLIC_READ_MARKER],
|
|
400
|
+
}));
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
if (allowedActions.includes('read')) {
|
|
408
|
+
describe('getItem()', () => {
|
|
409
|
+
beforeEach(async () => {
|
|
410
|
+
await itemsStore.createItem(recordName, createStoreItem({
|
|
99
411
|
address: 'address',
|
|
100
412
|
markers: [PUBLIC_READ_MARKER],
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
|
|
413
|
+
}));
|
|
414
|
+
await itemsStore.createItem(recordName, createStoreItem({
|
|
415
|
+
address: 'address2',
|
|
416
|
+
markers: [PRIVATE_MARKER],
|
|
417
|
+
}));
|
|
418
|
+
await itemsStore.createItem(recordName, createStoreItem({
|
|
419
|
+
address: 'address3',
|
|
420
|
+
markers: [PUBLIC_READ_MARKER],
|
|
421
|
+
}));
|
|
422
|
+
});
|
|
423
|
+
it('should return the item if the user has access', async () => {
|
|
424
|
+
const result = await manager.getItem({
|
|
425
|
+
recordName: recordName,
|
|
104
426
|
userId,
|
|
105
|
-
|
|
427
|
+
address: 'address2',
|
|
106
428
|
instances: [],
|
|
107
|
-
})
|
|
108
|
-
expect(result).
|
|
429
|
+
});
|
|
430
|
+
expect(result).toMatchObject({
|
|
109
431
|
success: true,
|
|
432
|
+
item: createOutputItem({
|
|
433
|
+
address: 'address2',
|
|
434
|
+
markers: [PRIVATE_MARKER],
|
|
435
|
+
}),
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
it('should return data_not_found if the item was not found', async () => {
|
|
439
|
+
const result = await manager.getItem({
|
|
110
440
|
recordName: recordName,
|
|
111
|
-
|
|
441
|
+
userId,
|
|
442
|
+
address: 'missing',
|
|
443
|
+
instances: [],
|
|
444
|
+
});
|
|
445
|
+
expect(result).toEqual({
|
|
446
|
+
success: false,
|
|
447
|
+
errorCode: 'data_not_found',
|
|
448
|
+
errorMessage: expect.any(String),
|
|
112
449
|
});
|
|
113
|
-
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(createStoreItem({
|
|
114
|
-
address: 'address',
|
|
115
|
-
markers: [PUBLIC_READ_MARKER],
|
|
116
|
-
}));
|
|
117
450
|
});
|
|
118
|
-
it('should
|
|
119
|
-
const result =
|
|
120
|
-
|
|
451
|
+
it('should return record_not_found if the record doesnt exist', async () => {
|
|
452
|
+
const result = await manager.getItem({
|
|
453
|
+
recordName: 'missing',
|
|
121
454
|
userId,
|
|
122
|
-
|
|
123
|
-
address: 'address',
|
|
124
|
-
markers: [PUBLIC_READ_MARKER],
|
|
125
|
-
}),
|
|
455
|
+
address: 'address',
|
|
126
456
|
instances: [],
|
|
127
|
-
})
|
|
457
|
+
});
|
|
128
458
|
expect(result).toEqual({
|
|
129
459
|
success: false,
|
|
130
460
|
errorCode: 'record_not_found',
|
|
131
461
|
errorMessage: expect.any(String),
|
|
132
462
|
});
|
|
133
|
-
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toBeFalsy();
|
|
134
463
|
});
|
|
135
464
|
if (allowRecordKeys) {
|
|
136
|
-
it('should
|
|
137
|
-
const result =
|
|
138
|
-
|
|
139
|
-
userId
|
|
140
|
-
|
|
141
|
-
address: 'address',
|
|
142
|
-
markers: [PUBLIC_READ_MARKER],
|
|
143
|
-
}),
|
|
465
|
+
it('should be able to use a record key to access the item', async () => {
|
|
466
|
+
const result = await manager.getItem({
|
|
467
|
+
recordName: key,
|
|
468
|
+
userId,
|
|
469
|
+
address: 'address2',
|
|
144
470
|
instances: [],
|
|
145
|
-
}));
|
|
146
|
-
expect(result).toEqual({
|
|
147
|
-
success: true,
|
|
148
|
-
recordName: recordName,
|
|
149
|
-
address: 'address',
|
|
150
471
|
});
|
|
151
|
-
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toEqual({
|
|
152
|
-
address: 'address',
|
|
153
|
-
markers: [PUBLIC_READ_MARKER],
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
it('should be able to use subjectless keys', async () => {
|
|
157
|
-
const result = (await manager.recordItem({
|
|
158
|
-
recordKeyOrRecordName: subjectlessKey,
|
|
159
|
-
userId: otherUserId,
|
|
160
|
-
item: createInputItem({
|
|
161
|
-
address: 'address',
|
|
162
|
-
markers: [PUBLIC_READ_MARKER],
|
|
163
|
-
}),
|
|
164
|
-
instances: [],
|
|
165
|
-
}));
|
|
166
472
|
expect(result).toEqual({
|
|
167
473
|
success: true,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
address: 'address',
|
|
173
|
-
markers: [PUBLIC_READ_MARKER],
|
|
474
|
+
item: createStoreItem({
|
|
475
|
+
address: 'address2',
|
|
476
|
+
markers: [PRIVATE_MARKER],
|
|
477
|
+
}),
|
|
174
478
|
});
|
|
175
479
|
});
|
|
176
480
|
}
|
|
177
481
|
else {
|
|
178
|
-
it('should
|
|
179
|
-
const result =
|
|
180
|
-
|
|
482
|
+
it('should return not_authorized if record keys are not allowed', async () => {
|
|
483
|
+
const result = await manager.getItem({
|
|
484
|
+
recordName: key,
|
|
181
485
|
userId: otherUserId,
|
|
182
|
-
|
|
183
|
-
address: 'address',
|
|
184
|
-
markers: [PUBLIC_READ_MARKER],
|
|
185
|
-
}),
|
|
486
|
+
address: 'address2',
|
|
186
487
|
instances: [],
|
|
187
|
-
}));
|
|
188
|
-
expect(result).toEqual({
|
|
189
|
-
success: false,
|
|
190
|
-
errorCode: 'not_authorized',
|
|
191
|
-
errorMessage: expect.any(String),
|
|
192
|
-
reason: {
|
|
193
|
-
type: 'missing_permission',
|
|
194
|
-
recordName,
|
|
195
|
-
action: 'create',
|
|
196
|
-
resourceKind,
|
|
197
|
-
resourceId: 'address',
|
|
198
|
-
subjectType: 'user',
|
|
199
|
-
subjectId: otherUserId,
|
|
200
|
-
},
|
|
201
488
|
});
|
|
202
|
-
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toBeFalsy();
|
|
203
|
-
});
|
|
204
|
-
it('should reject the request if subjectless keys are not allowed', async () => {
|
|
205
|
-
const result = (await manager.recordItem({
|
|
206
|
-
recordKeyOrRecordName: subjectlessKey,
|
|
207
|
-
userId: otherUserId,
|
|
208
|
-
item: createInputItem({
|
|
209
|
-
address: 'address',
|
|
210
|
-
markers: [PUBLIC_READ_MARKER],
|
|
211
|
-
}),
|
|
212
|
-
instances: [],
|
|
213
|
-
}));
|
|
214
489
|
expect(result).toEqual({
|
|
215
490
|
success: false,
|
|
216
491
|
errorCode: 'not_authorized',
|
|
@@ -218,151 +493,95 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
218
493
|
reason: {
|
|
219
494
|
type: 'missing_permission',
|
|
220
495
|
recordName,
|
|
221
|
-
action: '
|
|
496
|
+
action: 'read',
|
|
222
497
|
resourceKind,
|
|
223
|
-
resourceId: '
|
|
498
|
+
resourceId: 'address2',
|
|
224
499
|
subjectType: 'user',
|
|
225
500
|
subjectId: otherUserId,
|
|
226
501
|
},
|
|
227
502
|
});
|
|
228
|
-
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toBeFalsy();
|
|
229
503
|
});
|
|
230
504
|
}
|
|
231
505
|
});
|
|
232
|
-
|
|
506
|
+
}
|
|
507
|
+
if (allowedActions.includes('delete')) {
|
|
508
|
+
describe('eraseItem()', () => {
|
|
233
509
|
beforeEach(async () => {
|
|
234
510
|
await manager.recordItem({
|
|
235
511
|
recordKeyOrRecordName: recordName,
|
|
236
|
-
userId,
|
|
237
512
|
item: createInputItem({
|
|
238
513
|
address: 'address',
|
|
239
514
|
markers: [PUBLIC_READ_MARKER],
|
|
240
515
|
}),
|
|
516
|
+
userId,
|
|
241
517
|
instances: [],
|
|
242
518
|
});
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
519
|
+
await manager.recordItem({
|
|
520
|
+
recordKeyOrRecordName: recordName,
|
|
521
|
+
item: createInputItem({
|
|
522
|
+
address: 'address2',
|
|
523
|
+
markers: [PUBLIC_READ_MARKER],
|
|
524
|
+
}),
|
|
525
|
+
userId,
|
|
526
|
+
instances: [],
|
|
248
527
|
});
|
|
249
|
-
|
|
528
|
+
await manager.recordItem({
|
|
250
529
|
recordKeyOrRecordName: recordName,
|
|
530
|
+
item: createInputItem({
|
|
531
|
+
address: 'address3',
|
|
532
|
+
markers: [PUBLIC_READ_MARKER],
|
|
533
|
+
}),
|
|
251
534
|
userId,
|
|
252
|
-
item,
|
|
253
535
|
instances: [],
|
|
254
|
-
})
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
it('should erase the item if the user has access', async () => {
|
|
539
|
+
const result = await manager.eraseItem({
|
|
540
|
+
recordName: recordName,
|
|
541
|
+
userId,
|
|
542
|
+
address: 'address2',
|
|
543
|
+
instances: [],
|
|
544
|
+
});
|
|
255
545
|
expect(result).toEqual({
|
|
256
546
|
success: true,
|
|
257
|
-
recordName: recordName,
|
|
258
|
-
address: 'address',
|
|
259
547
|
});
|
|
260
|
-
await expect(itemsStore.getItemByAddress(recordName, '
|
|
261
|
-
address: 'address',
|
|
262
|
-
markers: [PRIVATE_MARKER],
|
|
263
|
-
}));
|
|
548
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address2')).resolves.toBeFalsy();
|
|
264
549
|
});
|
|
265
|
-
it('should
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
markers: [PUBLIC_READ_MARKER],
|
|
269
|
-
});
|
|
270
|
-
const result = (await manager.recordItem({
|
|
271
|
-
recordKeyOrRecordName: 'not_a_key',
|
|
550
|
+
it('should return data_not_found if the item doesnt exist', async () => {
|
|
551
|
+
const result = await manager.eraseItem({
|
|
552
|
+
recordName: recordName,
|
|
272
553
|
userId,
|
|
273
|
-
|
|
554
|
+
address: 'missing',
|
|
274
555
|
instances: [],
|
|
275
|
-
})
|
|
556
|
+
});
|
|
276
557
|
expect(result).toEqual({
|
|
277
558
|
success: false,
|
|
278
|
-
errorCode: '
|
|
279
|
-
errorMessage:
|
|
559
|
+
errorCode: 'data_not_found',
|
|
560
|
+
errorMessage: 'The item was not found.',
|
|
280
561
|
});
|
|
281
|
-
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(createStoreItem({
|
|
282
|
-
address: 'address',
|
|
283
|
-
markers: [PUBLIC_READ_MARKER],
|
|
284
|
-
}));
|
|
285
562
|
});
|
|
286
563
|
if (allowRecordKeys) {
|
|
287
|
-
it('should
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const result = (await manager.recordItem({
|
|
293
|
-
recordKeyOrRecordName: key,
|
|
294
|
-
userId,
|
|
295
|
-
item,
|
|
564
|
+
it('should erase the item if the record key has access', async () => {
|
|
565
|
+
const result = await manager.eraseItem({
|
|
566
|
+
recordName: key,
|
|
567
|
+
userId: otherUserId,
|
|
568
|
+
address: 'address2',
|
|
296
569
|
instances: [],
|
|
297
|
-
}));
|
|
298
|
-
expect(result).toEqual({
|
|
299
|
-
success: true,
|
|
300
|
-
recordName: recordName,
|
|
301
|
-
address: 'address',
|
|
302
|
-
});
|
|
303
|
-
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(item);
|
|
304
|
-
});
|
|
305
|
-
it('should be able to use subjectless keys', async () => {
|
|
306
|
-
const item = createInputItem({
|
|
307
|
-
address: 'address',
|
|
308
|
-
markers: [PRIVATE_MARKER],
|
|
309
570
|
});
|
|
310
|
-
const result = (await manager.recordItem({
|
|
311
|
-
recordKeyOrRecordName: subjectlessKey,
|
|
312
|
-
userId,
|
|
313
|
-
item,
|
|
314
|
-
instances: [],
|
|
315
|
-
}));
|
|
316
571
|
expect(result).toEqual({
|
|
317
572
|
success: true,
|
|
318
|
-
recordName: recordName,
|
|
319
|
-
address: 'address',
|
|
320
573
|
});
|
|
321
|
-
await expect(itemsStore.getItemByAddress(recordName, '
|
|
574
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address2')).resolves.toBeFalsy();
|
|
322
575
|
});
|
|
323
576
|
}
|
|
324
577
|
else {
|
|
325
|
-
it('should
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
markers: [PRIVATE_MARKER],
|
|
329
|
-
});
|
|
330
|
-
const result = (await manager.recordItem({
|
|
331
|
-
recordKeyOrRecordName: key,
|
|
578
|
+
it('should return not_authorized if the controller doesnt allow record keys', async () => {
|
|
579
|
+
const result = await manager.eraseItem({
|
|
580
|
+
recordName: key,
|
|
332
581
|
userId: otherUserId,
|
|
333
|
-
|
|
582
|
+
address: 'address2',
|
|
334
583
|
instances: [],
|
|
335
|
-
}));
|
|
336
|
-
expect(result).toEqual({
|
|
337
|
-
success: false,
|
|
338
|
-
errorCode: 'not_authorized',
|
|
339
|
-
errorMessage: expect.any(String),
|
|
340
|
-
reason: {
|
|
341
|
-
type: 'missing_permission',
|
|
342
|
-
recordName,
|
|
343
|
-
action: 'update',
|
|
344
|
-
resourceKind,
|
|
345
|
-
resourceId: 'address',
|
|
346
|
-
subjectType: 'user',
|
|
347
|
-
subjectId: otherUserId,
|
|
348
|
-
},
|
|
349
|
-
});
|
|
350
|
-
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(createStoreItem({
|
|
351
|
-
address: 'address',
|
|
352
|
-
markers: [PUBLIC_READ_MARKER],
|
|
353
|
-
}));
|
|
354
|
-
});
|
|
355
|
-
it('should reject the request if subjectless keys are not allowed', async () => {
|
|
356
|
-
const item = createInputItem({
|
|
357
|
-
address: 'address',
|
|
358
|
-
markers: [PRIVATE_MARKER],
|
|
359
584
|
});
|
|
360
|
-
const result = (await manager.recordItem({
|
|
361
|
-
recordKeyOrRecordName: subjectlessKey,
|
|
362
|
-
userId: otherUserId,
|
|
363
|
-
item,
|
|
364
|
-
instances: [],
|
|
365
|
-
}));
|
|
366
585
|
expect(result).toEqual({
|
|
367
586
|
success: false,
|
|
368
587
|
errorCode: 'not_authorized',
|
|
@@ -370,269 +589,117 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
370
589
|
reason: {
|
|
371
590
|
type: 'missing_permission',
|
|
372
591
|
recordName,
|
|
373
|
-
action: '
|
|
592
|
+
action: 'delete',
|
|
374
593
|
resourceKind,
|
|
375
|
-
resourceId: '
|
|
594
|
+
resourceId: 'address2',
|
|
376
595
|
subjectType: 'user',
|
|
377
596
|
subjectId: otherUserId,
|
|
378
597
|
},
|
|
379
598
|
});
|
|
380
|
-
await expect(itemsStore.getItemByAddress(recordName, '
|
|
381
|
-
address: 'address',
|
|
382
|
-
markers: [PUBLIC_READ_MARKER],
|
|
383
|
-
}));
|
|
599
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address2')).resolves.toBeTruthy();
|
|
384
600
|
});
|
|
385
601
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
beforeEach(async () => {
|
|
390
|
-
await itemsStore.createItem(recordName, createStoreItem({
|
|
391
|
-
address: 'address',
|
|
392
|
-
markers: [PUBLIC_READ_MARKER],
|
|
393
|
-
}));
|
|
394
|
-
await itemsStore.createItem(recordName, createStoreItem({
|
|
395
|
-
address: 'address2',
|
|
396
|
-
markers: [PRIVATE_MARKER],
|
|
397
|
-
}));
|
|
398
|
-
await itemsStore.createItem(recordName, createStoreItem({
|
|
399
|
-
address: 'address3',
|
|
400
|
-
markers: [PUBLIC_READ_MARKER],
|
|
401
|
-
}));
|
|
402
|
-
});
|
|
403
|
-
it('should return the item if the user has access', async () => {
|
|
404
|
-
const result = await manager.getItem({
|
|
405
|
-
recordName: recordName,
|
|
406
|
-
userId,
|
|
407
|
-
address: 'address2',
|
|
408
|
-
instances: [],
|
|
409
|
-
});
|
|
410
|
-
expect(result).toMatchObject({
|
|
411
|
-
success: true,
|
|
412
|
-
item: createOutputItem({
|
|
413
|
-
address: 'address2',
|
|
414
|
-
markers: [PRIVATE_MARKER],
|
|
415
|
-
}),
|
|
416
|
-
});
|
|
417
|
-
});
|
|
418
|
-
it('should return data_not_found if the item was not found', async () => {
|
|
419
|
-
const result = await manager.getItem({
|
|
420
|
-
recordName: recordName,
|
|
421
|
-
userId,
|
|
422
|
-
address: 'missing',
|
|
423
|
-
instances: [],
|
|
424
|
-
});
|
|
425
|
-
expect(result).toEqual({
|
|
426
|
-
success: false,
|
|
427
|
-
errorCode: 'data_not_found',
|
|
428
|
-
errorMessage: expect.any(String),
|
|
429
|
-
});
|
|
430
|
-
});
|
|
431
|
-
it('should return record_not_found if the record doesnt exist', async () => {
|
|
432
|
-
const result = await manager.getItem({
|
|
433
|
-
recordName: 'missing',
|
|
434
|
-
userId,
|
|
435
|
-
address: 'address',
|
|
436
|
-
instances: [],
|
|
437
|
-
});
|
|
438
|
-
expect(result).toEqual({
|
|
439
|
-
success: false,
|
|
440
|
-
errorCode: 'record_not_found',
|
|
441
|
-
errorMessage: expect.any(String),
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
if (allowRecordKeys) {
|
|
445
|
-
it('should be able to use a record key to access the item', async () => {
|
|
446
|
-
const result = await manager.getItem({
|
|
447
|
-
recordName: key,
|
|
602
|
+
it('should return record_not_found if the record doesnt exist', async () => {
|
|
603
|
+
const result = await manager.eraseItem({
|
|
604
|
+
recordName: 'missing',
|
|
448
605
|
userId,
|
|
449
606
|
address: 'address2',
|
|
450
607
|
instances: [],
|
|
451
608
|
});
|
|
452
|
-
expect(result).toEqual({
|
|
453
|
-
success: true,
|
|
454
|
-
item: createStoreItem({
|
|
455
|
-
address: 'address2',
|
|
456
|
-
markers: [PRIVATE_MARKER],
|
|
457
|
-
}),
|
|
458
|
-
});
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
else {
|
|
462
|
-
it('should return not_authorized if record keys are not allowed', async () => {
|
|
463
|
-
const result = await manager.getItem({
|
|
464
|
-
recordName: key,
|
|
465
|
-
userId: otherUserId,
|
|
466
|
-
address: 'address2',
|
|
467
|
-
instances: [],
|
|
468
|
-
});
|
|
469
609
|
expect(result).toEqual({
|
|
470
610
|
success: false,
|
|
471
|
-
errorCode: '
|
|
611
|
+
errorCode: 'record_not_found',
|
|
472
612
|
errorMessage: expect.any(String),
|
|
473
|
-
reason: {
|
|
474
|
-
type: 'missing_permission',
|
|
475
|
-
recordName,
|
|
476
|
-
action: 'read',
|
|
477
|
-
resourceKind,
|
|
478
|
-
resourceId: 'address2',
|
|
479
|
-
subjectType: 'user',
|
|
480
|
-
subjectId: otherUserId,
|
|
481
|
-
},
|
|
482
613
|
});
|
|
614
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address2')).resolves.toBeTruthy();
|
|
483
615
|
});
|
|
484
|
-
}
|
|
485
|
-
});
|
|
486
|
-
describe('eraseItem()', () => {
|
|
487
|
-
beforeEach(async () => {
|
|
488
|
-
await manager.recordItem({
|
|
489
|
-
recordKeyOrRecordName: recordName,
|
|
490
|
-
item: createInputItem({
|
|
491
|
-
address: 'address',
|
|
492
|
-
markers: [PUBLIC_READ_MARKER],
|
|
493
|
-
}),
|
|
494
|
-
userId,
|
|
495
|
-
instances: [],
|
|
496
|
-
});
|
|
497
|
-
await manager.recordItem({
|
|
498
|
-
recordKeyOrRecordName: recordName,
|
|
499
|
-
item: createInputItem({
|
|
500
|
-
address: 'address2',
|
|
501
|
-
markers: [PUBLIC_READ_MARKER],
|
|
502
|
-
}),
|
|
503
|
-
userId,
|
|
504
|
-
instances: [],
|
|
505
|
-
});
|
|
506
|
-
await manager.recordItem({
|
|
507
|
-
recordKeyOrRecordName: recordName,
|
|
508
|
-
item: createInputItem({
|
|
509
|
-
address: 'address3',
|
|
510
|
-
markers: [PUBLIC_READ_MARKER],
|
|
511
|
-
}),
|
|
512
|
-
userId,
|
|
513
|
-
instances: [],
|
|
514
|
-
});
|
|
515
|
-
});
|
|
516
|
-
it('should erase the item if the user has access', async () => {
|
|
517
|
-
const result = await manager.eraseItem({
|
|
518
|
-
recordName: recordName,
|
|
519
|
-
userId,
|
|
520
|
-
address: 'address2',
|
|
521
|
-
instances: [],
|
|
522
|
-
});
|
|
523
|
-
expect(result).toEqual({
|
|
524
|
-
success: true,
|
|
525
|
-
});
|
|
526
|
-
await expect(itemsStore.getItemByAddress(recordName, 'address2')).resolves.toBeFalsy();
|
|
527
616
|
});
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
617
|
+
}
|
|
618
|
+
if (allowedActions.includes('list')) {
|
|
619
|
+
describe('listItems()', () => {
|
|
620
|
+
let items;
|
|
621
|
+
beforeEach(async () => {
|
|
622
|
+
items = [];
|
|
623
|
+
for (let i = 0; i < 20; i++) {
|
|
624
|
+
const item = createStoreItem({
|
|
625
|
+
address: 'address' + i,
|
|
626
|
+
markers: [PRIVATE_MARKER],
|
|
627
|
+
});
|
|
628
|
+
await itemsStore.createItem(recordName, item);
|
|
629
|
+
items.push(createOutputItem({
|
|
630
|
+
address: item.address,
|
|
631
|
+
markers: item.markers,
|
|
632
|
+
}));
|
|
633
|
+
}
|
|
539
634
|
});
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
userId: otherUserId,
|
|
546
|
-
address: 'address2',
|
|
635
|
+
it('should return a list of items', async () => {
|
|
636
|
+
const result = (await manager.listItems({
|
|
637
|
+
recordName: recordName,
|
|
638
|
+
userId,
|
|
639
|
+
startingAddress: null,
|
|
547
640
|
instances: [],
|
|
548
|
-
});
|
|
641
|
+
}));
|
|
549
642
|
expect(result).toEqual({
|
|
550
643
|
success: true,
|
|
644
|
+
recordName: recordName,
|
|
645
|
+
items: expect.any(Array),
|
|
646
|
+
totalCount: 20,
|
|
551
647
|
});
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const result = await manager.eraseItem({
|
|
558
|
-
recordName: key,
|
|
559
|
-
userId: otherUserId,
|
|
560
|
-
address: 'address2',
|
|
561
|
-
instances: [],
|
|
562
|
-
});
|
|
563
|
-
expect(result).toEqual({
|
|
564
|
-
success: false,
|
|
565
|
-
errorCode: 'not_authorized',
|
|
566
|
-
errorMessage: expect.any(String),
|
|
567
|
-
reason: {
|
|
568
|
-
type: 'missing_permission',
|
|
569
|
-
recordName,
|
|
570
|
-
action: 'delete',
|
|
571
|
-
resourceKind,
|
|
572
|
-
resourceId: 'address2',
|
|
573
|
-
subjectType: 'user',
|
|
574
|
-
subjectId: otherUserId,
|
|
575
|
-
},
|
|
576
|
-
});
|
|
577
|
-
await expect(itemsStore.getItemByAddress(recordName, 'address2')).resolves.toBeTruthy();
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
it('should return record_not_found if the record doesnt exist', async () => {
|
|
581
|
-
const result = await manager.eraseItem({
|
|
582
|
-
recordName: 'missing',
|
|
583
|
-
userId,
|
|
584
|
-
address: 'address2',
|
|
585
|
-
instances: [],
|
|
586
|
-
});
|
|
587
|
-
expect(result).toEqual({
|
|
588
|
-
success: false,
|
|
589
|
-
errorCode: 'record_not_found',
|
|
590
|
-
errorMessage: expect.any(String),
|
|
648
|
+
const expectedItems = items.slice(0, 10);
|
|
649
|
+
expect(result.items.length).toBe(expectedItems.length);
|
|
650
|
+
for (let i = 0; i < expectedItems.length; i++) {
|
|
651
|
+
expect(result.items[i]).toMatchObject(expectedItems[i]);
|
|
652
|
+
}
|
|
591
653
|
});
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
654
|
+
if (allowRecordKeys) {
|
|
655
|
+
it('should be able to use a record key', async () => {
|
|
656
|
+
const result = (await manager.listItems({
|
|
657
|
+
recordName: key,
|
|
658
|
+
userId: otherUserId,
|
|
659
|
+
startingAddress: null,
|
|
660
|
+
instances: [],
|
|
661
|
+
}));
|
|
662
|
+
expect(result).toEqual({
|
|
663
|
+
success: true,
|
|
664
|
+
recordName: recordName,
|
|
665
|
+
items: expect.any(Array),
|
|
666
|
+
totalCount: 20,
|
|
667
|
+
});
|
|
668
|
+
const expectedItems = items.slice(0, 10);
|
|
669
|
+
expect(result.items.length).toBe(expectedItems.length);
|
|
670
|
+
for (let i = 0; i < expectedItems.length; i++) {
|
|
671
|
+
expect(result.items[i]).toMatchObject(expectedItems[i]);
|
|
672
|
+
}
|
|
603
673
|
});
|
|
604
|
-
await itemsStore.createItem(recordName, item);
|
|
605
|
-
items.push(createOutputItem({
|
|
606
|
-
address: item.address,
|
|
607
|
-
markers: item.markers,
|
|
608
|
-
}));
|
|
609
674
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
675
|
+
else {
|
|
676
|
+
it('should return not_authorized if record keys are not allowed', async () => {
|
|
677
|
+
const result = await manager.listItems({
|
|
678
|
+
recordName: key,
|
|
679
|
+
userId: otherUserId,
|
|
680
|
+
startingAddress: null,
|
|
681
|
+
instances: [],
|
|
682
|
+
});
|
|
683
|
+
expect(result).toEqual({
|
|
684
|
+
success: false,
|
|
685
|
+
errorCode: 'not_authorized',
|
|
686
|
+
errorMessage: expect.any(String),
|
|
687
|
+
reason: {
|
|
688
|
+
type: 'missing_permission',
|
|
689
|
+
recordName,
|
|
690
|
+
action: 'list',
|
|
691
|
+
resourceKind,
|
|
692
|
+
subjectType: 'user',
|
|
693
|
+
subjectId: otherUserId,
|
|
694
|
+
},
|
|
695
|
+
});
|
|
696
|
+
});
|
|
628
697
|
}
|
|
629
|
-
|
|
630
|
-
if (allowRecordKeys) {
|
|
631
|
-
it('should be able to use a record key', async () => {
|
|
698
|
+
it('should return items after the given starting address', async () => {
|
|
632
699
|
const result = (await manager.listItems({
|
|
633
|
-
recordName:
|
|
634
|
-
userId
|
|
635
|
-
startingAddress:
|
|
700
|
+
recordName: recordName,
|
|
701
|
+
userId,
|
|
702
|
+
startingAddress: 'address3',
|
|
636
703
|
instances: [],
|
|
637
704
|
}));
|
|
638
705
|
expect(result).toEqual({
|
|
@@ -641,19 +708,17 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
641
708
|
items: expect.any(Array),
|
|
642
709
|
totalCount: 20,
|
|
643
710
|
});
|
|
644
|
-
const expectedItems = items.slice(
|
|
711
|
+
const expectedItems = items.slice(4, 10);
|
|
645
712
|
expect(result.items.length).toBe(expectedItems.length);
|
|
646
713
|
for (let i = 0; i < expectedItems.length; i++) {
|
|
647
714
|
expect(result.items[i]).toMatchObject(expectedItems[i]);
|
|
648
715
|
}
|
|
649
716
|
});
|
|
650
|
-
|
|
651
|
-
else {
|
|
652
|
-
it('should return not_authorized if record keys are not allowed', async () => {
|
|
717
|
+
it('should return not_authorized if the user does not have access to the account marker', async () => {
|
|
653
718
|
const result = await manager.listItems({
|
|
654
|
-
recordName:
|
|
719
|
+
recordName: recordName,
|
|
655
720
|
userId: otherUserId,
|
|
656
|
-
startingAddress:
|
|
721
|
+
startingAddress: 'address3',
|
|
657
722
|
instances: [],
|
|
658
723
|
});
|
|
659
724
|
expect(result).toEqual({
|
|
@@ -661,125 +726,39 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
661
726
|
errorCode: 'not_authorized',
|
|
662
727
|
errorMessage: expect.any(String),
|
|
663
728
|
reason: {
|
|
664
|
-
type: 'missing_permission',
|
|
665
|
-
recordName,
|
|
666
729
|
action: 'list',
|
|
667
|
-
|
|
668
|
-
|
|
730
|
+
recordName: recordName,
|
|
731
|
+
resourceId: undefined,
|
|
732
|
+
resourceKind: resourceKind,
|
|
669
733
|
subjectId: otherUserId,
|
|
734
|
+
subjectType: 'user',
|
|
735
|
+
type: 'missing_permission',
|
|
670
736
|
},
|
|
671
737
|
});
|
|
672
738
|
});
|
|
673
|
-
}
|
|
674
|
-
it('should return items after the given starting address', async () => {
|
|
675
|
-
const result = (await manager.listItems({
|
|
676
|
-
recordName: recordName,
|
|
677
|
-
userId,
|
|
678
|
-
startingAddress: 'address3',
|
|
679
|
-
instances: [],
|
|
680
|
-
}));
|
|
681
|
-
expect(result).toEqual({
|
|
682
|
-
success: true,
|
|
683
|
-
recordName: recordName,
|
|
684
|
-
items: expect.any(Array),
|
|
685
|
-
totalCount: 20,
|
|
686
|
-
});
|
|
687
|
-
const expectedItems = items.slice(4, 10);
|
|
688
|
-
expect(result.items.length).toBe(expectedItems.length);
|
|
689
|
-
for (let i = 0; i < expectedItems.length; i++) {
|
|
690
|
-
expect(result.items[i]).toMatchObject(expectedItems[i]);
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
it('should return not_authorized if the user does not have access to the account marker', async () => {
|
|
694
|
-
const result = await manager.listItems({
|
|
695
|
-
recordName: recordName,
|
|
696
|
-
userId: otherUserId,
|
|
697
|
-
startingAddress: 'address3',
|
|
698
|
-
instances: [],
|
|
699
|
-
});
|
|
700
|
-
expect(result).toEqual({
|
|
701
|
-
success: false,
|
|
702
|
-
errorCode: 'not_authorized',
|
|
703
|
-
errorMessage: expect.any(String),
|
|
704
|
-
reason: {
|
|
705
|
-
action: 'list',
|
|
706
|
-
recordName: recordName,
|
|
707
|
-
resourceId: undefined,
|
|
708
|
-
resourceKind: resourceKind,
|
|
709
|
-
subjectId: otherUserId,
|
|
710
|
-
subjectType: 'user',
|
|
711
|
-
type: 'missing_permission',
|
|
712
|
-
},
|
|
713
|
-
});
|
|
714
|
-
});
|
|
715
|
-
});
|
|
716
|
-
describe('listItemsByMarker()', () => {
|
|
717
|
-
let items;
|
|
718
|
-
beforeEach(async () => {
|
|
719
|
-
items = [];
|
|
720
|
-
for (let i = 0; i < 40; i++) {
|
|
721
|
-
const item = createStoreItem({
|
|
722
|
-
address: 'address' + i,
|
|
723
|
-
markers: [
|
|
724
|
-
i % 2 === 0 ? PRIVATE_MARKER : PUBLIC_READ_MARKER,
|
|
725
|
-
],
|
|
726
|
-
});
|
|
727
|
-
await itemsStore.createItem(recordName, item);
|
|
728
|
-
items.push(createOutputItem({
|
|
729
|
-
address: item.address,
|
|
730
|
-
markers: item.markers,
|
|
731
|
-
}));
|
|
732
|
-
}
|
|
733
|
-
});
|
|
734
|
-
it('should return a list of items that have the given marker', async () => {
|
|
735
|
-
const result = (await manager.listItemsByMarker({
|
|
736
|
-
recordName: recordName,
|
|
737
|
-
userId,
|
|
738
|
-
marker: PRIVATE_MARKER,
|
|
739
|
-
startingAddress: null,
|
|
740
|
-
instances: [],
|
|
741
|
-
}));
|
|
742
|
-
expect(result).toEqual({
|
|
743
|
-
success: true,
|
|
744
|
-
recordName: recordName,
|
|
745
|
-
items: expect.any(Array),
|
|
746
|
-
totalCount: 20,
|
|
747
|
-
});
|
|
748
|
-
const expectedItems = items
|
|
749
|
-
.filter((i) => i.markers.indexOf(PRIVATE_MARKER) >= 0)
|
|
750
|
-
.slice(0, 10);
|
|
751
|
-
expect(result.items.length).toBe(expectedItems.length);
|
|
752
|
-
for (let i = 0; i < expectedItems.length; i++) {
|
|
753
|
-
expect(result.items[i]).toMatchObject(expectedItems[i]);
|
|
754
|
-
}
|
|
755
739
|
});
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
740
|
+
describe('listItemsByMarker()', () => {
|
|
741
|
+
let items;
|
|
742
|
+
beforeEach(async () => {
|
|
743
|
+
items = [];
|
|
744
|
+
for (let i = 0; i < 40; i++) {
|
|
745
|
+
const item = createStoreItem({
|
|
746
|
+
address: 'address' + i,
|
|
747
|
+
markers: [
|
|
748
|
+
i % 2 === 0 ? PRIVATE_MARKER : PUBLIC_READ_MARKER,
|
|
749
|
+
],
|
|
750
|
+
});
|
|
751
|
+
await itemsStore.createItem(recordName, item);
|
|
752
|
+
items.push(createOutputItem({
|
|
753
|
+
address: item.address,
|
|
754
|
+
markers: item.markers,
|
|
755
|
+
}));
|
|
756
|
+
}
|
|
769
757
|
});
|
|
770
|
-
|
|
771
|
-
.filter((i) => i.markers.indexOf(PRIVATE_MARKER) >= 0)
|
|
772
|
-
.slice(1, 11);
|
|
773
|
-
expect(result.items.length).toBe(expectedItems.length);
|
|
774
|
-
for (let i = 0; i < expectedItems.length; i++) {
|
|
775
|
-
expect(result.items[i]).toMatchObject(expectedItems[i]);
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
if (allowRecordKeys) {
|
|
779
|
-
it('should be able to use a record key', async () => {
|
|
758
|
+
it('should return a list of items that have the given marker', async () => {
|
|
780
759
|
const result = (await manager.listItemsByMarker({
|
|
781
|
-
recordName:
|
|
782
|
-
userId
|
|
760
|
+
recordName: recordName,
|
|
761
|
+
userId,
|
|
783
762
|
marker: PRIVATE_MARKER,
|
|
784
763
|
startingAddress: null,
|
|
785
764
|
instances: [],
|
|
@@ -798,54 +777,100 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
798
777
|
expect(result.items[i]).toMatchObject(expectedItems[i]);
|
|
799
778
|
}
|
|
800
779
|
});
|
|
801
|
-
|
|
802
|
-
else {
|
|
803
|
-
it('should return not_authorized if record keys are not allowed', async () => {
|
|
780
|
+
it('should return a list of items that are after the starting address', async () => {
|
|
804
781
|
const result = (await manager.listItemsByMarker({
|
|
805
|
-
recordName:
|
|
782
|
+
recordName: recordName,
|
|
783
|
+
userId,
|
|
784
|
+
marker: PRIVATE_MARKER,
|
|
785
|
+
startingAddress: 'address1',
|
|
786
|
+
instances: [],
|
|
787
|
+
}));
|
|
788
|
+
expect(result).toEqual({
|
|
789
|
+
success: true,
|
|
790
|
+
recordName: recordName,
|
|
791
|
+
items: expect.any(Array),
|
|
792
|
+
totalCount: 20,
|
|
793
|
+
});
|
|
794
|
+
const expectedItems = items
|
|
795
|
+
.filter((i) => i.markers.indexOf(PRIVATE_MARKER) >= 0)
|
|
796
|
+
.slice(1, 11);
|
|
797
|
+
expect(result.items.length).toBe(expectedItems.length);
|
|
798
|
+
for (let i = 0; i < expectedItems.length; i++) {
|
|
799
|
+
expect(result.items[i]).toMatchObject(expectedItems[i]);
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
if (allowRecordKeys) {
|
|
803
|
+
it('should be able to use a record key', async () => {
|
|
804
|
+
const result = (await manager.listItemsByMarker({
|
|
805
|
+
recordName: key,
|
|
806
|
+
userId: otherUserId,
|
|
807
|
+
marker: PRIVATE_MARKER,
|
|
808
|
+
startingAddress: null,
|
|
809
|
+
instances: [],
|
|
810
|
+
}));
|
|
811
|
+
expect(result).toEqual({
|
|
812
|
+
success: true,
|
|
813
|
+
recordName: recordName,
|
|
814
|
+
items: expect.any(Array),
|
|
815
|
+
totalCount: 20,
|
|
816
|
+
});
|
|
817
|
+
const expectedItems = items
|
|
818
|
+
.filter((i) => i.markers.indexOf(PRIVATE_MARKER) >= 0)
|
|
819
|
+
.slice(0, 10);
|
|
820
|
+
expect(result.items.length).toBe(expectedItems.length);
|
|
821
|
+
for (let i = 0; i < expectedItems.length; i++) {
|
|
822
|
+
expect(result.items[i]).toMatchObject(expectedItems[i]);
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
else {
|
|
827
|
+
it('should return not_authorized if record keys are not allowed', async () => {
|
|
828
|
+
const result = (await manager.listItemsByMarker({
|
|
829
|
+
recordName: key,
|
|
830
|
+
userId: otherUserId,
|
|
831
|
+
marker: PRIVATE_MARKER,
|
|
832
|
+
startingAddress: null,
|
|
833
|
+
instances: [],
|
|
834
|
+
}));
|
|
835
|
+
expect(result).toEqual({
|
|
836
|
+
success: false,
|
|
837
|
+
errorCode: 'not_authorized',
|
|
838
|
+
errorMessage: expect.any(String),
|
|
839
|
+
reason: {
|
|
840
|
+
type: 'missing_permission',
|
|
841
|
+
recordName,
|
|
842
|
+
action: 'list',
|
|
843
|
+
resourceKind,
|
|
844
|
+
subjectType: 'user',
|
|
845
|
+
subjectId: otherUserId,
|
|
846
|
+
},
|
|
847
|
+
});
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
it('should return not_authorized if the user does not have access to the marker', async () => {
|
|
851
|
+
const result = await manager.listItemsByMarker({
|
|
852
|
+
recordName: recordName,
|
|
806
853
|
userId: otherUserId,
|
|
807
854
|
marker: PRIVATE_MARKER,
|
|
808
855
|
startingAddress: null,
|
|
809
856
|
instances: [],
|
|
810
|
-
})
|
|
857
|
+
});
|
|
811
858
|
expect(result).toEqual({
|
|
812
859
|
success: false,
|
|
813
860
|
errorCode: 'not_authorized',
|
|
814
861
|
errorMessage: expect.any(String),
|
|
815
862
|
reason: {
|
|
816
|
-
type: 'missing_permission',
|
|
817
|
-
recordName,
|
|
818
863
|
action: 'list',
|
|
819
|
-
|
|
820
|
-
|
|
864
|
+
recordName: recordName,
|
|
865
|
+
resourceId: undefined,
|
|
866
|
+
resourceKind: resourceKind,
|
|
821
867
|
subjectId: otherUserId,
|
|
868
|
+
subjectType: 'user',
|
|
869
|
+
type: 'missing_permission',
|
|
822
870
|
},
|
|
823
871
|
});
|
|
824
872
|
});
|
|
825
|
-
}
|
|
826
|
-
it('should return not_authorized if the user does not have access to the marker', async () => {
|
|
827
|
-
const result = await manager.listItemsByMarker({
|
|
828
|
-
recordName: recordName,
|
|
829
|
-
userId: otherUserId,
|
|
830
|
-
marker: PRIVATE_MARKER,
|
|
831
|
-
startingAddress: null,
|
|
832
|
-
instances: [],
|
|
833
|
-
});
|
|
834
|
-
expect(result).toEqual({
|
|
835
|
-
success: false,
|
|
836
|
-
errorCode: 'not_authorized',
|
|
837
|
-
errorMessage: expect.any(String),
|
|
838
|
-
reason: {
|
|
839
|
-
action: 'list',
|
|
840
|
-
recordName: recordName,
|
|
841
|
-
resourceId: undefined,
|
|
842
|
-
resourceKind: resourceKind,
|
|
843
|
-
subjectId: otherUserId,
|
|
844
|
-
subjectType: 'user',
|
|
845
|
-
type: 'missing_permission',
|
|
846
|
-
},
|
|
847
|
-
});
|
|
848
873
|
});
|
|
849
|
-
}
|
|
874
|
+
}
|
|
850
875
|
}
|
|
851
876
|
//# sourceMappingURL=CrudRecordsControllerTests.js.map
|