fable 3.0.32 → 3.0.34
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/.config/configstore/update-notifier-npm.json +1 -1
- package/.config/retold-harness/MySQL-Laden-Entry.sh +17 -0
- package/.config/retold-harness/MySQL-Security.sql +5 -0
- package/.config/retold-harness/bookstore-api-endpoint-exercises.paw +0 -0
- package/.config/retold-harness/bookstore-configuration.json +28 -0
- package/.config/retold-harness/bookstore-import-books-run.js +1 -0
- package/.config/retold-harness/bookstore-import-books.js +214 -0
- package/.config/retold-harness/bookstore-serve-meadow-endpoint-apis-IPC.js +137 -0
- package/.config/retold-harness/bookstore-serve-meadow-endpoint-apis.js +128 -0
- package/.config/retold-harness/data/books.csv +10001 -0
- package/.config/retold-harness/model/ddl/BookStore.ddl +66 -0
- package/.config/retold-harness/model/generated_diagram/README.md +1 -0
- package/.config/retold-harness/model/generated_diagram/Stricture_Output.dot +13 -0
- package/.config/retold-harness/model/generated_diagram/Stricture_Output.png +0 -0
- package/.config/retold-harness/model/generated_documentation/Dictionary.md +18 -0
- package/.config/retold-harness/model/generated_documentation/Model-Author.md +20 -0
- package/.config/retold-harness/model/generated_documentation/Model-Book.md +26 -0
- package/.config/retold-harness/model/generated_documentation/Model-BookAuthorJoin.md +14 -0
- package/.config/retold-harness/model/generated_documentation/Model-BookPrice.md +25 -0
- package/.config/retold-harness/model/generated_documentation/Model-Review.md +22 -0
- package/.config/retold-harness/model/generated_documentation/ModelChangeTracking.md +17 -0
- package/.config/retold-harness/model/generated_documentation/README.md +1 -0
- package/.config/retold-harness/model/json_schema/BookStore-Extended.json +915 -0
- package/.config/retold-harness/model/json_schema/BookStore-PICT.json +1 -0
- package/.config/retold-harness/model/json_schema/BookStore.json +280 -0
- package/.config/retold-harness/model/json_schema/README.md +1 -0
- package/.config/retold-harness/model/manual_scripts/DropTables.sql +5 -0
- package/.config/retold-harness/model/manual_scripts/README.md +2 -0
- package/.config/retold-harness/model/meadow_schema/BookStore-MeadowSchema-Author.json +220 -0
- package/.config/retold-harness/model/meadow_schema/BookStore-MeadowSchema-Book.json +268 -0
- package/.config/retold-harness/model/meadow_schema/BookStore-MeadowSchema-BookAuthorJoin.json +172 -0
- package/.config/retold-harness/model/meadow_schema/BookStore-MeadowSchema-BookPrice.json +260 -0
- package/.config/retold-harness/model/meadow_schema/BookStore-MeadowSchema-Review.json +236 -0
- package/.config/retold-harness/model/meadow_schema/README.md +1 -0
- package/.config/retold-harness/model/sql_create/BookStore-CreateDatabase.mysql.sql +116 -0
- package/.config/retold-harness/model/sql_create/README.md +1 -0
- package/.config/retold-harness/package.json +19 -0
- package/.config/retold-harness/test_old/Tests.js +3243 -0
- package/.config/retold-harness/test_old/untitled.js +88 -0
- package/.config/vscode-sqltools/runningInfo.json +13 -0
- package/.vscode/settings.json +17 -0
- package/Dockerfile_LUXURYCode +18 -0
- package/README.md +1 -1
- package/dist/fable.compatible.js +1 -11
- package/dist/fable.compatible.min.js +2 -78
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +1 -11
- package/dist/fable.min.js +2 -70
- package/dist/fable.min.js.map +1 -1
- package/package.json +5 -5
- package/source/Fable-ServiceManager.js +0 -1
- package/source/Fable.js +5 -1
- package/source/services/Fable-Service-DataFormat.js +0 -1
|
@@ -0,0 +1,3243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for the MeadowEndpoints Service
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Steven Velozo <steven@velozo.com>
|
|
5
|
+
*/
|
|
6
|
+
const Chai = require("chai");
|
|
7
|
+
const Expect = Chai.expect;
|
|
8
|
+
const Assert = Chai.assert;
|
|
9
|
+
|
|
10
|
+
const libFable = require('fable');
|
|
11
|
+
|
|
12
|
+
const libOrator = require('orator');
|
|
13
|
+
const libOratorServiceServerRestify = require('orator-serviceserver-restify');
|
|
14
|
+
|
|
15
|
+
const libMeadow = require('meadow');
|
|
16
|
+
const libMeadowEndpoints = require('../source/Meadow-Endpoints.js');
|
|
17
|
+
|
|
18
|
+
const libSuperTest = require('supertest');
|
|
19
|
+
const libMySQL = require('mysql2');
|
|
20
|
+
const libAsync = require('async');
|
|
21
|
+
|
|
22
|
+
const _Fable = new libFable(
|
|
23
|
+
{
|
|
24
|
+
Product: 'MockOratorAlternate',
|
|
25
|
+
ProductVersion: '0.0.0',
|
|
26
|
+
|
|
27
|
+
"UnauthorizedRequestDelay": 10,
|
|
28
|
+
|
|
29
|
+
MeadowAuthenticationMode: 'LoggedIn',
|
|
30
|
+
MeadowAuthorizationMode: 'SimpleOwnership',
|
|
31
|
+
|
|
32
|
+
APIServerPort: 9080,
|
|
33
|
+
|
|
34
|
+
MySQL:
|
|
35
|
+
{
|
|
36
|
+
// This is queued up for Travis defaults.
|
|
37
|
+
Server: "localhost",
|
|
38
|
+
Port: 3306,
|
|
39
|
+
User: process.env.DEV_MYSQL_USER || "root",
|
|
40
|
+
Password: process.env.DEV_MYSQL_PASS || "123456789",
|
|
41
|
+
Database: "FableTest",
|
|
42
|
+
ConnectionPoolLimit: 20
|
|
43
|
+
},
|
|
44
|
+
ConfigFile: __dirname + "/../MeadowTest-Settings.json"
|
|
45
|
+
});
|
|
46
|
+
_Fable.settings.DataIsInitialized = false;
|
|
47
|
+
|
|
48
|
+
// Connect to SQL, put the connection in the magic location
|
|
49
|
+
_Fable.MeadowMySQLConnectionPool = libMySQL.createPool
|
|
50
|
+
(
|
|
51
|
+
{
|
|
52
|
+
connectionLimit: _Fable.settings.MySQL.ConnectionPoolLimit,
|
|
53
|
+
host: _Fable.settings.MySQL.Server,
|
|
54
|
+
port: _Fable.settings.MySQL.Port,
|
|
55
|
+
user: _Fable.settings.MySQL.User,
|
|
56
|
+
password: _Fable.settings.MySQL.Password,
|
|
57
|
+
database: _Fable.settings.MySQL.Database,
|
|
58
|
+
namedPlaceholders: true
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
var _MockSessionValidUser = (
|
|
63
|
+
{
|
|
64
|
+
SessionID: '0000-VALID',
|
|
65
|
+
UserID: 37,
|
|
66
|
+
UserRole: 'User',
|
|
67
|
+
UserRoleIndex: 1,
|
|
68
|
+
LoggedIn: true,
|
|
69
|
+
DeviceID: 'TEST-HARNESS',
|
|
70
|
+
CustomerID: 1
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
var _AnimalSchema = require('./Animal.json');
|
|
74
|
+
|
|
75
|
+
// Now that we have some test data, wire up the endpoints!
|
|
76
|
+
|
|
77
|
+
// Load up a Meadow (pointing at the Animal database)
|
|
78
|
+
const _Meadow = require('meadow')
|
|
79
|
+
.new(_Fable, 'FableTest')
|
|
80
|
+
.setProvider('MySQL')
|
|
81
|
+
.setSchema(_AnimalSchema.Schema)
|
|
82
|
+
.setJsonSchema(_AnimalSchema.JsonSchema)
|
|
83
|
+
.setDefaultIdentifier(_AnimalSchema.DefaultIdentifier)
|
|
84
|
+
.setDefault(_AnimalSchema.DefaultObject);
|
|
85
|
+
// Instantiate the endpoints
|
|
86
|
+
const _MeadowEndpoints = require('../source/Meadow-Endpoints.js').new(_Meadow);
|
|
87
|
+
|
|
88
|
+
// Instantiate the service server, using restify
|
|
89
|
+
let _Orator = new libOrator(_Fable, libOratorServiceServerRestify);
|
|
90
|
+
|
|
91
|
+
suite
|
|
92
|
+
(
|
|
93
|
+
'Meadow-Endpoints',
|
|
94
|
+
() =>
|
|
95
|
+
{
|
|
96
|
+
let getAnimalInsert = function(pName, pType)
|
|
97
|
+
{
|
|
98
|
+
return "INSERT INTO `FableTest` (`IDAnimal`, `GUIDAnimal`, `CreateDate`, `CreatingIDUser`, `UpdateDate`, `UpdatingIDUser`, `Deleted`, `DeleteDate`, `DeletingIDUser`, `Name`, `Type`, `IDCustomer`) VALUES (NULL, '00000000-0000-0000-0000-000000000000', NOW(), 1, NOW(), 1, 0, NULL, 0, '"+pName+"', '"+pType+"', 1); ";
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
setup
|
|
102
|
+
(
|
|
103
|
+
(fDone)=>
|
|
104
|
+
{
|
|
105
|
+
// Only do this for the first test, so we persist database state across suites
|
|
106
|
+
if (!_Fable.settings.DataIsInitialized)
|
|
107
|
+
{
|
|
108
|
+
// Tear down previous test data, rebuild records
|
|
109
|
+
libAsync.waterfall(
|
|
110
|
+
[
|
|
111
|
+
(fCallBack) =>
|
|
112
|
+
{
|
|
113
|
+
_Orator.initializeServiceServer((pQueryError, pResponse)=>{ fCallBack(); });
|
|
114
|
+
},
|
|
115
|
+
(fCallBack) =>
|
|
116
|
+
{
|
|
117
|
+
console.log('a')
|
|
118
|
+
_Fable.MeadowMySQLConnectionPool.query('DROP TABLE IF EXISTS FableTest', (pQueryError, pResponse)=>{ fCallBack(); });
|
|
119
|
+
},
|
|
120
|
+
(fCallBack) =>
|
|
121
|
+
{
|
|
122
|
+
_Fable.MeadowMySQLConnectionPool.query("CREATE TABLE IF NOT EXISTS FableTest (IDAnimal INT UNSIGNED NOT NULL AUTO_INCREMENT, GUIDAnimal CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', CreateDate DATETIME, CreatingIDUser INT NOT NULL DEFAULT '0', UpdateDate DATETIME, UpdatingIDUser INT NOT NULL DEFAULT '0', Deleted TINYINT NOT NULL DEFAULT '0', DeleteDate DATETIME, DeletingIDUser INT NOT NULL DEFAULT '0', Name CHAR(128) NOT NULL DEFAULT '', Type CHAR(128) NOT NULL DEFAULT '', IDCustomer INT NOT NULL DEFAULT '0', PRIMARY KEY (IDAnimal) );", (pQueryError, pResponse)=>{ fCallBack(); });
|
|
123
|
+
},
|
|
124
|
+
(fCallBack) =>
|
|
125
|
+
{
|
|
126
|
+
console.log('x')
|
|
127
|
+
_Fable.MeadowMySQLConnectionPool.query(getAnimalInsert('Foo Foo', 'Bunny'), (pQueryError, pResponse)=>{ fCallBack(); });
|
|
128
|
+
},
|
|
129
|
+
(fCallBack) =>
|
|
130
|
+
{
|
|
131
|
+
console.log('z')
|
|
132
|
+
_Fable.MeadowMySQLConnectionPool.query(getAnimalInsert('Red Riding Hood', 'Girl'), (pQueryError, pResponse)=>{ fCallBack(); });
|
|
133
|
+
},
|
|
134
|
+
(fCallBack) =>
|
|
135
|
+
{
|
|
136
|
+
_Fable.MeadowMySQLConnectionPool.query(getAnimalInsert('Red', 'Dog'), (pQueryError, pResponse)=>{ fCallBack(); });
|
|
137
|
+
},
|
|
138
|
+
(fCallBack) =>
|
|
139
|
+
{
|
|
140
|
+
_Fable.MeadowMySQLConnectionPool.query(getAnimalInsert('Spot', 'Dog'), (pQueryError, pResponse)=>{ fCallBack(); });
|
|
141
|
+
},
|
|
142
|
+
(fCallBack) =>
|
|
143
|
+
{
|
|
144
|
+
_Fable.MeadowMySQLConnectionPool.query(getAnimalInsert('Gertrude', 'Frog'), (pQueryError, pResponse)=>{ fCallBack(); });
|
|
145
|
+
},
|
|
146
|
+
(fCallBack) =>
|
|
147
|
+
{
|
|
148
|
+
// Wire the endpoints up
|
|
149
|
+
_MeadowEndpoints.connectRoutes(_Orator.webServer);
|
|
150
|
+
|
|
151
|
+
_Orator.startWebServer ((pQueryError, pResponse)=>{ fCallBack(); });
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
(pError) =>
|
|
155
|
+
{
|
|
156
|
+
_Fable.settings.DataIsInitialized = true;
|
|
157
|
+
return fDone();
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
else
|
|
162
|
+
{
|
|
163
|
+
return fDone();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
suite
|
|
169
|
+
(
|
|
170
|
+
'Object Sanity',
|
|
171
|
+
() =>
|
|
172
|
+
{
|
|
173
|
+
test
|
|
174
|
+
(
|
|
175
|
+
'initialize should build a happy little object',
|
|
176
|
+
(fDone) =>
|
|
177
|
+
{
|
|
178
|
+
Expect(_MeadowEndpoints).to.be.an('object', 'MeadowEndpoints should initialize as an object directly from the require statement.');
|
|
179
|
+
return fDone();
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
suite
|
|
186
|
+
(
|
|
187
|
+
'Basic Server Routes',
|
|
188
|
+
()=>
|
|
189
|
+
{
|
|
190
|
+
test
|
|
191
|
+
(
|
|
192
|
+
'create: create a record',
|
|
193
|
+
function(fDone)
|
|
194
|
+
{
|
|
195
|
+
var tmpRecord = {Name:'BatBrains', Type:'Mammoth'};
|
|
196
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
197
|
+
libSuperTest('http://localhost:9080/')
|
|
198
|
+
.post('1.0/FableTest')
|
|
199
|
+
.send(tmpRecord)
|
|
200
|
+
.end(
|
|
201
|
+
function(pError, pResponse)
|
|
202
|
+
{
|
|
203
|
+
// Expect response to be the record we just created.
|
|
204
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
205
|
+
Expect(tmpResult.Type).to.equal('Mammoth');
|
|
206
|
+
Expect(tmpResult.CreatingIDUser).to.equal(37);
|
|
207
|
+
fDone();
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
test
|
|
213
|
+
(
|
|
214
|
+
'create: create a record',
|
|
215
|
+
function(fDone)
|
|
216
|
+
{
|
|
217
|
+
var tmpRecord = {Name:'BatBrains', Type:'Mammoth'};
|
|
218
|
+
_MockSessionValidUser.UserRoleIndex = 1;
|
|
219
|
+
libSuperTest('http://localhost:9080/')
|
|
220
|
+
.post('1.0/FableTest')
|
|
221
|
+
.send(tmpRecord)
|
|
222
|
+
.end(
|
|
223
|
+
function(pError, pResponse)
|
|
224
|
+
{
|
|
225
|
+
// Expect response to be the record we just created.
|
|
226
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
227
|
+
Expect(tmpResult.Error).to.contain('authenticated');
|
|
228
|
+
fDone();
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
test
|
|
234
|
+
(
|
|
235
|
+
'create: create a record with a bad record passed in',
|
|
236
|
+
function(fDone)
|
|
237
|
+
{
|
|
238
|
+
var tmpRecord = ' ';
|
|
239
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
240
|
+
libSuperTest('http://localhost:9080/')
|
|
241
|
+
.post('1.0/FableTest')
|
|
242
|
+
.send(tmpRecord)
|
|
243
|
+
.end(
|
|
244
|
+
function(pError, pResponse)
|
|
245
|
+
{
|
|
246
|
+
// Expect response to be the record we just created.
|
|
247
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
248
|
+
Expect(tmpResult.Error).to.not.be.null;
|
|
249
|
+
fDone();
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
test
|
|
255
|
+
(
|
|
256
|
+
'read: get a specific record',
|
|
257
|
+
function(fDone)
|
|
258
|
+
{
|
|
259
|
+
libSuperTest('http://localhost:9080/')
|
|
260
|
+
.get('1.0/FableTest/2')
|
|
261
|
+
.end(
|
|
262
|
+
function (pError, pResponse)
|
|
263
|
+
{
|
|
264
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
265
|
+
Expect(tmpResult.Type).to.equal('Girl');
|
|
266
|
+
fDone();
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
test
|
|
272
|
+
(
|
|
273
|
+
'read: define a custom authorization behavior',
|
|
274
|
+
function(fDone)
|
|
275
|
+
{
|
|
276
|
+
const defaultAuthorizer = _MeadowEndpoints.endpointAuthorizers.getAuthorizer('Allow');
|
|
277
|
+
_MeadowEndpoints.endpointAuthorizers.setAuthorizer('Allow', function(req, next) { req.MeadowAuthorization = false; return next(); });
|
|
278
|
+
_Orator.webServer.get('/CustomHotRodRoute/:IDRecord', _MeadowEndpoints.endpointAuthenticators.Read, _MeadowEndpoints.wireState, _MeadowEndpoints.endpoints.Read);
|
|
279
|
+
libSuperTest('http://localhost:9080/')
|
|
280
|
+
.get('CustomHotRodRoute/2')
|
|
281
|
+
.end(
|
|
282
|
+
function (pError, pResponse)
|
|
283
|
+
{
|
|
284
|
+
_MeadowEndpoints.endpointAuthorizers.setAuthorizer('Allow', defaultAuthorizer);
|
|
285
|
+
//TODO: it's weird that we don't get an error here for access denied...
|
|
286
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
287
|
+
Expect(tmpResult.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
288
|
+
fDone();
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
test
|
|
294
|
+
(
|
|
295
|
+
'read: define a custom route and get a record with it',
|
|
296
|
+
function(fDone)
|
|
297
|
+
{
|
|
298
|
+
_Orator.webServer.get('/CustomHotRodRoute/:IDRecord', _MeadowEndpoints.endpointAuthenticators.Read, _MeadowEndpoints.wireState, _MeadowEndpoints.endpoints.Read);
|
|
299
|
+
libSuperTest('http://localhost:9080/')
|
|
300
|
+
.get('CustomHotRodRoute/2')
|
|
301
|
+
.end(
|
|
302
|
+
function (pError, pResponse)
|
|
303
|
+
{
|
|
304
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
305
|
+
Expect(tmpResult.Type).to.equal('Girl');
|
|
306
|
+
fDone();
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
);
|
|
311
|
+
test
|
|
312
|
+
(
|
|
313
|
+
'read: get a specific record but be denied by security',
|
|
314
|
+
function(fDone)
|
|
315
|
+
{
|
|
316
|
+
_Meadow.schemaFull.authorizer.Manager = {};
|
|
317
|
+
_Meadow.schemaFull.authorizer.Manager.Read = 'Deny';
|
|
318
|
+
|
|
319
|
+
libSuperTest('http://localhost:9080/')
|
|
320
|
+
.get('1.0/FableTest/2')
|
|
321
|
+
.end(
|
|
322
|
+
function (pError, pResponse)
|
|
323
|
+
{
|
|
324
|
+
Expect(pResponse.text).to.contain('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
325
|
+
// Reset authorization
|
|
326
|
+
_Meadow.schemaFull.authorizer.Manager.Read = 'Allow';
|
|
327
|
+
fDone();
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
);
|
|
332
|
+
test
|
|
333
|
+
(
|
|
334
|
+
'read: get a specific record which resolved to Deny authorization, but with a Deny authorizer that just allows',
|
|
335
|
+
function(fDone)
|
|
336
|
+
{
|
|
337
|
+
_Meadow.schemaFull.authorizer.Manager = {};
|
|
338
|
+
_Meadow.schemaFull.authorizer.Manager.Read = 'Deny';
|
|
339
|
+
const defaultAuthorizer = _MeadowEndpoints.endpointAuthorizers.getAuthorizer('Deny');
|
|
340
|
+
_MeadowEndpoints.endpointAuthorizers.setAuthorizer('Deny', function(req, next) { req.MeadowAuthorization = true; return next(); });
|
|
341
|
+
|
|
342
|
+
libSuperTest('http://localhost:9080/')
|
|
343
|
+
.get('1.0/FableTest/2')
|
|
344
|
+
.end(
|
|
345
|
+
function (pError, pResponse)
|
|
346
|
+
{
|
|
347
|
+
// Reset authorization
|
|
348
|
+
_Meadow.schemaFull.authorizer.Manager.Read = 'Allow';
|
|
349
|
+
_MeadowEndpoints.endpointAuthorizers.setAuthorizer('Deny', defaultAuthorizer);
|
|
350
|
+
|
|
351
|
+
const responseBody = JSON.parse(pResponse.text);
|
|
352
|
+
Expect(responseBody.IDAnimal).to.equal(2);
|
|
353
|
+
fDone();
|
|
354
|
+
}
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
test
|
|
359
|
+
(
|
|
360
|
+
'read: get a specific record with a bad parameter',
|
|
361
|
+
function(fDone)
|
|
362
|
+
{
|
|
363
|
+
libSuperTest('http://localhost:9080/')
|
|
364
|
+
.get('1.0/FableTest/')
|
|
365
|
+
.end(
|
|
366
|
+
function (pError, pResponse)
|
|
367
|
+
{
|
|
368
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
369
|
+
Expect(tmpResult.Error).to.equal('Error retreiving a record. Record not found');
|
|
370
|
+
fDone();
|
|
371
|
+
}
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
);
|
|
375
|
+
test
|
|
376
|
+
(
|
|
377
|
+
'reads: get all records',
|
|
378
|
+
function(fDone)
|
|
379
|
+
{
|
|
380
|
+
libSuperTest('http://localhost:9080/')
|
|
381
|
+
.get('1.0/FableTests')
|
|
382
|
+
.end(
|
|
383
|
+
function (pError, pResponse)
|
|
384
|
+
{
|
|
385
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
386
|
+
Expect(tmpResults.length).to.equal(6);
|
|
387
|
+
Expect(tmpResults[0].Type).to.equal('Bunny');
|
|
388
|
+
Expect(tmpResults[4].Name).to.equal('Gertrude');
|
|
389
|
+
fDone();
|
|
390
|
+
}
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
);
|
|
394
|
+
test
|
|
395
|
+
(
|
|
396
|
+
'readsLiteExtended: get all records',
|
|
397
|
+
function(fDone)
|
|
398
|
+
{
|
|
399
|
+
libSuperTest('http://localhost:9080/')
|
|
400
|
+
.get('1.0/FableTests/LiteExtended/Type,Name')
|
|
401
|
+
.end(
|
|
402
|
+
function (pError, pResponse)
|
|
403
|
+
{
|
|
404
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
405
|
+
Expect(tmpResults.length).to.equal(6);
|
|
406
|
+
Expect(tmpResults[0].IDAnimal).to.equal(1);
|
|
407
|
+
Expect(tmpResults[4].IDAnimal).to.equal(5);
|
|
408
|
+
Expect(tmpResults[4].Type).to.equal('Frog');
|
|
409
|
+
fDone();
|
|
410
|
+
}
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
test
|
|
415
|
+
(
|
|
416
|
+
'readsby: get all records by Type',
|
|
417
|
+
function(fDone)
|
|
418
|
+
{
|
|
419
|
+
libSuperTest('http://localhost:9080/')
|
|
420
|
+
.get('1.0/FableTests/By/Type/Dog')
|
|
421
|
+
.end(
|
|
422
|
+
function (pError, pResponse)
|
|
423
|
+
{
|
|
424
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
425
|
+
Expect(tmpResults.length).to.equal(2);
|
|
426
|
+
Expect(tmpResults[0].Type).to.equal('Dog');
|
|
427
|
+
fDone();
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
);
|
|
432
|
+
test
|
|
433
|
+
(
|
|
434
|
+
'readsby: get all records by Type IN LIST',
|
|
435
|
+
function(fDone)
|
|
436
|
+
{
|
|
437
|
+
libSuperTest('http://localhost:9080/')
|
|
438
|
+
.get('1.0/FableTests/By/Type/Mammoth%2C%20WithComma,Dog')
|
|
439
|
+
.end(
|
|
440
|
+
function (pError, pResponse)
|
|
441
|
+
{
|
|
442
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
443
|
+
Expect(tmpResults.length).to.equal(2);
|
|
444
|
+
Expect(tmpResults[0].Type).to.equal('Dog');
|
|
445
|
+
fDone();
|
|
446
|
+
}
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
);
|
|
450
|
+
test
|
|
451
|
+
(
|
|
452
|
+
'countby: get count of records by Type',
|
|
453
|
+
function(fDone)
|
|
454
|
+
{
|
|
455
|
+
libSuperTest('http://localhost:9080/')
|
|
456
|
+
.get('1.0/FableTests/Count/By/Type/Dog')
|
|
457
|
+
.end(
|
|
458
|
+
function (pError, pResponse)
|
|
459
|
+
{
|
|
460
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
461
|
+
Expect(tmpResults.Count).to.equal(2);
|
|
462
|
+
fDone();
|
|
463
|
+
}
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
);
|
|
467
|
+
test
|
|
468
|
+
(
|
|
469
|
+
'countby: get count of records by multiple Types',
|
|
470
|
+
function(fDone)
|
|
471
|
+
{
|
|
472
|
+
libSuperTest('http://localhost:9080/')
|
|
473
|
+
.get('1.0/FableTests/Count/By/Type/Dog,Mammoth')
|
|
474
|
+
.end(
|
|
475
|
+
function (pError, pResponse)
|
|
476
|
+
{
|
|
477
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
478
|
+
Expect(tmpResults.Count).to.equal(3);
|
|
479
|
+
fDone();
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
test
|
|
485
|
+
(
|
|
486
|
+
'readsby: get paged records by Type',
|
|
487
|
+
function(fDone)
|
|
488
|
+
{
|
|
489
|
+
libSuperTest('http://localhost:9080/')
|
|
490
|
+
.get('1.0/FableTests/By/Type/Dog/1/1')
|
|
491
|
+
.end(
|
|
492
|
+
function (pError, pResponse)
|
|
493
|
+
{
|
|
494
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
495
|
+
Expect(tmpResults.length).to.equal(1);
|
|
496
|
+
Expect(tmpResults[0].Name).to.equal('Spot');
|
|
497
|
+
fDone();
|
|
498
|
+
}
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
);
|
|
502
|
+
test
|
|
503
|
+
(
|
|
504
|
+
'readselect: get a page of filtered records by date',
|
|
505
|
+
function(fDone)
|
|
506
|
+
{
|
|
507
|
+
var today = new Date();
|
|
508
|
+
today = today.toISOString().substring(0, 10);
|
|
509
|
+
|
|
510
|
+
libSuperTest('http://localhost:9080/')
|
|
511
|
+
.get(`1.0/FableTestSelect/FilteredTo/FBD~UpdateDate~EQ~${today}/0/1`)
|
|
512
|
+
.end(
|
|
513
|
+
function (pError, pResponse)
|
|
514
|
+
{
|
|
515
|
+
console.log(pResponse.text)
|
|
516
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
517
|
+
Expect(tmpResults.length).to.equal(1);
|
|
518
|
+
Expect(tmpResults[0].Value).to.equal('FableTest #1');
|
|
519
|
+
fDone();
|
|
520
|
+
}
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
);
|
|
524
|
+
test
|
|
525
|
+
(
|
|
526
|
+
'readselect: get all records',
|
|
527
|
+
function(fDone)
|
|
528
|
+
{
|
|
529
|
+
libSuperTest('http://localhost:9080/')
|
|
530
|
+
.get('1.0/FableTestSelect')
|
|
531
|
+
.end(
|
|
532
|
+
function (pError, pResponse)
|
|
533
|
+
{
|
|
534
|
+
console.log(pResponse.text)
|
|
535
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
536
|
+
Expect(tmpResults.length).to.equal(6);
|
|
537
|
+
Expect(tmpResults[4].Value).to.equal('FableTest #5');
|
|
538
|
+
fDone();
|
|
539
|
+
}
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
);
|
|
543
|
+
test
|
|
544
|
+
(
|
|
545
|
+
'readselect: get a page of records',
|
|
546
|
+
function(fDone)
|
|
547
|
+
{
|
|
548
|
+
libSuperTest('http://localhost:9080/')
|
|
549
|
+
.get('1.0/FableTestSelect/2/2')
|
|
550
|
+
.end(
|
|
551
|
+
function (pError, pResponse)
|
|
552
|
+
{
|
|
553
|
+
console.log(pResponse.text)
|
|
554
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
555
|
+
Expect(tmpResults.length).to.equal(2);
|
|
556
|
+
Expect(tmpResults[1].Value).to.equal('FableTest #4');
|
|
557
|
+
fDone();
|
|
558
|
+
}
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
);
|
|
562
|
+
test
|
|
563
|
+
(
|
|
564
|
+
'readselect: get a page of records',
|
|
565
|
+
function(fDone)
|
|
566
|
+
{
|
|
567
|
+
libSuperTest('http://localhost:9080/')
|
|
568
|
+
.get('1.0/FableTestSelect/2/2')
|
|
569
|
+
.end(
|
|
570
|
+
function (pError, pResponse)
|
|
571
|
+
{
|
|
572
|
+
console.log(pResponse.text)
|
|
573
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
574
|
+
Expect(tmpResults.length).to.equal(2);
|
|
575
|
+
Expect(tmpResults[1].Value).to.equal('FableTest #4');
|
|
576
|
+
fDone();
|
|
577
|
+
}
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
);
|
|
581
|
+
test
|
|
582
|
+
(
|
|
583
|
+
'readselect: get filtered records',
|
|
584
|
+
function(fDone)
|
|
585
|
+
{
|
|
586
|
+
libSuperTest('http://localhost:9080/')
|
|
587
|
+
.get('1.0/FableTestSelect/FilteredTo/FBV~Type~EQ~Dog')
|
|
588
|
+
.end(
|
|
589
|
+
function (pError, pResponse)
|
|
590
|
+
{
|
|
591
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
592
|
+
Expect(tmpResults.length).to.equal(2);
|
|
593
|
+
Expect(tmpResults[0].Value).to.equal('FableTest #3');
|
|
594
|
+
fDone();
|
|
595
|
+
}
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
);
|
|
599
|
+
test
|
|
600
|
+
(
|
|
601
|
+
'readselect: get a page of filtered records',
|
|
602
|
+
function(fDone)
|
|
603
|
+
{
|
|
604
|
+
libSuperTest('http://localhost:9080/')
|
|
605
|
+
.get('1.0/FableTestSelect/FilteredTo/FBV~Type~EQ~Dog/1/1')
|
|
606
|
+
.end(
|
|
607
|
+
function (pError, pResponse)
|
|
608
|
+
{
|
|
609
|
+
console.log(pResponse.text)
|
|
610
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
611
|
+
Expect(tmpResults.length).to.equal(1);
|
|
612
|
+
Expect(tmpResults[0].Value).to.equal('FableTest #4');
|
|
613
|
+
fDone();
|
|
614
|
+
}
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
);
|
|
618
|
+
test
|
|
619
|
+
(
|
|
620
|
+
'readselect: get an empty page of records',
|
|
621
|
+
function(fDone)
|
|
622
|
+
{
|
|
623
|
+
libSuperTest('http://localhost:9080/')
|
|
624
|
+
.get('1.0/FableTestSelect/200/200')
|
|
625
|
+
.end(
|
|
626
|
+
function (pError, pResponse)
|
|
627
|
+
{
|
|
628
|
+
console.log(pResponse.text)
|
|
629
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
630
|
+
Expect(tmpResults.length).to.equal(0);
|
|
631
|
+
fDone();
|
|
632
|
+
}
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
);
|
|
636
|
+
test
|
|
637
|
+
(
|
|
638
|
+
'reads: get a page of records',
|
|
639
|
+
function(fDone)
|
|
640
|
+
{
|
|
641
|
+
libSuperTest('http://localhost:9080/')
|
|
642
|
+
// Get page 2, 2 records per page.
|
|
643
|
+
.get('1.0/FableTests/2/2')
|
|
644
|
+
.end(
|
|
645
|
+
function (pError, pResponse)
|
|
646
|
+
{
|
|
647
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
648
|
+
Expect(tmpResults.length).to.equal(2);
|
|
649
|
+
Expect(tmpResults[0].Type).to.equal('Dog');
|
|
650
|
+
Expect(tmpResults[1].Name).to.equal('Spot');
|
|
651
|
+
fDone();
|
|
652
|
+
}
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
);
|
|
656
|
+
test
|
|
657
|
+
(
|
|
658
|
+
'reads: get a filtered set of records',
|
|
659
|
+
function(fDone)
|
|
660
|
+
{
|
|
661
|
+
libSuperTest('http://localhost:9080/')
|
|
662
|
+
.get('1.0/FableTests/FilteredTo/FBV~Type~EQ~Frog')
|
|
663
|
+
.end(
|
|
664
|
+
function (pError, pResponse)
|
|
665
|
+
{
|
|
666
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
667
|
+
Expect(tmpResults.length).to.equal(1);
|
|
668
|
+
Expect(tmpResults[0].Type).to.equal('Frog');
|
|
669
|
+
fDone();
|
|
670
|
+
}
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
);
|
|
674
|
+
test
|
|
675
|
+
(
|
|
676
|
+
'reads: get distinct values for a column',
|
|
677
|
+
function(fDone)
|
|
678
|
+
{
|
|
679
|
+
libSuperTest('http://localhost:9080/')
|
|
680
|
+
.get('1.0/FableTests/Distinct/Type')
|
|
681
|
+
.end(
|
|
682
|
+
function (pError, pResponse)
|
|
683
|
+
{
|
|
684
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
685
|
+
Expect(tmpResults.length).to.equal(5);
|
|
686
|
+
const types = tmpResults.map((r) => r.Type);
|
|
687
|
+
Expect(types).to.have.members(['Bunny', 'Girl', 'Dog', 'Frog', 'Mammoth']);
|
|
688
|
+
fDone();
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
);
|
|
693
|
+
test
|
|
694
|
+
(
|
|
695
|
+
'reads: get distinct values for a column with filter',
|
|
696
|
+
function(fDone)
|
|
697
|
+
{
|
|
698
|
+
libSuperTest('http://localhost:9080/')
|
|
699
|
+
.get('1.0/FableTests/Distinct/Type/FilteredTo/FBV~IDAnimal~LT~3')
|
|
700
|
+
.end(
|
|
701
|
+
function (pError, pResponse)
|
|
702
|
+
{
|
|
703
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
704
|
+
Expect(tmpResults.length).to.equal(2);
|
|
705
|
+
const types = new Set(tmpResults.map((r) => r.Type));
|
|
706
|
+
Expect(types.size).to.equal(2);
|
|
707
|
+
fDone();
|
|
708
|
+
}
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
);
|
|
712
|
+
test
|
|
713
|
+
(
|
|
714
|
+
'reads: get distinct values for a column with filter and pagination',
|
|
715
|
+
function(fDone)
|
|
716
|
+
{
|
|
717
|
+
libSuperTest('http://localhost:9080/')
|
|
718
|
+
.get('1.0/FableTests/Distinct/Type/FilteredTo/FBV~IDAnimal~LT~3/0/1')
|
|
719
|
+
.end(
|
|
720
|
+
function (pError, pResponse)
|
|
721
|
+
{
|
|
722
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
723
|
+
Expect(tmpResults.length).to.equal(1);
|
|
724
|
+
fDone();
|
|
725
|
+
}
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
);
|
|
729
|
+
test
|
|
730
|
+
(
|
|
731
|
+
'reads: get distinct values for a column with pagination',
|
|
732
|
+
function(fDone)
|
|
733
|
+
{
|
|
734
|
+
libSuperTest('http://localhost:9080/')
|
|
735
|
+
.get('1.0/FableTests/Distinct/Type/2/2')
|
|
736
|
+
.end(
|
|
737
|
+
function (pError, pResponse)
|
|
738
|
+
{
|
|
739
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
740
|
+
Expect(tmpResults.length).to.equal(2);
|
|
741
|
+
const types = new Set(tmpResults.map((r) => r.Type));
|
|
742
|
+
Expect(types.size).to.equal(2);
|
|
743
|
+
fDone();
|
|
744
|
+
}
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
);
|
|
748
|
+
test
|
|
749
|
+
(
|
|
750
|
+
'reads: get a filtered paged set of records',
|
|
751
|
+
function(fDone)
|
|
752
|
+
{
|
|
753
|
+
libSuperTest('http://localhost:9080/')
|
|
754
|
+
// Skip one record, 2 records per page.
|
|
755
|
+
.get('1.0/FableTests/FilteredTo/FBV~Type~EQ~Dog/1/2')
|
|
756
|
+
.end(
|
|
757
|
+
function (pError, pResponse)
|
|
758
|
+
{
|
|
759
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
760
|
+
Expect(tmpResults.length).to.equal(1);
|
|
761
|
+
Expect(tmpResults[0].Type).to.equal('Dog');
|
|
762
|
+
fDone();
|
|
763
|
+
}
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
);
|
|
767
|
+
test
|
|
768
|
+
(
|
|
769
|
+
'update: update a record',
|
|
770
|
+
function(fDone)
|
|
771
|
+
{
|
|
772
|
+
// Change animal 4 ("Spot") to a Corgi
|
|
773
|
+
var tmpRecord = {IDAnimal:4, Type:'Corgi'};
|
|
774
|
+
libSuperTest('http://localhost:9080/')
|
|
775
|
+
.put('1.0/FableTest')
|
|
776
|
+
.send(tmpRecord)
|
|
777
|
+
.end(
|
|
778
|
+
function(pError, pResponse)
|
|
779
|
+
{
|
|
780
|
+
// Expect response to be the record we just created.
|
|
781
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
782
|
+
Expect(tmpResult.Type).to.equal('Corgi');
|
|
783
|
+
Expect(tmpResult.CreatingIDUser).to.equal(1);
|
|
784
|
+
Expect(tmpResult.UpdatingIDUser).to.equal(37);
|
|
785
|
+
fDone();
|
|
786
|
+
}
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
);
|
|
790
|
+
test
|
|
791
|
+
(
|
|
792
|
+
'delete: delete a record',
|
|
793
|
+
function(fDone)
|
|
794
|
+
{
|
|
795
|
+
// Delete animal 3 ("Red")
|
|
796
|
+
var tmpRecord = {IDAnimal:3};
|
|
797
|
+
libSuperTest('http://localhost:9080/')
|
|
798
|
+
.del('1.0/FableTest')
|
|
799
|
+
.send(tmpRecord)
|
|
800
|
+
.end(
|
|
801
|
+
function(pError, pResponse)
|
|
802
|
+
{
|
|
803
|
+
// Expect response to be the count of deleted records.
|
|
804
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
805
|
+
Expect(tmpResult.Count).to.equal(1);
|
|
806
|
+
fDone();
|
|
807
|
+
}
|
|
808
|
+
);
|
|
809
|
+
}
|
|
810
|
+
);
|
|
811
|
+
test
|
|
812
|
+
(
|
|
813
|
+
'delete: undelete a record after deleting it',
|
|
814
|
+
function(fDone)
|
|
815
|
+
{
|
|
816
|
+
// Delete animal 4
|
|
817
|
+
var tmpRecord = {IDAnimal:4};
|
|
818
|
+
libSuperTest('http://localhost:9080/')
|
|
819
|
+
.del('1.0/FableTest')
|
|
820
|
+
.send(tmpRecord)
|
|
821
|
+
.end(
|
|
822
|
+
function(pError, pResponse)
|
|
823
|
+
{
|
|
824
|
+
// Expect response to be the count of deleted records.
|
|
825
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
826
|
+
Expect(tmpResult.Count).to.equal(1);
|
|
827
|
+
|
|
828
|
+
// Now undelete the record
|
|
829
|
+
libSuperTest('http://localhost:9080/')
|
|
830
|
+
.get('1.0/FableTest/Undelete/4')
|
|
831
|
+
.end(
|
|
832
|
+
function(pError, pResponse)
|
|
833
|
+
{
|
|
834
|
+
// Expect response to be the count of deleted records.
|
|
835
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
836
|
+
Expect(tmpResult.Count).to.equal(1);
|
|
837
|
+
return fDone();
|
|
838
|
+
}
|
|
839
|
+
);
|
|
840
|
+
}
|
|
841
|
+
);
|
|
842
|
+
}
|
|
843
|
+
);
|
|
844
|
+
test
|
|
845
|
+
(
|
|
846
|
+
'delete: delete a record with a bad parameter',
|
|
847
|
+
function(fDone)
|
|
848
|
+
{
|
|
849
|
+
// Delete animal 3 ("Red")
|
|
850
|
+
var tmpRecord = {IDAnimal:{MyStuff:4}};
|
|
851
|
+
libSuperTest('http://localhost:9080/')
|
|
852
|
+
.del('1.0/FableTest')
|
|
853
|
+
.send(tmpRecord)
|
|
854
|
+
.end(
|
|
855
|
+
function(pError, pResponse)
|
|
856
|
+
{
|
|
857
|
+
// Expect response to be the count of deleted records.
|
|
858
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
859
|
+
Expect(tmpResult.Error).to.contain('a valid record ID is required');
|
|
860
|
+
fDone();
|
|
861
|
+
}
|
|
862
|
+
);
|
|
863
|
+
}
|
|
864
|
+
);
|
|
865
|
+
test
|
|
866
|
+
(
|
|
867
|
+
'count: get the count of records',
|
|
868
|
+
function(fDone)
|
|
869
|
+
{
|
|
870
|
+
libSuperTest('http://localhost:9080/')
|
|
871
|
+
.get('1.0/FableTests/Count')
|
|
872
|
+
.end(
|
|
873
|
+
function (pError, pResponse)
|
|
874
|
+
{
|
|
875
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
876
|
+
Expect(tmpResults.Count).to.equal(5);
|
|
877
|
+
fDone();
|
|
878
|
+
}
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
);
|
|
882
|
+
test
|
|
883
|
+
(
|
|
884
|
+
'count: get the count of filtered records',
|
|
885
|
+
function(fDone)
|
|
886
|
+
{
|
|
887
|
+
libSuperTest('http://localhost:9080/')
|
|
888
|
+
.get('1.0/FableTests/Count/FilteredTo/FBV~Type~EQ~Girl')
|
|
889
|
+
.end(
|
|
890
|
+
function (pError, pResponse)
|
|
891
|
+
{
|
|
892
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
893
|
+
Expect(tmpResults.Count).to.equal(1);
|
|
894
|
+
fDone();
|
|
895
|
+
}
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
);
|
|
899
|
+
test
|
|
900
|
+
(
|
|
901
|
+
'schema: get the schema of a record',
|
|
902
|
+
function(fDone)
|
|
903
|
+
{
|
|
904
|
+
libSuperTest('http://localhost:9080/')
|
|
905
|
+
.get('1.0/FableTest/Schema')
|
|
906
|
+
.end(
|
|
907
|
+
function (pError, pResponse)
|
|
908
|
+
{
|
|
909
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
910
|
+
//console.log('SCHEMA --> '+JSON.stringify(tmpResults, null, 4))
|
|
911
|
+
Expect(tmpResults.title).to.equal('Animal');
|
|
912
|
+
Expect(tmpResults.description).to.contain('creature that lives in');
|
|
913
|
+
fDone();
|
|
914
|
+
}
|
|
915
|
+
);
|
|
916
|
+
}
|
|
917
|
+
);
|
|
918
|
+
test
|
|
919
|
+
(
|
|
920
|
+
'new: get a new empty record',
|
|
921
|
+
function(fDone)
|
|
922
|
+
{
|
|
923
|
+
libSuperTest('http://localhost:9080/')
|
|
924
|
+
.get('1.0/FableTest/Schema/New')
|
|
925
|
+
.end(
|
|
926
|
+
function (pError, pResponse)
|
|
927
|
+
{
|
|
928
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
929
|
+
//console.log(JSON.stringify(tmpResults, null, 4))
|
|
930
|
+
Expect(tmpResults.IDAnimal).to.equal(null);
|
|
931
|
+
Expect(tmpResults.Name).to.equal('Unknown');
|
|
932
|
+
Expect(tmpResults.Type).to.equal('Unclassified');
|
|
933
|
+
fDone();
|
|
934
|
+
}
|
|
935
|
+
);
|
|
936
|
+
}
|
|
937
|
+
);
|
|
938
|
+
test
|
|
939
|
+
(
|
|
940
|
+
'validate: validate an invalid record',
|
|
941
|
+
function(fDone)
|
|
942
|
+
{
|
|
943
|
+
var tmpRecord = {IDAnimal:4, Type:'Corgi'};
|
|
944
|
+
libSuperTest('http://localhost:9080/')
|
|
945
|
+
.post('1.0/FableTest/Schema/Validate')
|
|
946
|
+
.send(tmpRecord)
|
|
947
|
+
.end(
|
|
948
|
+
function(pError, pResponse)
|
|
949
|
+
{
|
|
950
|
+
// Expect response to be the record we just created.
|
|
951
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
952
|
+
//console.log(JSON.stringify(tmpResult, null, 4))
|
|
953
|
+
Expect(tmpResult.Valid).to.equal(false);
|
|
954
|
+
Expect(tmpResult.Errors[0].field).to.equal('data.Name');
|
|
955
|
+
Expect(tmpResult.Errors[0].message).to.equal('is required');
|
|
956
|
+
fDone();
|
|
957
|
+
}
|
|
958
|
+
);
|
|
959
|
+
}
|
|
960
|
+
);
|
|
961
|
+
test
|
|
962
|
+
(
|
|
963
|
+
'validate: validate a valid record',
|
|
964
|
+
function(fDone)
|
|
965
|
+
{
|
|
966
|
+
var tmpRecord = {IDAnimal:4, Type:'Corgi', Name:'Doofer', CreatingIDUser:10};
|
|
967
|
+
libSuperTest('http://localhost:9080/')
|
|
968
|
+
.post('1.0/FableTest/Schema/Validate')
|
|
969
|
+
.send(tmpRecord)
|
|
970
|
+
.end(
|
|
971
|
+
function(pError, pResponse)
|
|
972
|
+
{
|
|
973
|
+
// Expect response to be the record we just created.
|
|
974
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
975
|
+
//console.log(JSON.stringify(tmpResult, null, 4))
|
|
976
|
+
Expect(tmpResult.Valid).to.equal(true);
|
|
977
|
+
fDone();
|
|
978
|
+
}
|
|
979
|
+
);
|
|
980
|
+
}
|
|
981
|
+
);
|
|
982
|
+
test
|
|
983
|
+
(
|
|
984
|
+
'validate: validate bad data',
|
|
985
|
+
function(fDone)
|
|
986
|
+
{
|
|
987
|
+
var tmpRecord = 'IAMBAD';
|
|
988
|
+
libSuperTest('http://localhost:9080/')
|
|
989
|
+
.post('1.0/FableTest/Schema/Validate')
|
|
990
|
+
.send(tmpRecord)
|
|
991
|
+
.end(
|
|
992
|
+
function(pError, pResponse)
|
|
993
|
+
{
|
|
994
|
+
// Expect response to be the record we just created.
|
|
995
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
996
|
+
//console.log(JSON.stringify(tmpResult, null, 4))
|
|
997
|
+
Expect(tmpResult.Valid).to.be.false;
|
|
998
|
+
fDone();
|
|
999
|
+
}
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
);
|
|
1003
|
+
}
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
);
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
suite
|
|
1010
|
+
(
|
|
1011
|
+
'Behavior Modifications',
|
|
1012
|
+
function()
|
|
1013
|
+
{
|
|
1014
|
+
test
|
|
1015
|
+
(
|
|
1016
|
+
'instantiate a behavior modification object',
|
|
1017
|
+
function()
|
|
1018
|
+
{
|
|
1019
|
+
var tmpBehaviorMods = require('../source/Meadow-BehaviorModifications.js').new(_Fable);
|
|
1020
|
+
Expect(tmpBehaviorMods).to.be.an('object');
|
|
1021
|
+
}
|
|
1022
|
+
);
|
|
1023
|
+
test
|
|
1024
|
+
(
|
|
1025
|
+
'exercise the templates api',
|
|
1026
|
+
function()
|
|
1027
|
+
{
|
|
1028
|
+
var tmpBehaviorMods = require('../source/Meadow-BehaviorModifications.js').new(_Fable);
|
|
1029
|
+
|
|
1030
|
+
var tmpCrossBehaviorState = 0;
|
|
1031
|
+
|
|
1032
|
+
Expect(tmpBehaviorMods.runBehavior('NoBehaviorsHere', {}, function() {})).to.equal(undefined, 'nonexistant behaviors should just execute');
|
|
1033
|
+
tmpBehaviorMods.setBehavior('BigBehavior', function() { tmpCrossBehaviorState++ });
|
|
1034
|
+
Expect(tmpCrossBehaviorState).to.equal(0);
|
|
1035
|
+
Expect(tmpBehaviorMods.runBehavior('BigBehavior', {}, function() {})).to.equal(undefined, 'existant behaviors should just execute');
|
|
1036
|
+
Expect(tmpCrossBehaviorState).to.equal(1);
|
|
1037
|
+
}
|
|
1038
|
+
);
|
|
1039
|
+
test
|
|
1040
|
+
(
|
|
1041
|
+
'exercise the behavior modification api',
|
|
1042
|
+
function()
|
|
1043
|
+
{
|
|
1044
|
+
var tmpBehaviorMods = require('../source/Meadow-BehaviorModifications.js').new(_Fable);
|
|
1045
|
+
Expect(tmpBehaviorMods.getTemplateFunction('NoTemplatesHere')).to.equal(false, 'empty template hashes on empty sets should return false');
|
|
1046
|
+
Expect(tmpBehaviorMods.getTemplate('NoTemplatesHere')).to.equal(false,'emtpy template sets should be false');
|
|
1047
|
+
tmpBehaviorMods.setTemplate('AnimalFormatter', '<p>An animal (id <%= Number %> is here</p>');
|
|
1048
|
+
Expect(tmpBehaviorMods.getTemplate('AnimalFormatter')).to.contain('An animal');
|
|
1049
|
+
Expect(tmpBehaviorMods.processTemplate('AnimalFormatter', {Number:5})).to.contain('id 5');
|
|
1050
|
+
Expect(tmpBehaviorMods.processTemplate('FriendFormatter', {Number:5}, 'blit <%= Number %>')).to.contain('blit 5');
|
|
1051
|
+
Expect(tmpBehaviorMods.processTemplate('Blank', {Number:5})).to.equal('');
|
|
1052
|
+
tmpBehaviorMods.setTemplate('SimpleTemplate', 'Not so simple.');
|
|
1053
|
+
Expect(tmpBehaviorMods.processTemplate('SimpleTemplate')).to.equal('Not so simple.');
|
|
1054
|
+
}
|
|
1055
|
+
);
|
|
1056
|
+
test
|
|
1057
|
+
(
|
|
1058
|
+
'exercise the security modification api',
|
|
1059
|
+
function()
|
|
1060
|
+
{
|
|
1061
|
+
var tmpAuthorizers = require('../source/Meadow-Authorizers.js').new(_Fable);
|
|
1062
|
+
tmpAuthorizers.setAuthorizer('AlwaysAuthorize',
|
|
1063
|
+
function(pRequest, fComplete)
|
|
1064
|
+
{
|
|
1065
|
+
pRequest.MeadowAuthorization = true;
|
|
1066
|
+
});
|
|
1067
|
+
var tmpMockRequest = {MeadowAuthorization: 'Green'};
|
|
1068
|
+
tmpAuthorizers.authorize('BadHash', tmpMockRequest,
|
|
1069
|
+
function()
|
|
1070
|
+
{
|
|
1071
|
+
Expect(tmpMockRequest.MeadowAuthorization).to.equal('Green');
|
|
1072
|
+
});
|
|
1073
|
+
tmpAuthorizers.authorize('AlwaysAuthorize', tmpMockRequest,
|
|
1074
|
+
function()
|
|
1075
|
+
{
|
|
1076
|
+
Expect(tmpMockRequest.MeadowAuthorization).to.equal(true);
|
|
1077
|
+
});
|
|
1078
|
+
tmpAuthorizers.authorize('Allow', tmpMockRequest,
|
|
1079
|
+
function()
|
|
1080
|
+
{
|
|
1081
|
+
Expect(tmpMockRequest.MeadowAuthorization).to.equal(true);
|
|
1082
|
+
});
|
|
1083
|
+
tmpAuthorizers.authorize('Deny', tmpMockRequest,
|
|
1084
|
+
function()
|
|
1085
|
+
{
|
|
1086
|
+
Expect(tmpMockRequest.MeadowAuthorization).to.equal(false);
|
|
1087
|
+
});
|
|
1088
|
+
var tmpMockFullRequest =
|
|
1089
|
+
{
|
|
1090
|
+
UserSession:
|
|
1091
|
+
{
|
|
1092
|
+
CustomerID: 10,
|
|
1093
|
+
UserID: 1
|
|
1094
|
+
},
|
|
1095
|
+
Record:
|
|
1096
|
+
{
|
|
1097
|
+
IDCustomer: 10,
|
|
1098
|
+
IDUser: 1
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
// Test that
|
|
1102
|
+
}
|
|
1103
|
+
);
|
|
1104
|
+
test
|
|
1105
|
+
(
|
|
1106
|
+
'exercise the security modification authenticators',
|
|
1107
|
+
function()
|
|
1108
|
+
{
|
|
1109
|
+
var tmpAuthorizers = require('../source/Meadow-Authorizers.js').new(_Fable);
|
|
1110
|
+
var tmpMockFullRequest =
|
|
1111
|
+
{
|
|
1112
|
+
UserSession:
|
|
1113
|
+
{
|
|
1114
|
+
CustomerID: 10,
|
|
1115
|
+
UserID: 1
|
|
1116
|
+
},
|
|
1117
|
+
Record:
|
|
1118
|
+
{
|
|
1119
|
+
IDCustomer: 10,
|
|
1120
|
+
CreatingIDUser: 1
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
// Mine and MyCustomer should both work
|
|
1124
|
+
tmpAuthorizers.authorize('Mine', tmpMockFullRequest,
|
|
1125
|
+
function()
|
|
1126
|
+
{
|
|
1127
|
+
Expect(tmpMockFullRequest.MeadowAuthorization).to.equal(true);
|
|
1128
|
+
});
|
|
1129
|
+
tmpAuthorizers.authorize('MyCustomer', tmpMockFullRequest,
|
|
1130
|
+
function()
|
|
1131
|
+
{
|
|
1132
|
+
Expect(tmpMockFullRequest.MeadowAuthorization).to.equal(true);
|
|
1133
|
+
});
|
|
1134
|
+
tmpMockFullRequest.UserSession.CustomerID = 100;
|
|
1135
|
+
tmpMockFullRequest.UserSession.UserID = 100;
|
|
1136
|
+
// Now they should both fail
|
|
1137
|
+
tmpAuthorizers.authorize('Mine', tmpMockFullRequest,
|
|
1138
|
+
function()
|
|
1139
|
+
{
|
|
1140
|
+
//If record does not have matching CreatingIDUser, then it should fail
|
|
1141
|
+
Expect(tmpMockFullRequest.MeadowAuthorization).to.equal(false);
|
|
1142
|
+
});
|
|
1143
|
+
tmpAuthorizers.authorize('MyCustomer', tmpMockFullRequest,
|
|
1144
|
+
function()
|
|
1145
|
+
{
|
|
1146
|
+
//If record does not have matching CustomerID, then it should fail
|
|
1147
|
+
Expect(tmpMockFullRequest.MeadowAuthorization).to.equal(false);
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
);
|
|
1153
|
+
suite
|
|
1154
|
+
(
|
|
1155
|
+
'Basic Server Routes',
|
|
1156
|
+
function()
|
|
1157
|
+
{
|
|
1158
|
+
test
|
|
1159
|
+
(
|
|
1160
|
+
'create: create a record',
|
|
1161
|
+
function(fDone)
|
|
1162
|
+
{
|
|
1163
|
+
var tmpRecord = {Name:'BatBrains', Type:'Mammoth'};
|
|
1164
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
1165
|
+
libSuperTest('http://localhost:9080/')
|
|
1166
|
+
.post('1.0/FableTest')
|
|
1167
|
+
.send(tmpRecord)
|
|
1168
|
+
.end(
|
|
1169
|
+
function(pError, pResponse)
|
|
1170
|
+
{
|
|
1171
|
+
// Expect response to be the record we just created.
|
|
1172
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1173
|
+
Expect(tmpResult.Type).to.equal('Mammoth');
|
|
1174
|
+
Expect(tmpResult.CreatingIDUser).to.equal(37);
|
|
1175
|
+
fDone();
|
|
1176
|
+
}
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
);
|
|
1180
|
+
test
|
|
1181
|
+
(
|
|
1182
|
+
'create: create a record',
|
|
1183
|
+
function(fDone)
|
|
1184
|
+
{
|
|
1185
|
+
var tmpRecord = {Name:'BatBrains', Type:'Mammoth'};
|
|
1186
|
+
_MockSessionValidUser.UserRoleIndex = 1;
|
|
1187
|
+
libSuperTest('http://localhost:9080/')
|
|
1188
|
+
.post('1.0/FableTest')
|
|
1189
|
+
.send(tmpRecord)
|
|
1190
|
+
.end(
|
|
1191
|
+
function(pError, pResponse)
|
|
1192
|
+
{
|
|
1193
|
+
// Expect response to be the record we just created.
|
|
1194
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1195
|
+
Expect(tmpResult.Error).to.contain('authenticated');
|
|
1196
|
+
fDone();
|
|
1197
|
+
}
|
|
1198
|
+
);
|
|
1199
|
+
}
|
|
1200
|
+
);
|
|
1201
|
+
test
|
|
1202
|
+
(
|
|
1203
|
+
'create: create a record with a bad record passed in',
|
|
1204
|
+
function(fDone)
|
|
1205
|
+
{
|
|
1206
|
+
var tmpRecord = ' ';
|
|
1207
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
1208
|
+
libSuperTest('http://localhost:9080/')
|
|
1209
|
+
.post('1.0/FableTest')
|
|
1210
|
+
.send(tmpRecord)
|
|
1211
|
+
.end(
|
|
1212
|
+
function(pError, pResponse)
|
|
1213
|
+
{
|
|
1214
|
+
// Expect response to be the record we just created.
|
|
1215
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1216
|
+
Expect(tmpResult.Error).to.not.be.null;
|
|
1217
|
+
fDone();
|
|
1218
|
+
}
|
|
1219
|
+
);
|
|
1220
|
+
}
|
|
1221
|
+
);
|
|
1222
|
+
test
|
|
1223
|
+
(
|
|
1224
|
+
'read: get a specific record',
|
|
1225
|
+
function(fDone)
|
|
1226
|
+
{
|
|
1227
|
+
libSuperTest('http://localhost:9080/')
|
|
1228
|
+
.get('1.0/FableTest/2')
|
|
1229
|
+
.end(
|
|
1230
|
+
function (pError, pResponse)
|
|
1231
|
+
{
|
|
1232
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1233
|
+
Expect(tmpResult.Type).to.equal('Girl');
|
|
1234
|
+
fDone();
|
|
1235
|
+
}
|
|
1236
|
+
);
|
|
1237
|
+
}
|
|
1238
|
+
);
|
|
1239
|
+
test
|
|
1240
|
+
(
|
|
1241
|
+
'read: define a custom authorization behavior',
|
|
1242
|
+
function(fDone)
|
|
1243
|
+
{
|
|
1244
|
+
const defaultAuthorizer = _MeadowEndpoints.endpointAuthorizers.getAuthorizer('Allow');
|
|
1245
|
+
_MeadowEndpoints.endpointAuthorizers.setAuthorizer('Allow', function(req, next) { req.MeadowAuthorization = false; return next(); });
|
|
1246
|
+
_Orator.webServer.get('/CustomHotRodRoute/:IDRecord', _MeadowEndpoints.endpointAuthenticators.Read, _MeadowEndpoints.wireState, _MeadowEndpoints.endpoints.Read);
|
|
1247
|
+
libSuperTest('http://localhost:9080/')
|
|
1248
|
+
.get('CustomHotRodRoute/2')
|
|
1249
|
+
.end(
|
|
1250
|
+
function (pError, pResponse)
|
|
1251
|
+
{
|
|
1252
|
+
_MeadowEndpoints.endpointAuthorizers.setAuthorizer('Allow', defaultAuthorizer);
|
|
1253
|
+
//TODO: it's weird that we don't get an error here for access denied...
|
|
1254
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1255
|
+
Expect(tmpResult.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
1256
|
+
fDone();
|
|
1257
|
+
}
|
|
1258
|
+
);
|
|
1259
|
+
}
|
|
1260
|
+
);
|
|
1261
|
+
test
|
|
1262
|
+
(
|
|
1263
|
+
'read: define a custom route and get a record with it',
|
|
1264
|
+
function(fDone)
|
|
1265
|
+
{
|
|
1266
|
+
_Orator.webServer.get('/CustomHotRodRoute/:IDRecord', _MeadowEndpoints.endpointAuthenticators.Read, _MeadowEndpoints.wireState, _MeadowEndpoints.endpoints.Read);
|
|
1267
|
+
libSuperTest('http://localhost:9080/')
|
|
1268
|
+
.get('CustomHotRodRoute/2')
|
|
1269
|
+
.end(
|
|
1270
|
+
function (pError, pResponse)
|
|
1271
|
+
{
|
|
1272
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1273
|
+
Expect(tmpResult.Type).to.equal('Girl');
|
|
1274
|
+
fDone();
|
|
1275
|
+
}
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
);
|
|
1279
|
+
test
|
|
1280
|
+
(
|
|
1281
|
+
'read: get a specific record but be denied by security',
|
|
1282
|
+
function(fDone)
|
|
1283
|
+
{
|
|
1284
|
+
_Meadow.schemaFull.authorizer.Manager = {};
|
|
1285
|
+
_Meadow.schemaFull.authorizer.Manager.Read = 'Deny';
|
|
1286
|
+
|
|
1287
|
+
libSuperTest('http://localhost:9080/')
|
|
1288
|
+
.get('1.0/FableTest/2')
|
|
1289
|
+
.end(
|
|
1290
|
+
function (pError, pResponse)
|
|
1291
|
+
{
|
|
1292
|
+
Expect(pResponse.text).to.contain('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
1293
|
+
// Reset authorization
|
|
1294
|
+
_Meadow.schemaFull.authorizer.Manager.Read = 'Allow';
|
|
1295
|
+
fDone();
|
|
1296
|
+
}
|
|
1297
|
+
);
|
|
1298
|
+
}
|
|
1299
|
+
);
|
|
1300
|
+
test
|
|
1301
|
+
(
|
|
1302
|
+
'read: get a specific record which resolved to Deny authorization, but with a Deny authorizer that just allows',
|
|
1303
|
+
function(fDone)
|
|
1304
|
+
{
|
|
1305
|
+
_Meadow.schemaFull.authorizer.Manager = {};
|
|
1306
|
+
_Meadow.schemaFull.authorizer.Manager.Read = 'Deny';
|
|
1307
|
+
const defaultAuthorizer = _MeadowEndpoints.endpointAuthorizers.getAuthorizer('Deny');
|
|
1308
|
+
_MeadowEndpoints.endpointAuthorizers.setAuthorizer('Deny', function(req, next) { req.MeadowAuthorization = true; return next(); });
|
|
1309
|
+
|
|
1310
|
+
libSuperTest('http://localhost:9080/')
|
|
1311
|
+
.get('1.0/FableTest/2')
|
|
1312
|
+
.end(
|
|
1313
|
+
function (pError, pResponse)
|
|
1314
|
+
{
|
|
1315
|
+
// Reset authorization
|
|
1316
|
+
_Meadow.schemaFull.authorizer.Manager.Read = 'Allow';
|
|
1317
|
+
_MeadowEndpoints.endpointAuthorizers.setAuthorizer('Deny', defaultAuthorizer);
|
|
1318
|
+
|
|
1319
|
+
const responseBody = JSON.parse(pResponse.text);
|
|
1320
|
+
Expect(responseBody.IDAnimal).to.equal(2);
|
|
1321
|
+
fDone();
|
|
1322
|
+
}
|
|
1323
|
+
);
|
|
1324
|
+
}
|
|
1325
|
+
);
|
|
1326
|
+
test
|
|
1327
|
+
(
|
|
1328
|
+
'read: get a specific record with a bad parameter',
|
|
1329
|
+
function(fDone)
|
|
1330
|
+
{
|
|
1331
|
+
libSuperTest('http://localhost:9080/')
|
|
1332
|
+
.get('1.0/FableTest/')
|
|
1333
|
+
.end(
|
|
1334
|
+
function (pError, pResponse)
|
|
1335
|
+
{
|
|
1336
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1337
|
+
Expect(tmpResult.Error).to.equal('Error retreiving a record. Record not found');
|
|
1338
|
+
fDone();
|
|
1339
|
+
}
|
|
1340
|
+
);
|
|
1341
|
+
}
|
|
1342
|
+
);
|
|
1343
|
+
test
|
|
1344
|
+
(
|
|
1345
|
+
'reads: get all records',
|
|
1346
|
+
function(fDone)
|
|
1347
|
+
{
|
|
1348
|
+
libSuperTest('http://localhost:9080/')
|
|
1349
|
+
.get('1.0/FableTests')
|
|
1350
|
+
.end(
|
|
1351
|
+
function (pError, pResponse)
|
|
1352
|
+
{
|
|
1353
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1354
|
+
Expect(tmpResults.length).to.equal(6);
|
|
1355
|
+
Expect(tmpResults[0].Type).to.equal('Bunny');
|
|
1356
|
+
Expect(tmpResults[4].Name).to.equal('Gertrude');
|
|
1357
|
+
fDone();
|
|
1358
|
+
}
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
);
|
|
1362
|
+
test
|
|
1363
|
+
(
|
|
1364
|
+
'readsLiteExtended: get all records',
|
|
1365
|
+
function(fDone)
|
|
1366
|
+
{
|
|
1367
|
+
libSuperTest('http://localhost:9080/')
|
|
1368
|
+
.get('1.0/FableTests/LiteExtended/Type,Name')
|
|
1369
|
+
.end(
|
|
1370
|
+
function (pError, pResponse)
|
|
1371
|
+
{
|
|
1372
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1373
|
+
Expect(tmpResults.length).to.equal(6);
|
|
1374
|
+
Expect(tmpResults[0].IDAnimal).to.equal(1);
|
|
1375
|
+
Expect(tmpResults[4].IDAnimal).to.equal(5);
|
|
1376
|
+
Expect(tmpResults[4].Type).to.equal('Frog');
|
|
1377
|
+
fDone();
|
|
1378
|
+
}
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
);
|
|
1382
|
+
test
|
|
1383
|
+
(
|
|
1384
|
+
'readsby: get all records by Type',
|
|
1385
|
+
function(fDone)
|
|
1386
|
+
{
|
|
1387
|
+
libSuperTest('http://localhost:9080/')
|
|
1388
|
+
.get('1.0/FableTests/By/Type/Dog')
|
|
1389
|
+
.end(
|
|
1390
|
+
function (pError, pResponse)
|
|
1391
|
+
{
|
|
1392
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1393
|
+
Expect(tmpResults.length).to.equal(2);
|
|
1394
|
+
Expect(tmpResults[0].Type).to.equal('Dog');
|
|
1395
|
+
fDone();
|
|
1396
|
+
}
|
|
1397
|
+
);
|
|
1398
|
+
}
|
|
1399
|
+
);
|
|
1400
|
+
test
|
|
1401
|
+
(
|
|
1402
|
+
'readsby: get all records by Type IN LIST',
|
|
1403
|
+
function(fDone)
|
|
1404
|
+
{
|
|
1405
|
+
libSuperTest('http://localhost:9080/')
|
|
1406
|
+
.get('1.0/FableTests/By/Type/Mammoth%2C%20WithComma,Dog')
|
|
1407
|
+
.end(
|
|
1408
|
+
function (pError, pResponse)
|
|
1409
|
+
{
|
|
1410
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1411
|
+
Expect(tmpResults.length).to.equal(2);
|
|
1412
|
+
Expect(tmpResults[0].Type).to.equal('Dog');
|
|
1413
|
+
fDone();
|
|
1414
|
+
}
|
|
1415
|
+
);
|
|
1416
|
+
}
|
|
1417
|
+
);
|
|
1418
|
+
test
|
|
1419
|
+
(
|
|
1420
|
+
'countby: get count of records by Type',
|
|
1421
|
+
function(fDone)
|
|
1422
|
+
{
|
|
1423
|
+
libSuperTest('http://localhost:9080/')
|
|
1424
|
+
.get('1.0/FableTests/Count/By/Type/Dog')
|
|
1425
|
+
.end(
|
|
1426
|
+
function (pError, pResponse)
|
|
1427
|
+
{
|
|
1428
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1429
|
+
Expect(tmpResults.Count).to.equal(2);
|
|
1430
|
+
fDone();
|
|
1431
|
+
}
|
|
1432
|
+
);
|
|
1433
|
+
}
|
|
1434
|
+
);
|
|
1435
|
+
test
|
|
1436
|
+
(
|
|
1437
|
+
'countby: get count of records by multiple Types',
|
|
1438
|
+
function(fDone)
|
|
1439
|
+
{
|
|
1440
|
+
libSuperTest('http://localhost:9080/')
|
|
1441
|
+
.get('1.0/FableTests/Count/By/Type/Dog,Mammoth')
|
|
1442
|
+
.end(
|
|
1443
|
+
function (pError, pResponse)
|
|
1444
|
+
{
|
|
1445
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1446
|
+
Expect(tmpResults.Count).to.equal(3);
|
|
1447
|
+
fDone();
|
|
1448
|
+
}
|
|
1449
|
+
);
|
|
1450
|
+
}
|
|
1451
|
+
);
|
|
1452
|
+
test
|
|
1453
|
+
(
|
|
1454
|
+
'readsby: get paged records by Type',
|
|
1455
|
+
function(fDone)
|
|
1456
|
+
{
|
|
1457
|
+
libSuperTest('http://localhost:9080/')
|
|
1458
|
+
.get('1.0/FableTests/By/Type/Dog/1/1')
|
|
1459
|
+
.end(
|
|
1460
|
+
function (pError, pResponse)
|
|
1461
|
+
{
|
|
1462
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1463
|
+
Expect(tmpResults.length).to.equal(1);
|
|
1464
|
+
Expect(tmpResults[0].Name).to.equal('Spot');
|
|
1465
|
+
fDone();
|
|
1466
|
+
}
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1469
|
+
);
|
|
1470
|
+
test
|
|
1471
|
+
(
|
|
1472
|
+
'readselect: get a page of filtered records by date',
|
|
1473
|
+
function(fDone)
|
|
1474
|
+
{
|
|
1475
|
+
var today = new Date();
|
|
1476
|
+
today = today.toISOString().substring(0, 10);
|
|
1477
|
+
|
|
1478
|
+
libSuperTest('http://localhost:9080/')
|
|
1479
|
+
.get(`1.0/FableTestSelect/FilteredTo/FBD~UpdateDate~EQ~${today}/0/1`)
|
|
1480
|
+
.end(
|
|
1481
|
+
function (pError, pResponse)
|
|
1482
|
+
{
|
|
1483
|
+
console.log(pResponse.text)
|
|
1484
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1485
|
+
Expect(tmpResults.length).to.equal(1);
|
|
1486
|
+
Expect(tmpResults[0].Value).to.equal('FableTest #1');
|
|
1487
|
+
fDone();
|
|
1488
|
+
}
|
|
1489
|
+
);
|
|
1490
|
+
}
|
|
1491
|
+
);
|
|
1492
|
+
test
|
|
1493
|
+
(
|
|
1494
|
+
'readselect: get all records',
|
|
1495
|
+
function(fDone)
|
|
1496
|
+
{
|
|
1497
|
+
libSuperTest('http://localhost:9080/')
|
|
1498
|
+
.get('1.0/FableTestSelect')
|
|
1499
|
+
.end(
|
|
1500
|
+
function (pError, pResponse)
|
|
1501
|
+
{
|
|
1502
|
+
console.log(pResponse.text)
|
|
1503
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1504
|
+
Expect(tmpResults.length).to.equal(6);
|
|
1505
|
+
Expect(tmpResults[4].Value).to.equal('FableTest #5');
|
|
1506
|
+
fDone();
|
|
1507
|
+
}
|
|
1508
|
+
);
|
|
1509
|
+
}
|
|
1510
|
+
);
|
|
1511
|
+
test
|
|
1512
|
+
(
|
|
1513
|
+
'readselect: get a page of records',
|
|
1514
|
+
function(fDone)
|
|
1515
|
+
{
|
|
1516
|
+
libSuperTest('http://localhost:9080/')
|
|
1517
|
+
.get('1.0/FableTestSelect/2/2')
|
|
1518
|
+
.end(
|
|
1519
|
+
function (pError, pResponse)
|
|
1520
|
+
{
|
|
1521
|
+
console.log(pResponse.text)
|
|
1522
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1523
|
+
Expect(tmpResults.length).to.equal(2);
|
|
1524
|
+
Expect(tmpResults[1].Value).to.equal('FableTest #4');
|
|
1525
|
+
fDone();
|
|
1526
|
+
}
|
|
1527
|
+
);
|
|
1528
|
+
}
|
|
1529
|
+
);
|
|
1530
|
+
test
|
|
1531
|
+
(
|
|
1532
|
+
'readselect: get a page of records',
|
|
1533
|
+
function(fDone)
|
|
1534
|
+
{
|
|
1535
|
+
libSuperTest('http://localhost:9080/')
|
|
1536
|
+
.get('1.0/FableTestSelect/2/2')
|
|
1537
|
+
.end(
|
|
1538
|
+
function (pError, pResponse)
|
|
1539
|
+
{
|
|
1540
|
+
console.log(pResponse.text)
|
|
1541
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1542
|
+
Expect(tmpResults.length).to.equal(2);
|
|
1543
|
+
Expect(tmpResults[1].Value).to.equal('FableTest #4');
|
|
1544
|
+
fDone();
|
|
1545
|
+
}
|
|
1546
|
+
);
|
|
1547
|
+
}
|
|
1548
|
+
);
|
|
1549
|
+
test
|
|
1550
|
+
(
|
|
1551
|
+
'readselect: get filtered records',
|
|
1552
|
+
function(fDone)
|
|
1553
|
+
{
|
|
1554
|
+
libSuperTest('http://localhost:9080/')
|
|
1555
|
+
.get('1.0/FableTestSelect/FilteredTo/FBV~Type~EQ~Dog')
|
|
1556
|
+
.end(
|
|
1557
|
+
function (pError, pResponse)
|
|
1558
|
+
{
|
|
1559
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1560
|
+
Expect(tmpResults.length).to.equal(2);
|
|
1561
|
+
Expect(tmpResults[0].Value).to.equal('FableTest #3');
|
|
1562
|
+
fDone();
|
|
1563
|
+
}
|
|
1564
|
+
);
|
|
1565
|
+
}
|
|
1566
|
+
);
|
|
1567
|
+
test
|
|
1568
|
+
(
|
|
1569
|
+
'readselect: get a page of filtered records',
|
|
1570
|
+
function(fDone)
|
|
1571
|
+
{
|
|
1572
|
+
libSuperTest('http://localhost:9080/')
|
|
1573
|
+
.get('1.0/FableTestSelect/FilteredTo/FBV~Type~EQ~Dog/1/1')
|
|
1574
|
+
.end(
|
|
1575
|
+
function (pError, pResponse)
|
|
1576
|
+
{
|
|
1577
|
+
console.log(pResponse.text)
|
|
1578
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1579
|
+
Expect(tmpResults.length).to.equal(1);
|
|
1580
|
+
Expect(tmpResults[0].Value).to.equal('FableTest #4');
|
|
1581
|
+
fDone();
|
|
1582
|
+
}
|
|
1583
|
+
);
|
|
1584
|
+
}
|
|
1585
|
+
);
|
|
1586
|
+
test
|
|
1587
|
+
(
|
|
1588
|
+
'readselect: get an empty page of records',
|
|
1589
|
+
function(fDone)
|
|
1590
|
+
{
|
|
1591
|
+
libSuperTest('http://localhost:9080/')
|
|
1592
|
+
.get('1.0/FableTestSelect/200/200')
|
|
1593
|
+
.end(
|
|
1594
|
+
function (pError, pResponse)
|
|
1595
|
+
{
|
|
1596
|
+
console.log(pResponse.text)
|
|
1597
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1598
|
+
Expect(tmpResults.length).to.equal(0);
|
|
1599
|
+
fDone();
|
|
1600
|
+
}
|
|
1601
|
+
);
|
|
1602
|
+
}
|
|
1603
|
+
);
|
|
1604
|
+
test
|
|
1605
|
+
(
|
|
1606
|
+
'reads: get a page of records',
|
|
1607
|
+
function(fDone)
|
|
1608
|
+
{
|
|
1609
|
+
libSuperTest('http://localhost:9080/')
|
|
1610
|
+
// Get page 2, 2 records per page.
|
|
1611
|
+
.get('1.0/FableTests/2/2')
|
|
1612
|
+
.end(
|
|
1613
|
+
function (pError, pResponse)
|
|
1614
|
+
{
|
|
1615
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1616
|
+
Expect(tmpResults.length).to.equal(2);
|
|
1617
|
+
Expect(tmpResults[0].Type).to.equal('Dog');
|
|
1618
|
+
Expect(tmpResults[1].Name).to.equal('Spot');
|
|
1619
|
+
fDone();
|
|
1620
|
+
}
|
|
1621
|
+
);
|
|
1622
|
+
}
|
|
1623
|
+
);
|
|
1624
|
+
test
|
|
1625
|
+
(
|
|
1626
|
+
'reads: get a filtered set of records',
|
|
1627
|
+
function(fDone)
|
|
1628
|
+
{
|
|
1629
|
+
libSuperTest('http://localhost:9080/')
|
|
1630
|
+
.get('1.0/FableTests/FilteredTo/FBV~Type~EQ~Frog')
|
|
1631
|
+
.end(
|
|
1632
|
+
function (pError, pResponse)
|
|
1633
|
+
{
|
|
1634
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1635
|
+
Expect(tmpResults.length).to.equal(1);
|
|
1636
|
+
Expect(tmpResults[0].Type).to.equal('Frog');
|
|
1637
|
+
fDone();
|
|
1638
|
+
}
|
|
1639
|
+
);
|
|
1640
|
+
}
|
|
1641
|
+
);
|
|
1642
|
+
test
|
|
1643
|
+
(
|
|
1644
|
+
'reads: get distinct values for a column',
|
|
1645
|
+
function(fDone)
|
|
1646
|
+
{
|
|
1647
|
+
libSuperTest('http://localhost:9080/')
|
|
1648
|
+
.get('1.0/FableTests/Distinct/Type')
|
|
1649
|
+
.end(
|
|
1650
|
+
function (pError, pResponse)
|
|
1651
|
+
{
|
|
1652
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1653
|
+
Expect(tmpResults.length).to.equal(5);
|
|
1654
|
+
const types = tmpResults.map((r) => r.Type);
|
|
1655
|
+
Expect(types).to.have.members(['Bunny', 'Girl', 'Dog', 'Frog', 'Mammoth']);
|
|
1656
|
+
fDone();
|
|
1657
|
+
}
|
|
1658
|
+
);
|
|
1659
|
+
}
|
|
1660
|
+
);
|
|
1661
|
+
test
|
|
1662
|
+
(
|
|
1663
|
+
'reads: get distinct values for a column with filter',
|
|
1664
|
+
function(fDone)
|
|
1665
|
+
{
|
|
1666
|
+
libSuperTest('http://localhost:9080/')
|
|
1667
|
+
.get('1.0/FableTests/Distinct/Type/FilteredTo/FBV~IDAnimal~LT~3')
|
|
1668
|
+
.end(
|
|
1669
|
+
function (pError, pResponse)
|
|
1670
|
+
{
|
|
1671
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1672
|
+
Expect(tmpResults.length).to.equal(2);
|
|
1673
|
+
const types = new Set(tmpResults.map((r) => r.Type));
|
|
1674
|
+
Expect(types.size).to.equal(2);
|
|
1675
|
+
fDone();
|
|
1676
|
+
}
|
|
1677
|
+
);
|
|
1678
|
+
}
|
|
1679
|
+
);
|
|
1680
|
+
test
|
|
1681
|
+
(
|
|
1682
|
+
'reads: get distinct values for a column with filter and pagination',
|
|
1683
|
+
function(fDone)
|
|
1684
|
+
{
|
|
1685
|
+
libSuperTest('http://localhost:9080/')
|
|
1686
|
+
.get('1.0/FableTests/Distinct/Type/FilteredTo/FBV~IDAnimal~LT~3/0/1')
|
|
1687
|
+
.end(
|
|
1688
|
+
function (pError, pResponse)
|
|
1689
|
+
{
|
|
1690
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1691
|
+
Expect(tmpResults.length).to.equal(1);
|
|
1692
|
+
fDone();
|
|
1693
|
+
}
|
|
1694
|
+
);
|
|
1695
|
+
}
|
|
1696
|
+
);
|
|
1697
|
+
test
|
|
1698
|
+
(
|
|
1699
|
+
'reads: get distinct values for a column with pagination',
|
|
1700
|
+
function(fDone)
|
|
1701
|
+
{
|
|
1702
|
+
libSuperTest('http://localhost:9080/')
|
|
1703
|
+
.get('1.0/FableTests/Distinct/Type/2/2')
|
|
1704
|
+
.end(
|
|
1705
|
+
function (pError, pResponse)
|
|
1706
|
+
{
|
|
1707
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1708
|
+
Expect(tmpResults.length).to.equal(2);
|
|
1709
|
+
const types = new Set(tmpResults.map((r) => r.Type));
|
|
1710
|
+
Expect(types.size).to.equal(2);
|
|
1711
|
+
fDone();
|
|
1712
|
+
}
|
|
1713
|
+
);
|
|
1714
|
+
}
|
|
1715
|
+
);
|
|
1716
|
+
test
|
|
1717
|
+
(
|
|
1718
|
+
'reads: get a filtered paged set of records',
|
|
1719
|
+
function(fDone)
|
|
1720
|
+
{
|
|
1721
|
+
libSuperTest('http://localhost:9080/')
|
|
1722
|
+
// Skip one record, 2 records per page.
|
|
1723
|
+
.get('1.0/FableTests/FilteredTo/FBV~Type~EQ~Dog/1/2')
|
|
1724
|
+
.end(
|
|
1725
|
+
function (pError, pResponse)
|
|
1726
|
+
{
|
|
1727
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1728
|
+
Expect(tmpResults.length).to.equal(1);
|
|
1729
|
+
Expect(tmpResults[0].Type).to.equal('Dog');
|
|
1730
|
+
fDone();
|
|
1731
|
+
}
|
|
1732
|
+
);
|
|
1733
|
+
}
|
|
1734
|
+
);
|
|
1735
|
+
test
|
|
1736
|
+
(
|
|
1737
|
+
'update: update a record',
|
|
1738
|
+
function(fDone)
|
|
1739
|
+
{
|
|
1740
|
+
// Change animal 4 ("Spot") to a Corgi
|
|
1741
|
+
var tmpRecord = {IDAnimal:4, Type:'Corgi'};
|
|
1742
|
+
libSuperTest('http://localhost:9080/')
|
|
1743
|
+
.put('1.0/FableTest')
|
|
1744
|
+
.send(tmpRecord)
|
|
1745
|
+
.end(
|
|
1746
|
+
function(pError, pResponse)
|
|
1747
|
+
{
|
|
1748
|
+
// Expect response to be the record we just created.
|
|
1749
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1750
|
+
Expect(tmpResult.Type).to.equal('Corgi');
|
|
1751
|
+
Expect(tmpResult.CreatingIDUser).to.equal(1);
|
|
1752
|
+
Expect(tmpResult.UpdatingIDUser).to.equal(37);
|
|
1753
|
+
fDone();
|
|
1754
|
+
}
|
|
1755
|
+
);
|
|
1756
|
+
}
|
|
1757
|
+
);
|
|
1758
|
+
test
|
|
1759
|
+
(
|
|
1760
|
+
'delete: delete a record',
|
|
1761
|
+
function(fDone)
|
|
1762
|
+
{
|
|
1763
|
+
// Delete animal 3 ("Red")
|
|
1764
|
+
var tmpRecord = {IDAnimal:3};
|
|
1765
|
+
libSuperTest('http://localhost:9080/')
|
|
1766
|
+
.del('1.0/FableTest')
|
|
1767
|
+
.send(tmpRecord)
|
|
1768
|
+
.end(
|
|
1769
|
+
function(pError, pResponse)
|
|
1770
|
+
{
|
|
1771
|
+
// Expect response to be the count of deleted records.
|
|
1772
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1773
|
+
Expect(tmpResult.Count).to.equal(1);
|
|
1774
|
+
fDone();
|
|
1775
|
+
}
|
|
1776
|
+
);
|
|
1777
|
+
}
|
|
1778
|
+
);
|
|
1779
|
+
test
|
|
1780
|
+
(
|
|
1781
|
+
'delete: undelete a record after deleting it',
|
|
1782
|
+
function(fDone)
|
|
1783
|
+
{
|
|
1784
|
+
// Delete animal 4
|
|
1785
|
+
var tmpRecord = {IDAnimal:4};
|
|
1786
|
+
libSuperTest('http://localhost:9080/')
|
|
1787
|
+
.del('1.0/FableTest')
|
|
1788
|
+
.send(tmpRecord)
|
|
1789
|
+
.end(
|
|
1790
|
+
function(pError, pResponse)
|
|
1791
|
+
{
|
|
1792
|
+
// Expect response to be the count of deleted records.
|
|
1793
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1794
|
+
Expect(tmpResult.Count).to.equal(1);
|
|
1795
|
+
|
|
1796
|
+
// Now undelete the record
|
|
1797
|
+
libSuperTest('http://localhost:9080/')
|
|
1798
|
+
.get('1.0/FableTest/Undelete/4')
|
|
1799
|
+
.end(
|
|
1800
|
+
function(pError, pResponse)
|
|
1801
|
+
{
|
|
1802
|
+
// Expect response to be the count of deleted records.
|
|
1803
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1804
|
+
Expect(tmpResult.Count).to.equal(1);
|
|
1805
|
+
return fDone();
|
|
1806
|
+
}
|
|
1807
|
+
);
|
|
1808
|
+
}
|
|
1809
|
+
);
|
|
1810
|
+
}
|
|
1811
|
+
);
|
|
1812
|
+
test
|
|
1813
|
+
(
|
|
1814
|
+
'delete: delete a record with a bad parameter',
|
|
1815
|
+
function(fDone)
|
|
1816
|
+
{
|
|
1817
|
+
// Delete animal 3 ("Red")
|
|
1818
|
+
var tmpRecord = {IDAnimal:{MyStuff:4}};
|
|
1819
|
+
libSuperTest('http://localhost:9080/')
|
|
1820
|
+
.del('1.0/FableTest')
|
|
1821
|
+
.send(tmpRecord)
|
|
1822
|
+
.end(
|
|
1823
|
+
function(pError, pResponse)
|
|
1824
|
+
{
|
|
1825
|
+
// Expect response to be the count of deleted records.
|
|
1826
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1827
|
+
Expect(tmpResult.Error).to.contain('a valid record ID is required');
|
|
1828
|
+
fDone();
|
|
1829
|
+
}
|
|
1830
|
+
);
|
|
1831
|
+
}
|
|
1832
|
+
);
|
|
1833
|
+
test
|
|
1834
|
+
(
|
|
1835
|
+
'count: get the count of records',
|
|
1836
|
+
function(fDone)
|
|
1837
|
+
{
|
|
1838
|
+
libSuperTest('http://localhost:9080/')
|
|
1839
|
+
.get('1.0/FableTests/Count')
|
|
1840
|
+
.end(
|
|
1841
|
+
function (pError, pResponse)
|
|
1842
|
+
{
|
|
1843
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1844
|
+
Expect(tmpResults.Count).to.equal(5);
|
|
1845
|
+
fDone();
|
|
1846
|
+
}
|
|
1847
|
+
);
|
|
1848
|
+
}
|
|
1849
|
+
);
|
|
1850
|
+
test
|
|
1851
|
+
(
|
|
1852
|
+
'count: get the count of filtered records',
|
|
1853
|
+
function(fDone)
|
|
1854
|
+
{
|
|
1855
|
+
libSuperTest('http://localhost:9080/')
|
|
1856
|
+
.get('1.0/FableTests/Count/FilteredTo/FBV~Type~EQ~Girl')
|
|
1857
|
+
.end(
|
|
1858
|
+
function (pError, pResponse)
|
|
1859
|
+
{
|
|
1860
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1861
|
+
Expect(tmpResults.Count).to.equal(1);
|
|
1862
|
+
fDone();
|
|
1863
|
+
}
|
|
1864
|
+
);
|
|
1865
|
+
}
|
|
1866
|
+
);
|
|
1867
|
+
test
|
|
1868
|
+
(
|
|
1869
|
+
'schema: get the schema of a record',
|
|
1870
|
+
function(fDone)
|
|
1871
|
+
{
|
|
1872
|
+
libSuperTest('http://localhost:9080/')
|
|
1873
|
+
.get('1.0/FableTest/Schema')
|
|
1874
|
+
.end(
|
|
1875
|
+
function (pError, pResponse)
|
|
1876
|
+
{
|
|
1877
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1878
|
+
//console.log('SCHEMA --> '+JSON.stringify(tmpResults, null, 4))
|
|
1879
|
+
Expect(tmpResults.title).to.equal('Animal');
|
|
1880
|
+
Expect(tmpResults.description).to.contain('creature that lives in');
|
|
1881
|
+
fDone();
|
|
1882
|
+
}
|
|
1883
|
+
);
|
|
1884
|
+
}
|
|
1885
|
+
);
|
|
1886
|
+
test
|
|
1887
|
+
(
|
|
1888
|
+
'new: get a new empty record',
|
|
1889
|
+
function(fDone)
|
|
1890
|
+
{
|
|
1891
|
+
libSuperTest('http://localhost:9080/')
|
|
1892
|
+
.get('1.0/FableTest/Schema/New')
|
|
1893
|
+
.end(
|
|
1894
|
+
function (pError, pResponse)
|
|
1895
|
+
{
|
|
1896
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
1897
|
+
//console.log(JSON.stringify(tmpResults, null, 4))
|
|
1898
|
+
Expect(tmpResults.IDAnimal).to.equal(null);
|
|
1899
|
+
Expect(tmpResults.Name).to.equal('Unknown');
|
|
1900
|
+
Expect(tmpResults.Type).to.equal('Unclassified');
|
|
1901
|
+
fDone();
|
|
1902
|
+
}
|
|
1903
|
+
);
|
|
1904
|
+
}
|
|
1905
|
+
);
|
|
1906
|
+
test
|
|
1907
|
+
(
|
|
1908
|
+
'validate: validate an invalid record',
|
|
1909
|
+
function(fDone)
|
|
1910
|
+
{
|
|
1911
|
+
var tmpRecord = {IDAnimal:4, Type:'Corgi'};
|
|
1912
|
+
libSuperTest('http://localhost:9080/')
|
|
1913
|
+
.post('1.0/FableTest/Schema/Validate')
|
|
1914
|
+
.send(tmpRecord)
|
|
1915
|
+
.end(
|
|
1916
|
+
function(pError, pResponse)
|
|
1917
|
+
{
|
|
1918
|
+
// Expect response to be the record we just created.
|
|
1919
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1920
|
+
//console.log(JSON.stringify(tmpResult, null, 4))
|
|
1921
|
+
Expect(tmpResult.Valid).to.equal(false);
|
|
1922
|
+
Expect(tmpResult.Errors[0].field).to.equal('data.Name');
|
|
1923
|
+
Expect(tmpResult.Errors[0].message).to.equal('is required');
|
|
1924
|
+
fDone();
|
|
1925
|
+
}
|
|
1926
|
+
);
|
|
1927
|
+
}
|
|
1928
|
+
);
|
|
1929
|
+
test
|
|
1930
|
+
(
|
|
1931
|
+
'validate: validate a valid record',
|
|
1932
|
+
function(fDone)
|
|
1933
|
+
{
|
|
1934
|
+
var tmpRecord = {IDAnimal:4, Type:'Corgi', Name:'Doofer', CreatingIDUser:10};
|
|
1935
|
+
libSuperTest('http://localhost:9080/')
|
|
1936
|
+
.post('1.0/FableTest/Schema/Validate')
|
|
1937
|
+
.send(tmpRecord)
|
|
1938
|
+
.end(
|
|
1939
|
+
function(pError, pResponse)
|
|
1940
|
+
{
|
|
1941
|
+
// Expect response to be the record we just created.
|
|
1942
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1943
|
+
//console.log(JSON.stringify(tmpResult, null, 4))
|
|
1944
|
+
Expect(tmpResult.Valid).to.equal(true);
|
|
1945
|
+
fDone();
|
|
1946
|
+
}
|
|
1947
|
+
);
|
|
1948
|
+
}
|
|
1949
|
+
);
|
|
1950
|
+
test
|
|
1951
|
+
(
|
|
1952
|
+
'validate: validate bad data',
|
|
1953
|
+
function(fDone)
|
|
1954
|
+
{
|
|
1955
|
+
var tmpRecord = 'IAMBAD';
|
|
1956
|
+
libSuperTest('http://localhost:9080/')
|
|
1957
|
+
.post('1.0/FableTest/Schema/Validate')
|
|
1958
|
+
.send(tmpRecord)
|
|
1959
|
+
.end(
|
|
1960
|
+
function(pError, pResponse)
|
|
1961
|
+
{
|
|
1962
|
+
// Expect response to be the record we just created.
|
|
1963
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1964
|
+
//console.log(JSON.stringify(tmpResult, null, 4))
|
|
1965
|
+
Expect(tmpResult.Valid).to.be.false;
|
|
1966
|
+
fDone();
|
|
1967
|
+
}
|
|
1968
|
+
);
|
|
1969
|
+
}
|
|
1970
|
+
);
|
|
1971
|
+
}
|
|
1972
|
+
);
|
|
1973
|
+
suite
|
|
1974
|
+
(
|
|
1975
|
+
'Unauthorized server routes',
|
|
1976
|
+
function()
|
|
1977
|
+
{
|
|
1978
|
+
test
|
|
1979
|
+
(
|
|
1980
|
+
'read: get a specific record',
|
|
1981
|
+
function(fDone)
|
|
1982
|
+
{
|
|
1983
|
+
_MockSessionValidUser.UserRoleIndex = -1;
|
|
1984
|
+
libSuperTest('http://localhost:9080/')
|
|
1985
|
+
.get('1.0/FableTest/2')
|
|
1986
|
+
.end(
|
|
1987
|
+
function (pError, pResponse)
|
|
1988
|
+
{
|
|
1989
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1990
|
+
Expect(tmpResult.Error).to.contain('You must be appropriately authenticated');
|
|
1991
|
+
_MockSessionValidUser.UserRoleIndex = 1;
|
|
1992
|
+
fDone();
|
|
1993
|
+
}
|
|
1994
|
+
);
|
|
1995
|
+
}
|
|
1996
|
+
);
|
|
1997
|
+
}
|
|
1998
|
+
);
|
|
1999
|
+
suite
|
|
2000
|
+
(
|
|
2001
|
+
'Bad user server routes',
|
|
2002
|
+
function()
|
|
2003
|
+
{
|
|
2004
|
+
test
|
|
2005
|
+
(
|
|
2006
|
+
'create: create a record',
|
|
2007
|
+
function(fDone)
|
|
2008
|
+
{
|
|
2009
|
+
_MockSessionValidUser.UserID = 0;
|
|
2010
|
+
var tmpRecord = {Name:'BatBrains', Type:'Mammoth'};
|
|
2011
|
+
libSuperTest('http://localhost:9080/')
|
|
2012
|
+
.post('1.0/FableTest')
|
|
2013
|
+
.send(tmpRecord)
|
|
2014
|
+
.end(
|
|
2015
|
+
function(pError, pResponse)
|
|
2016
|
+
{
|
|
2017
|
+
// Expect response to be the record we just created.
|
|
2018
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2019
|
+
Expect(tmpResult.Error).to.contain('authenticated');
|
|
2020
|
+
fDone();
|
|
2021
|
+
}
|
|
2022
|
+
);
|
|
2023
|
+
}
|
|
2024
|
+
);
|
|
2025
|
+
test
|
|
2026
|
+
(
|
|
2027
|
+
'read: get a specific record',
|
|
2028
|
+
function(fDone)
|
|
2029
|
+
{
|
|
2030
|
+
libSuperTest('http://localhost:9080/')
|
|
2031
|
+
.get('1.0/FableTest/2')
|
|
2032
|
+
.end(
|
|
2033
|
+
function (pError, pResponse)
|
|
2034
|
+
{
|
|
2035
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2036
|
+
Expect(tmpResult.Error).to.contain('authenticated');
|
|
2037
|
+
fDone();
|
|
2038
|
+
}
|
|
2039
|
+
);
|
|
2040
|
+
}
|
|
2041
|
+
);
|
|
2042
|
+
test
|
|
2043
|
+
(
|
|
2044
|
+
'readselect: get all records',
|
|
2045
|
+
function(fDone)
|
|
2046
|
+
{
|
|
2047
|
+
libSuperTest('http://localhost:9080/')
|
|
2048
|
+
.get('1.0/FableTestSelect')
|
|
2049
|
+
.end(
|
|
2050
|
+
function (pError, pResponse)
|
|
2051
|
+
{
|
|
2052
|
+
console.log(pResponse.text)
|
|
2053
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
2054
|
+
Expect(tmpResults.Error).to.contain('authenticated');
|
|
2055
|
+
fDone();
|
|
2056
|
+
}
|
|
2057
|
+
);
|
|
2058
|
+
}
|
|
2059
|
+
);
|
|
2060
|
+
test
|
|
2061
|
+
(
|
|
2062
|
+
'update: update a record',
|
|
2063
|
+
function(fDone)
|
|
2064
|
+
{
|
|
2065
|
+
// Change animal 4 ("Spot") to a Corgi
|
|
2066
|
+
var tmpRecord = {IDAnimal:4, Type:'Corgi'};
|
|
2067
|
+
libSuperTest('http://localhost:9080/')
|
|
2068
|
+
.put('1.0/FableTest')
|
|
2069
|
+
.send(tmpRecord)
|
|
2070
|
+
.end(
|
|
2071
|
+
function(pError, pResponse)
|
|
2072
|
+
{
|
|
2073
|
+
// Expect response to be the record we just created.
|
|
2074
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2075
|
+
Expect(tmpResult.Error).to.contain('authenticated');
|
|
2076
|
+
fDone();
|
|
2077
|
+
}
|
|
2078
|
+
);
|
|
2079
|
+
}
|
|
2080
|
+
);
|
|
2081
|
+
test
|
|
2082
|
+
(
|
|
2083
|
+
'schema: get the schema of a record',
|
|
2084
|
+
function(fDone)
|
|
2085
|
+
{
|
|
2086
|
+
libSuperTest('http://localhost:9080/')
|
|
2087
|
+
.get('1.0/FableTest/Schema')
|
|
2088
|
+
.end(
|
|
2089
|
+
function (pError, pResponse)
|
|
2090
|
+
{
|
|
2091
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
2092
|
+
//console.log('SCHEMA --> '+JSON.stringify(tmpResults, null, 4))
|
|
2093
|
+
Expect(tmpResults.Error).to.contain('authenticated');
|
|
2094
|
+
fDone();
|
|
2095
|
+
}
|
|
2096
|
+
);
|
|
2097
|
+
}
|
|
2098
|
+
);
|
|
2099
|
+
test
|
|
2100
|
+
(
|
|
2101
|
+
'new: get a new empty record',
|
|
2102
|
+
function(fDone)
|
|
2103
|
+
{
|
|
2104
|
+
libSuperTest('http://localhost:9080/')
|
|
2105
|
+
.get('1.0/FableTest/Schema/New')
|
|
2106
|
+
.end(
|
|
2107
|
+
function (pError, pResponse)
|
|
2108
|
+
{
|
|
2109
|
+
var tmpResults = JSON.parse(pResponse.text);
|
|
2110
|
+
//console.log(JSON.stringify(tmpResults, null, 4))
|
|
2111
|
+
Expect(tmpResults.Error).to.contain('authenticated');
|
|
2112
|
+
fDone();
|
|
2113
|
+
}
|
|
2114
|
+
);
|
|
2115
|
+
}
|
|
2116
|
+
);
|
|
2117
|
+
test
|
|
2118
|
+
(
|
|
2119
|
+
'validate: validate an invalid record',
|
|
2120
|
+
function(fDone)
|
|
2121
|
+
{
|
|
2122
|
+
var tmpRecord = {IDAnimal:4, Type:'Corgi'};
|
|
2123
|
+
libSuperTest('http://localhost:9080/')
|
|
2124
|
+
.post('1.0/FableTest/Schema/Validate')
|
|
2125
|
+
.send(tmpRecord)
|
|
2126
|
+
.end(
|
|
2127
|
+
function(pError, pResponse)
|
|
2128
|
+
{
|
|
2129
|
+
// Expect response to be the record we just created.
|
|
2130
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2131
|
+
//console.log(JSON.stringify(tmpResult, null, 4))
|
|
2132
|
+
Expect(tmpResult.Error).to.contain('authenticated');
|
|
2133
|
+
fDone();
|
|
2134
|
+
|
|
2135
|
+
}
|
|
2136
|
+
);
|
|
2137
|
+
}
|
|
2138
|
+
);
|
|
2139
|
+
test
|
|
2140
|
+
(
|
|
2141
|
+
'count: get the count of records',
|
|
2142
|
+
function(fDone)
|
|
2143
|
+
{
|
|
2144
|
+
libSuperTest('http://localhost:9080/')
|
|
2145
|
+
.get('1.0/FableTests/Count')
|
|
2146
|
+
.end(
|
|
2147
|
+
function (pError, pResponse)
|
|
2148
|
+
{
|
|
2149
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2150
|
+
Expect(tmpResult.Error).to.contain('authenticated');
|
|
2151
|
+
fDone();
|
|
2152
|
+
}
|
|
2153
|
+
);
|
|
2154
|
+
}
|
|
2155
|
+
);
|
|
2156
|
+
test
|
|
2157
|
+
(
|
|
2158
|
+
'delete: delete a record',
|
|
2159
|
+
function(fDone)
|
|
2160
|
+
{
|
|
2161
|
+
// Delete animal 3 ("Red")
|
|
2162
|
+
var tmpRecord = {IDAnimal:3};
|
|
2163
|
+
libSuperTest('http://localhost:9080/')
|
|
2164
|
+
.del('1.0/FableTest')
|
|
2165
|
+
.send(tmpRecord)
|
|
2166
|
+
.end(
|
|
2167
|
+
function(pError, pResponse)
|
|
2168
|
+
{
|
|
2169
|
+
// Expect response to be the count of deleted records.
|
|
2170
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2171
|
+
Expect(tmpResult.Error).to.contain('authenticated');
|
|
2172
|
+
_MockSessionValidUser.UserID = 10;
|
|
2173
|
+
fDone();
|
|
2174
|
+
}
|
|
2175
|
+
);
|
|
2176
|
+
}
|
|
2177
|
+
);
|
|
2178
|
+
}
|
|
2179
|
+
);
|
|
2180
|
+
suite
|
|
2181
|
+
(
|
|
2182
|
+
'Not logged in server routes',
|
|
2183
|
+
function()
|
|
2184
|
+
{
|
|
2185
|
+
test
|
|
2186
|
+
(
|
|
2187
|
+
'read: get a specific record',
|
|
2188
|
+
function(fDone)
|
|
2189
|
+
{
|
|
2190
|
+
_MockSessionValidUser.LoggedIn = false;
|
|
2191
|
+
libSuperTest('http://localhost:9080/')
|
|
2192
|
+
.get('1.0/FableTest/2')
|
|
2193
|
+
.end(
|
|
2194
|
+
function (pError, pResponse)
|
|
2195
|
+
{
|
|
2196
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2197
|
+
Expect(tmpResult.Error).to.contain('You must be authenticated');
|
|
2198
|
+
_MockSessionValidUser.LoggedIn = true;
|
|
2199
|
+
fDone();
|
|
2200
|
+
}
|
|
2201
|
+
);
|
|
2202
|
+
}
|
|
2203
|
+
);
|
|
2204
|
+
}
|
|
2205
|
+
);
|
|
2206
|
+
suite
|
|
2207
|
+
(
|
|
2208
|
+
'Filter parser',
|
|
2209
|
+
function()
|
|
2210
|
+
{
|
|
2211
|
+
test
|
|
2212
|
+
(
|
|
2213
|
+
'Filter parse',
|
|
2214
|
+
function(fDone)
|
|
2215
|
+
{
|
|
2216
|
+
var tmpQuery = _MeadowEndpoints.DAL.query;
|
|
2217
|
+
_MeadowEndpoints.parseFilter('FBV~UUIDAnimal~EQ~1000000', tmpQuery);
|
|
2218
|
+
Expect(tmpQuery.parameters.filter[0].Column).to.equal('UUIDAnimal');
|
|
2219
|
+
fDone();
|
|
2220
|
+
}
|
|
2221
|
+
);
|
|
2222
|
+
}
|
|
2223
|
+
);
|
|
2224
|
+
suite
|
|
2225
|
+
(
|
|
2226
|
+
'Changing route requirement',
|
|
2227
|
+
function()
|
|
2228
|
+
{
|
|
2229
|
+
test
|
|
2230
|
+
(
|
|
2231
|
+
'read: get a specific record',
|
|
2232
|
+
function(fDone)
|
|
2233
|
+
{
|
|
2234
|
+
Expect(_MeadowEndpoints.endpointAuthorizationLevels.Read).to.equal(0);
|
|
2235
|
+
fDone();
|
|
2236
|
+
}
|
|
2237
|
+
);
|
|
2238
|
+
}
|
|
2239
|
+
);
|
|
2240
|
+
suite
|
|
2241
|
+
(
|
|
2242
|
+
'Behavior modifications',
|
|
2243
|
+
function()
|
|
2244
|
+
{
|
|
2245
|
+
test
|
|
2246
|
+
(
|
|
2247
|
+
'read: modified get of a specific record',
|
|
2248
|
+
function(fDone)
|
|
2249
|
+
{
|
|
2250
|
+
// Override the query configuration
|
|
2251
|
+
_MeadowEndpoints.behaviorModifications.setBehavior('Read-QueryConfiguration', [
|
|
2252
|
+
function(pRequest, fComplete)
|
|
2253
|
+
{
|
|
2254
|
+
//implicitly test behvaior-cascade
|
|
2255
|
+
return fComplete(false);
|
|
2256
|
+
},
|
|
2257
|
+
function(pRequest, fComplete)
|
|
2258
|
+
{
|
|
2259
|
+
// Turn up logging on the request.
|
|
2260
|
+
pRequest.Query.setLogLevel(5);
|
|
2261
|
+
fComplete(false);
|
|
2262
|
+
} ]);
|
|
2263
|
+
libSuperTest('http://localhost:9080/')
|
|
2264
|
+
.get('1.0/FableTest/2')
|
|
2265
|
+
.end(
|
|
2266
|
+
function (pError, pResponse)
|
|
2267
|
+
{
|
|
2268
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2269
|
+
//console.log(JSON.stringify(tmpResult, null, 4))
|
|
2270
|
+
Expect(tmpResult.Name).to.equal('Red Riding Hood');
|
|
2271
|
+
fDone();
|
|
2272
|
+
}
|
|
2273
|
+
);
|
|
2274
|
+
}
|
|
2275
|
+
);
|
|
2276
|
+
test
|
|
2277
|
+
(
|
|
2278
|
+
'read: inject data into the record',
|
|
2279
|
+
function(fDone)
|
|
2280
|
+
{
|
|
2281
|
+
// Override the query configuration
|
|
2282
|
+
_MeadowEndpoints.behaviorModifications.setBehavior('Read-PostOperation',
|
|
2283
|
+
function(pRequest, fComplete)
|
|
2284
|
+
{
|
|
2285
|
+
// Create a custom property on the record.
|
|
2286
|
+
pRequest.Record.CustomProperty = 'Custom '+pRequest.Record.Type+' ID '+pRequest.Record.IDAnimal;
|
|
2287
|
+
fComplete(false);
|
|
2288
|
+
});
|
|
2289
|
+
_MockSessionValidUser.LoggedIn = true;
|
|
2290
|
+
libSuperTest('http://localhost:9080/')
|
|
2291
|
+
.get('1.0/FableTest/2')
|
|
2292
|
+
.end(
|
|
2293
|
+
function (pError, pResponse)
|
|
2294
|
+
{
|
|
2295
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2296
|
+
//console.log(JSON.stringify(tmpResult, null, 4))
|
|
2297
|
+
Expect(tmpResult.CustomProperty).to.equal('Custom Girl ID 2');
|
|
2298
|
+
fDone();
|
|
2299
|
+
}
|
|
2300
|
+
);
|
|
2301
|
+
}
|
|
2302
|
+
);
|
|
2303
|
+
test
|
|
2304
|
+
(
|
|
2305
|
+
'read-max: get the max record ID',
|
|
2306
|
+
function(fDone)
|
|
2307
|
+
{
|
|
2308
|
+
libSuperTest('http://localhost:9080/')
|
|
2309
|
+
.get('1.0/FableTest/Max/IDAnimal')
|
|
2310
|
+
.end(
|
|
2311
|
+
function (pError, pResponse)
|
|
2312
|
+
{
|
|
2313
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2314
|
+
Expect(tmpResult.IDAnimal).to.equal(6);
|
|
2315
|
+
fDone();
|
|
2316
|
+
}
|
|
2317
|
+
);
|
|
2318
|
+
}
|
|
2319
|
+
);
|
|
2320
|
+
test
|
|
2321
|
+
(
|
|
2322
|
+
'read-max: get the max name',
|
|
2323
|
+
function(fDone)
|
|
2324
|
+
{
|
|
2325
|
+
libSuperTest('http://localhost:9080/')
|
|
2326
|
+
.get('1.0/FableTest/Max/Name')
|
|
2327
|
+
.end(
|
|
2328
|
+
function (pError, pResponse)
|
|
2329
|
+
{
|
|
2330
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2331
|
+
Expect(tmpResult.Name).to.equal('Spot');
|
|
2332
|
+
fDone();
|
|
2333
|
+
}
|
|
2334
|
+
);
|
|
2335
|
+
}
|
|
2336
|
+
);
|
|
2337
|
+
}
|
|
2338
|
+
);
|
|
2339
|
+
suite
|
|
2340
|
+
(
|
|
2341
|
+
'Direct invocation',
|
|
2342
|
+
function()
|
|
2343
|
+
{
|
|
2344
|
+
var tmpCreatedRecordGUID;
|
|
2345
|
+
|
|
2346
|
+
test
|
|
2347
|
+
(
|
|
2348
|
+
'invoke: setup method is called',
|
|
2349
|
+
function(fDone)
|
|
2350
|
+
{
|
|
2351
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
2352
|
+
let setupCallCount = 0;
|
|
2353
|
+
let passedRequest, passedResponse, passedOriginalRequest;
|
|
2354
|
+
_MeadowEndpoints.setInvokeSetupCallback((req, res, origReq) =>
|
|
2355
|
+
{
|
|
2356
|
+
++setupCallCount;
|
|
2357
|
+
passedRequest = req;
|
|
2358
|
+
passedResponse = res;
|
|
2359
|
+
passedOriginalRequest = origReq;
|
|
2360
|
+
});
|
|
2361
|
+
const originalRequest = {UserSession: _MockSessionValidUser};
|
|
2362
|
+
_MeadowEndpoints.invokeEndpoint('Read', {IDRecord: 2}, originalRequest,
|
|
2363
|
+
function(pError, pResponse)
|
|
2364
|
+
{
|
|
2365
|
+
Expect(setupCallCount).to.equal(1);
|
|
2366
|
+
Expect(passedOriginalRequest).to.equal(originalRequest);
|
|
2367
|
+
Expect(passedRequest).to.be.an('object');
|
|
2368
|
+
Expect(passedResponse).to.be.an('object');
|
|
2369
|
+
|
|
2370
|
+
fDone();
|
|
2371
|
+
}
|
|
2372
|
+
);
|
|
2373
|
+
}
|
|
2374
|
+
);
|
|
2375
|
+
test
|
|
2376
|
+
(
|
|
2377
|
+
'invoke create: create a record',
|
|
2378
|
+
function(fDone)
|
|
2379
|
+
{
|
|
2380
|
+
var tmpRecord = {Name:'BatBrains', Type:'Mammoth'};
|
|
2381
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
2382
|
+
_MeadowEndpoints.invokeEndpoint('Create', tmpRecord, {UserSession: _MockSessionValidUser},
|
|
2383
|
+
function(pError, pResponse)
|
|
2384
|
+
{
|
|
2385
|
+
// Expect response to be the record we just created.
|
|
2386
|
+
Expect(pResponse.body.Name)
|
|
2387
|
+
.to.equal(tmpRecord.Name);
|
|
2388
|
+
|
|
2389
|
+
tmpCreatedRecordGUID = pResponse.body.GUIDAnimal;
|
|
2390
|
+
|
|
2391
|
+
fDone();
|
|
2392
|
+
}
|
|
2393
|
+
);
|
|
2394
|
+
}
|
|
2395
|
+
);
|
|
2396
|
+
test
|
|
2397
|
+
(
|
|
2398
|
+
'invoke create: create a record with a bad record passed in',
|
|
2399
|
+
function(fDone)
|
|
2400
|
+
{
|
|
2401
|
+
var tmpRecord = ' ';
|
|
2402
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
2403
|
+
_MeadowEndpoints.invokeEndpoint('Create', tmpRecord,
|
|
2404
|
+
function(pError, pResponse)
|
|
2405
|
+
{
|
|
2406
|
+
// Expect response to be the record we just created.
|
|
2407
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2408
|
+
Expect(tmpResult.Error).to.contain('a valid record is required');
|
|
2409
|
+
fDone();
|
|
2410
|
+
}
|
|
2411
|
+
);
|
|
2412
|
+
}
|
|
2413
|
+
);
|
|
2414
|
+
test
|
|
2415
|
+
(
|
|
2416
|
+
'invoke read: get a specific record',
|
|
2417
|
+
function(fDone)
|
|
2418
|
+
{
|
|
2419
|
+
_MeadowEndpoints.invokeEndpoint('Read', {IDRecord: 2}, {UserSession: _MockSessionValidUser},
|
|
2420
|
+
function (pError, pResponse)
|
|
2421
|
+
{
|
|
2422
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2423
|
+
Expect(tmpResult.Type).to.equal('Girl');
|
|
2424
|
+
fDone();
|
|
2425
|
+
}
|
|
2426
|
+
);
|
|
2427
|
+
}
|
|
2428
|
+
);
|
|
2429
|
+
test
|
|
2430
|
+
(
|
|
2431
|
+
'invoke read: get a specific record by GUID',
|
|
2432
|
+
function(fDone)
|
|
2433
|
+
{
|
|
2434
|
+
_MeadowEndpoints.invokeEndpoint('Read', {GUIDRecord: tmpCreatedRecordGUID}, {UserSession: _MockSessionValidUser},
|
|
2435
|
+
function (pError, pResponse)
|
|
2436
|
+
{
|
|
2437
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2438
|
+
Expect(tmpResult.Type).to.equal('Mammoth');
|
|
2439
|
+
fDone();
|
|
2440
|
+
}
|
|
2441
|
+
);
|
|
2442
|
+
}
|
|
2443
|
+
);
|
|
2444
|
+
test
|
|
2445
|
+
(
|
|
2446
|
+
'read: get a specific record with a bad parameter',
|
|
2447
|
+
function(fDone)
|
|
2448
|
+
{
|
|
2449
|
+
_MeadowEndpoints.invokeEndpoint('Read', {},
|
|
2450
|
+
function (pError, pResponse)
|
|
2451
|
+
{
|
|
2452
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2453
|
+
//console.log(tmpResult);
|
|
2454
|
+
Expect(tmpResult.Error).to.be.an('undefined'); //
|
|
2455
|
+
fDone();
|
|
2456
|
+
}
|
|
2457
|
+
);
|
|
2458
|
+
}
|
|
2459
|
+
);
|
|
2460
|
+
test
|
|
2461
|
+
(
|
|
2462
|
+
'invoke readselect: get all records',
|
|
2463
|
+
function(fDone)
|
|
2464
|
+
{
|
|
2465
|
+
_MeadowEndpoints.invokeEndpoint('ReadSelectList', {}, {UserSession: _MockSessionValidUser},
|
|
2466
|
+
function (pError, pResponse)
|
|
2467
|
+
{
|
|
2468
|
+
console.log(pResponse.body)
|
|
2469
|
+
Expect(pResponse.body)
|
|
2470
|
+
.to.be.an('array');
|
|
2471
|
+
//var tmpResults = JSON.parse(pResponse.text);
|
|
2472
|
+
//Expect(tmpResults.Error).to.contain('authenticated');
|
|
2473
|
+
fDone();
|
|
2474
|
+
}
|
|
2475
|
+
);
|
|
2476
|
+
}
|
|
2477
|
+
);
|
|
2478
|
+
test
|
|
2479
|
+
(
|
|
2480
|
+
'invoke readsby: get all records by Type',
|
|
2481
|
+
function(fDone)
|
|
2482
|
+
{
|
|
2483
|
+
_MeadowEndpoints.invokeEndpoint('ReadsBy', {ByField: 'Type', ByValue: 'Mammoth'}, {UserSession: _MockSessionValidUser},
|
|
2484
|
+
function (pError, pResponse)
|
|
2485
|
+
{
|
|
2486
|
+
//console.log(pResponse.body);
|
|
2487
|
+
|
|
2488
|
+
var tmpResults = pResponse.body; //JSON.parse(pResponse.text);
|
|
2489
|
+
Expect(tmpResults.length).to.equal(2);
|
|
2490
|
+
Expect(tmpResults[0].Type).to.equal('Mammoth');
|
|
2491
|
+
fDone();
|
|
2492
|
+
}
|
|
2493
|
+
);
|
|
2494
|
+
}
|
|
2495
|
+
);
|
|
2496
|
+
test
|
|
2497
|
+
(
|
|
2498
|
+
'invoke readsby: get all records by Type IN LIST',
|
|
2499
|
+
function(fDone)
|
|
2500
|
+
{
|
|
2501
|
+
_MeadowEndpoints.invokeEndpoint('ReadsBy', {ByField: 'Type', ByValue: ['Mammoth', 'Dog']}, {UserSession: _MockSessionValidUser},
|
|
2502
|
+
function (pError, pResponse)
|
|
2503
|
+
{
|
|
2504
|
+
//console.log(pResponse.body);
|
|
2505
|
+
|
|
2506
|
+
var tmpResults = pResponse.body; //JSON.parse(pResponse.text);
|
|
2507
|
+
Expect(tmpResults.length).to.equal(2);
|
|
2508
|
+
Expect(tmpResults[0].Type).to.equal('Mammoth');
|
|
2509
|
+
fDone();
|
|
2510
|
+
}
|
|
2511
|
+
);
|
|
2512
|
+
}
|
|
2513
|
+
);
|
|
2514
|
+
test
|
|
2515
|
+
(
|
|
2516
|
+
'invoke readsby: get all records by Type AND Name',
|
|
2517
|
+
function(fDone)
|
|
2518
|
+
{
|
|
2519
|
+
_MeadowEndpoints.invokeEndpoint('ReadsBy', {Filters: [
|
|
2520
|
+
{ByField: 'Type', ByValue: 'Mammoth'},
|
|
2521
|
+
{ByField: 'Name', ByValue: 'BatBrains'}
|
|
2522
|
+
]}, {UserSession: _MockSessionValidUser},
|
|
2523
|
+
function (pError, pResponse)
|
|
2524
|
+
{
|
|
2525
|
+
//console.log(pResponse.body);
|
|
2526
|
+
|
|
2527
|
+
var tmpResults = pResponse.body; //JSON.parse(pResponse.text);
|
|
2528
|
+
Expect(tmpResults.length).to.equal(2);
|
|
2529
|
+
Expect(tmpResults[0].Type).to.equal('Mammoth');
|
|
2530
|
+
fDone();
|
|
2531
|
+
}
|
|
2532
|
+
);
|
|
2533
|
+
}
|
|
2534
|
+
);
|
|
2535
|
+
test
|
|
2536
|
+
(
|
|
2537
|
+
'invoke countby: get cout of records by Type',
|
|
2538
|
+
function(fDone)
|
|
2539
|
+
{
|
|
2540
|
+
_MeadowEndpoints.invokeEndpoint('CountBy', {ByField: 'Type', ByValue: 'Mammoth'}, {UserSession: _MockSessionValidUser},
|
|
2541
|
+
function (pError, pResponse)
|
|
2542
|
+
{
|
|
2543
|
+
var tmpResults = pResponse.body; //JSON.parse(pResponse.text);
|
|
2544
|
+
Expect(tmpResults.Count).to.equal(2);
|
|
2545
|
+
fDone();
|
|
2546
|
+
}
|
|
2547
|
+
);
|
|
2548
|
+
}
|
|
2549
|
+
);
|
|
2550
|
+
test
|
|
2551
|
+
(
|
|
2552
|
+
'invoke readsby: get paged records by Type',
|
|
2553
|
+
function(fDone)
|
|
2554
|
+
{
|
|
2555
|
+
_MeadowEndpoints.invokeEndpoint('ReadsBy', {ByField: 'Type', ByValue: 'Mammoth', Begin: 1, Cap: 1}, {UserSession: _MockSessionValidUser},
|
|
2556
|
+
function (pError, pResponse)
|
|
2557
|
+
{
|
|
2558
|
+
var tmpResults = pResponse.body;
|
|
2559
|
+
Expect(tmpResults.length).to.equal(1);
|
|
2560
|
+
Expect(tmpResults[0].Type).to.equal('Mammoth');
|
|
2561
|
+
fDone();
|
|
2562
|
+
}
|
|
2563
|
+
);
|
|
2564
|
+
}
|
|
2565
|
+
);
|
|
2566
|
+
test
|
|
2567
|
+
(
|
|
2568
|
+
'invoke readselect: get a page of records',
|
|
2569
|
+
function(fDone)
|
|
2570
|
+
{
|
|
2571
|
+
_MeadowEndpoints.invokeEndpoint('ReadSelectList', {Begin: 2, Cap: 2}, {UserSession: _MockSessionValidUser},
|
|
2572
|
+
function (pError, pResponse)
|
|
2573
|
+
{
|
|
2574
|
+
var tmpResults = pResponse.Records; //JSON.parse(pResponse.text);
|
|
2575
|
+
Expect(tmpResults.length).to.equal(2);
|
|
2576
|
+
Expect(tmpResults[1].Value).to.equal('FableTest #5');
|
|
2577
|
+
fDone();
|
|
2578
|
+
}
|
|
2579
|
+
);
|
|
2580
|
+
}
|
|
2581
|
+
);
|
|
2582
|
+
test
|
|
2583
|
+
(
|
|
2584
|
+
'invoke readselect: get an empty page of records',
|
|
2585
|
+
function(fDone)
|
|
2586
|
+
{
|
|
2587
|
+
_MeadowEndpoints.invokeEndpoint('ReadSelectList', {Begin: 200, Cap: 200}, {UserSession: _MockSessionValidUser},
|
|
2588
|
+
function (pError, pResponse)
|
|
2589
|
+
{
|
|
2590
|
+
var tmpResults = pResponse.Records; //JSON.parse(pResponse.text);
|
|
2591
|
+
Expect(tmpResults.length).to.equal(0);
|
|
2592
|
+
fDone();
|
|
2593
|
+
}
|
|
2594
|
+
);
|
|
2595
|
+
}
|
|
2596
|
+
);
|
|
2597
|
+
test
|
|
2598
|
+
(
|
|
2599
|
+
'invoke reads: get a page of records',
|
|
2600
|
+
function(fDone)
|
|
2601
|
+
{
|
|
2602
|
+
_MeadowEndpoints.invokeEndpoint('Reads', {Begin: 2, Cap: 2}, {UserSession: _MockSessionValidUser},
|
|
2603
|
+
function (pError, pResponse)
|
|
2604
|
+
{
|
|
2605
|
+
var tmpResults = pResponse.Records; //JSON.parse(pResponse.text);
|
|
2606
|
+
Expect(tmpResults.length).to.equal(2);
|
|
2607
|
+
Expect(tmpResults[0].Type).to.equal('Corgi');
|
|
2608
|
+
Expect(tmpResults[1].Name).to.equal('Gertrude');
|
|
2609
|
+
fDone();
|
|
2610
|
+
}
|
|
2611
|
+
);
|
|
2612
|
+
}
|
|
2613
|
+
);
|
|
2614
|
+
test
|
|
2615
|
+
(
|
|
2616
|
+
'invoke update: update a record',
|
|
2617
|
+
function(fDone)
|
|
2618
|
+
{
|
|
2619
|
+
// Change animal 4 ("Spot") to a Corgi
|
|
2620
|
+
var tmpRecord = {IDAnimal:4, Type:'Corgi'};
|
|
2621
|
+
_MeadowEndpoints.invokeEndpoint('Update', tmpRecord, {UserSession: _MockSessionValidUser},
|
|
2622
|
+
function(pError, pResponse)
|
|
2623
|
+
{
|
|
2624
|
+
// Expect response to be the record we just created.
|
|
2625
|
+
var tmpResult = pResponse.Record; //JSON.parse(pResponse.text);
|
|
2626
|
+
Expect(tmpResult.Type).to.equal('Corgi');
|
|
2627
|
+
Expect(tmpResult.CreatingIDUser).to.equal(1);
|
|
2628
|
+
Expect(tmpResult.UpdatingIDUser).to.equal(_MockSessionValidUser.UserID);
|
|
2629
|
+
fDone();
|
|
2630
|
+
}
|
|
2631
|
+
);
|
|
2632
|
+
}
|
|
2633
|
+
);
|
|
2634
|
+
test
|
|
2635
|
+
(
|
|
2636
|
+
'invoke delete: delete a record',
|
|
2637
|
+
function(fDone)
|
|
2638
|
+
{
|
|
2639
|
+
// Delete animal 4 ("Corgi")
|
|
2640
|
+
var tmpRecord = {IDAnimal:4};
|
|
2641
|
+
|
|
2642
|
+
// Override the query configuration
|
|
2643
|
+
_MeadowEndpoints.behaviorModifications.setBehavior('Delete-PreOperation',
|
|
2644
|
+
function(pRequest, fComplete)
|
|
2645
|
+
{
|
|
2646
|
+
// Create a custom property on the record.
|
|
2647
|
+
Expect(pRequest.Record.IDAnimal).to.equal(tmpRecord.IDAnimal);
|
|
2648
|
+
return fComplete(false);
|
|
2649
|
+
});
|
|
2650
|
+
|
|
2651
|
+
_MeadowEndpoints.invokeEndpoint('Delete', tmpRecord, {UserSession: _MockSessionValidUser},
|
|
2652
|
+
function(pError, pResponse)
|
|
2653
|
+
{
|
|
2654
|
+
//clear out the behavior mapping to not affect other tests
|
|
2655
|
+
_MeadowEndpoints.behaviorModifications.setBehavior('Delete-PreOperation', null);
|
|
2656
|
+
|
|
2657
|
+
// Expect response to be the count of deleted records.
|
|
2658
|
+
var tmpResult = pResponse.body; //JSON.parse(pResponse.text);
|
|
2659
|
+
Expect(tmpResult.Count).to.equal(1);
|
|
2660
|
+
return fDone();
|
|
2661
|
+
}
|
|
2662
|
+
);
|
|
2663
|
+
}
|
|
2664
|
+
);
|
|
2665
|
+
test
|
|
2666
|
+
(
|
|
2667
|
+
'invoke delete: delete a record with a bad parameter',
|
|
2668
|
+
function(fDone)
|
|
2669
|
+
{
|
|
2670
|
+
// Delete animal 3 ("Red")
|
|
2671
|
+
var tmpRecord = {IDAnimal:{MyStuff:4}};
|
|
2672
|
+
_MeadowEndpoints.invokeEndpoint('Delete', tmpRecord, {UserSession: _MockSessionValidUser},
|
|
2673
|
+
function(pError, pResponse)
|
|
2674
|
+
{
|
|
2675
|
+
// Expect response to be the count of deleted records.
|
|
2676
|
+
var tmpResult = pResponse.body; //JSON.parse(pResponse.text);
|
|
2677
|
+
Expect(tmpResult.Error).to.contain('a valid record ID is required');
|
|
2678
|
+
fDone();
|
|
2679
|
+
}
|
|
2680
|
+
);
|
|
2681
|
+
}
|
|
2682
|
+
);
|
|
2683
|
+
test
|
|
2684
|
+
(
|
|
2685
|
+
'count: get the count of records',
|
|
2686
|
+
function(fDone)
|
|
2687
|
+
{
|
|
2688
|
+
_MeadowEndpoints.invokeEndpoint('Count', {}, {UserSession: _MockSessionValidUser},
|
|
2689
|
+
function (pError, pResponse)
|
|
2690
|
+
{
|
|
2691
|
+
var tmpResults = pResponse.body; //JSON.parse(pResponse.text);
|
|
2692
|
+
Expect(tmpResults.Count).to.equal(5);
|
|
2693
|
+
fDone();
|
|
2694
|
+
}
|
|
2695
|
+
);
|
|
2696
|
+
}
|
|
2697
|
+
);
|
|
2698
|
+
test
|
|
2699
|
+
(
|
|
2700
|
+
'schema: get the schema of a record',
|
|
2701
|
+
function(fDone)
|
|
2702
|
+
{
|
|
2703
|
+
_MeadowEndpoints.invokeEndpoint('Schema', {},
|
|
2704
|
+
function (pError, pResponse)
|
|
2705
|
+
{
|
|
2706
|
+
var tmpResults = pResponse.body; //JSON.parse(pResponse.text);
|
|
2707
|
+
//console.log('SCHEMA --> '+JSON.stringify(tmpResults, null, 4))
|
|
2708
|
+
Expect(tmpResults.title).to.equal('Animal');
|
|
2709
|
+
Expect(tmpResults.description).to.contain('creature that lives in');
|
|
2710
|
+
fDone();
|
|
2711
|
+
}
|
|
2712
|
+
);
|
|
2713
|
+
}
|
|
2714
|
+
);
|
|
2715
|
+
test
|
|
2716
|
+
(
|
|
2717
|
+
'new: get a new empty record',
|
|
2718
|
+
function(fDone)
|
|
2719
|
+
{
|
|
2720
|
+
_MeadowEndpoints.invokeEndpoint('New', {}, {UserSession: _MockSessionValidUser},
|
|
2721
|
+
function (pError, pResponse)
|
|
2722
|
+
{
|
|
2723
|
+
var tmpResults = pResponse.body; //JSON.parse(pResponse.text);
|
|
2724
|
+
//console.log(JSON.stringify(tmpResults, null, 4))
|
|
2725
|
+
Expect(tmpResults.IDAnimal).to.equal(null);
|
|
2726
|
+
Expect(tmpResults.Name).to.equal('Unknown');
|
|
2727
|
+
Expect(tmpResults.Type).to.equal('Unclassified');
|
|
2728
|
+
fDone();
|
|
2729
|
+
}
|
|
2730
|
+
);
|
|
2731
|
+
}
|
|
2732
|
+
);
|
|
2733
|
+
test
|
|
2734
|
+
(
|
|
2735
|
+
'validate: validate an invalid record',
|
|
2736
|
+
function(fDone)
|
|
2737
|
+
{
|
|
2738
|
+
var tmpRecord = {IDAnimal:4, Type:'Corgi'};
|
|
2739
|
+
_MeadowEndpoints.invokeEndpoint('Validate', tmpRecord, {UserSession: _MockSessionValidUser},
|
|
2740
|
+
function(pError, pResponse)
|
|
2741
|
+
{
|
|
2742
|
+
// Expect response to be the record we just created.
|
|
2743
|
+
var tmpResult = pResponse.body; //JSON.parse(pResponse.text);
|
|
2744
|
+
//console.log(JSON.stringify(tmpResult, null, 4))
|
|
2745
|
+
Expect(tmpResult.Valid).to.equal(false);
|
|
2746
|
+
Expect(tmpResult.Errors[0].field).to.equal('data.Name');
|
|
2747
|
+
Expect(tmpResult.Errors[0].message).to.equal('is required');
|
|
2748
|
+
fDone();
|
|
2749
|
+
}
|
|
2750
|
+
);
|
|
2751
|
+
}
|
|
2752
|
+
);
|
|
2753
|
+
test
|
|
2754
|
+
(
|
|
2755
|
+
'validate: validate a valid record',
|
|
2756
|
+
function(fDone)
|
|
2757
|
+
{
|
|
2758
|
+
var tmpRecord = {IDAnimal:4, Type:'Corgi', Name:'Doofer', CreatingIDUser:10};
|
|
2759
|
+
_MeadowEndpoints.invokeEndpoint('Validate', tmpRecord, {UserSession: _MockSessionValidUser},
|
|
2760
|
+
function(pError, pResponse)
|
|
2761
|
+
{
|
|
2762
|
+
// Expect response to be the record we just created.
|
|
2763
|
+
var tmpResult = pResponse.body; //JSON.parse(pResponse.text);
|
|
2764
|
+
//console.log(JSON.stringify(tmpResult, null, 4))
|
|
2765
|
+
Expect(tmpResult.Valid).to.equal(true);
|
|
2766
|
+
fDone();
|
|
2767
|
+
}
|
|
2768
|
+
);
|
|
2769
|
+
}
|
|
2770
|
+
);
|
|
2771
|
+
test
|
|
2772
|
+
(
|
|
2773
|
+
'validate: validate bad data',
|
|
2774
|
+
function(fDone)
|
|
2775
|
+
{
|
|
2776
|
+
var tmpRecord = 'IAMBAD';
|
|
2777
|
+
_MeadowEndpoints.invokeEndpoint('Validate', tmpRecord, {UserSession: _MockSessionValidUser},
|
|
2778
|
+
function(pError, pResponse)
|
|
2779
|
+
{
|
|
2780
|
+
// Expect response to be the record we just created.
|
|
2781
|
+
var tmpResult = pResponse.body; //JSON.parse(pResponse.text);
|
|
2782
|
+
//console.log(JSON.stringify(tmpResult, null, 4))
|
|
2783
|
+
Expect(tmpResult.Error).to.contain('validate failure');
|
|
2784
|
+
fDone();
|
|
2785
|
+
}
|
|
2786
|
+
);
|
|
2787
|
+
}
|
|
2788
|
+
);
|
|
2789
|
+
}
|
|
2790
|
+
);
|
|
2791
|
+
|
|
2792
|
+
suite
|
|
2793
|
+
(
|
|
2794
|
+
'Endpoint Security - Deny',
|
|
2795
|
+
function()
|
|
2796
|
+
{
|
|
2797
|
+
test
|
|
2798
|
+
(
|
|
2799
|
+
'invoke read: get a specific record',
|
|
2800
|
+
function(fDone)
|
|
2801
|
+
{
|
|
2802
|
+
_MockSessionValidUser.LoggedIn = true;
|
|
2803
|
+
_MockSessionValidUser.UserRoleIndex = 5; //set it to an undefined role, so the DefaultAPISecurity definitions of 'Deny' get used.
|
|
2804
|
+
|
|
2805
|
+
_MeadowEndpoints.invokeEndpoint('Read', {IDRecord: 2}, {UserSession: _MockSessionValidUser},
|
|
2806
|
+
function (pError, pResponse)
|
|
2807
|
+
{
|
|
2808
|
+
Expect(pResponse.body.ErrorCode).to.equal(405);
|
|
2809
|
+
Expect(pResponse.body.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
2810
|
+
return fDone();
|
|
2811
|
+
}
|
|
2812
|
+
);
|
|
2813
|
+
}
|
|
2814
|
+
);
|
|
2815
|
+
test
|
|
2816
|
+
(
|
|
2817
|
+
'invoke create: create a record',
|
|
2818
|
+
function(fDone)
|
|
2819
|
+
{
|
|
2820
|
+
var tmpRecord = {Name:'BatBrains', Type:'Mammoth'};
|
|
2821
|
+
_MeadowEndpoints.invokeEndpoint('Create', tmpRecord, {UserSession: _MockSessionValidUser},
|
|
2822
|
+
function(pError, pResponse)
|
|
2823
|
+
{
|
|
2824
|
+
Expect(pResponse.body.ErrorCode).to.equal(405);
|
|
2825
|
+
Expect(pResponse.body.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
2826
|
+
|
|
2827
|
+
return fDone();
|
|
2828
|
+
}
|
|
2829
|
+
);
|
|
2830
|
+
}
|
|
2831
|
+
);
|
|
2832
|
+
test
|
|
2833
|
+
(
|
|
2834
|
+
'invoke create: create a record with a bad record passed in',
|
|
2835
|
+
function(fDone)
|
|
2836
|
+
{
|
|
2837
|
+
var tmpRecord = ' ';
|
|
2838
|
+
_MeadowEndpoints.invokeEndpoint('Create', tmpRecord, {UserSession: _MockSessionValidUser},
|
|
2839
|
+
function(pError, pResponse)
|
|
2840
|
+
{
|
|
2841
|
+
// Expect response to be the record we just created.
|
|
2842
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
2843
|
+
Expect(tmpResult.Error).to.contain('a valid record is required');
|
|
2844
|
+
fDone();
|
|
2845
|
+
}
|
|
2846
|
+
);
|
|
2847
|
+
}
|
|
2848
|
+
);
|
|
2849
|
+
test
|
|
2850
|
+
(
|
|
2851
|
+
'invoke readselect: get all records',
|
|
2852
|
+
function(fDone)
|
|
2853
|
+
{
|
|
2854
|
+
_MeadowEndpoints.invokeEndpoint('ReadSelectList', {}, {UserSession: _MockSessionValidUser},
|
|
2855
|
+
function (pError, pResponse)
|
|
2856
|
+
{
|
|
2857
|
+
Expect(pResponse.body.ErrorCode).to.equal(405);
|
|
2858
|
+
Expect(pResponse.body.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
2859
|
+
|
|
2860
|
+
fDone();
|
|
2861
|
+
}
|
|
2862
|
+
);
|
|
2863
|
+
}
|
|
2864
|
+
);
|
|
2865
|
+
test
|
|
2866
|
+
(
|
|
2867
|
+
'invoke readsby: get all records by Type',
|
|
2868
|
+
function(fDone)
|
|
2869
|
+
{
|
|
2870
|
+
_MeadowEndpoints.invokeEndpoint('ReadsBy', {ByField: 'Type', ByValue: 'Mammoth'}, {UserSession: _MockSessionValidUser},
|
|
2871
|
+
function (pError, pResponse)
|
|
2872
|
+
{
|
|
2873
|
+
Expect(pResponse.body.ErrorCode).to.equal(405);
|
|
2874
|
+
Expect(pResponse.body.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
2875
|
+
fDone();
|
|
2876
|
+
}
|
|
2877
|
+
);
|
|
2878
|
+
}
|
|
2879
|
+
);
|
|
2880
|
+
test
|
|
2881
|
+
(
|
|
2882
|
+
'invoke readsby: get all records by Type IN LIST',
|
|
2883
|
+
function(fDone)
|
|
2884
|
+
{
|
|
2885
|
+
_MeadowEndpoints.invokeEndpoint('ReadsBy', {ByField: 'Type', ByValue: ['Mammoth', 'Dog']}, {UserSession: _MockSessionValidUser},
|
|
2886
|
+
function (pError, pResponse)
|
|
2887
|
+
{
|
|
2888
|
+
Expect(pResponse.body.ErrorCode).to.equal(405);
|
|
2889
|
+
Expect(pResponse.body.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
2890
|
+
fDone();
|
|
2891
|
+
}
|
|
2892
|
+
);
|
|
2893
|
+
}
|
|
2894
|
+
);
|
|
2895
|
+
test
|
|
2896
|
+
(
|
|
2897
|
+
'invoke countby: get cout of records by Type',
|
|
2898
|
+
function(fDone)
|
|
2899
|
+
{
|
|
2900
|
+
_MeadowEndpoints.invokeEndpoint('CountBy', {ByField: 'Type', ByValue: 'Mammoth'}, {UserSession: _MockSessionValidUser},
|
|
2901
|
+
function (pError, pResponse)
|
|
2902
|
+
{
|
|
2903
|
+
Expect(pResponse.body.ErrorCode).to.equal(405);
|
|
2904
|
+
Expect(pResponse.body.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
2905
|
+
fDone();
|
|
2906
|
+
}
|
|
2907
|
+
);
|
|
2908
|
+
}
|
|
2909
|
+
);
|
|
2910
|
+
test
|
|
2911
|
+
(
|
|
2912
|
+
'invoke countby: get cout of records by Type',
|
|
2913
|
+
function(fDone)
|
|
2914
|
+
{
|
|
2915
|
+
_MeadowEndpoints.invokeEndpoint('Count', {}, {UserSession: _MockSessionValidUser},
|
|
2916
|
+
function (pError, pResponse)
|
|
2917
|
+
{
|
|
2918
|
+
Expect(pResponse.body.ErrorCode).to.equal(405);
|
|
2919
|
+
Expect(pResponse.body.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
2920
|
+
fDone();
|
|
2921
|
+
}
|
|
2922
|
+
);
|
|
2923
|
+
}
|
|
2924
|
+
);
|
|
2925
|
+
test
|
|
2926
|
+
(
|
|
2927
|
+
'invoke readselect: get a page of records',
|
|
2928
|
+
function(fDone)
|
|
2929
|
+
{
|
|
2930
|
+
_MeadowEndpoints.invokeEndpoint('ReadSelectList', {Begin: 2, Cap: 2}, {UserSession: _MockSessionValidUser},
|
|
2931
|
+
function (pError, pResponse)
|
|
2932
|
+
{
|
|
2933
|
+
Expect(pResponse.body.ErrorCode).to.equal(405);
|
|
2934
|
+
Expect(pResponse.body.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
2935
|
+
fDone();
|
|
2936
|
+
}
|
|
2937
|
+
);
|
|
2938
|
+
}
|
|
2939
|
+
);
|
|
2940
|
+
test
|
|
2941
|
+
(
|
|
2942
|
+
'invoke readselect: get an empty page of records',
|
|
2943
|
+
function(fDone)
|
|
2944
|
+
{
|
|
2945
|
+
_MeadowEndpoints.invokeEndpoint('ReadSelectList', {Begin: 200, Cap: 200}, {UserSession: _MockSessionValidUser},
|
|
2946
|
+
function (pError, pResponse)
|
|
2947
|
+
{
|
|
2948
|
+
// Because no records were returned, it should show as Authorized
|
|
2949
|
+
|
|
2950
|
+
var tmpResults = pResponse.Records; //JSON.parse(pResponse.text);
|
|
2951
|
+
Expect(tmpResults.length).to.equal(0);
|
|
2952
|
+
fDone();
|
|
2953
|
+
}
|
|
2954
|
+
);
|
|
2955
|
+
}
|
|
2956
|
+
);
|
|
2957
|
+
test
|
|
2958
|
+
(
|
|
2959
|
+
'invoke reads: get a page of records',
|
|
2960
|
+
function(fDone)
|
|
2961
|
+
{
|
|
2962
|
+
_MeadowEndpoints.invokeEndpoint('Reads', {Begin: 2, Cap: 2}, {UserSession: _MockSessionValidUser},
|
|
2963
|
+
function (pError, pResponse)
|
|
2964
|
+
{
|
|
2965
|
+
Expect(pResponse.body.ErrorCode).to.equal(405);
|
|
2966
|
+
Expect(pResponse.body.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
2967
|
+
|
|
2968
|
+
fDone();
|
|
2969
|
+
}
|
|
2970
|
+
);
|
|
2971
|
+
}
|
|
2972
|
+
);
|
|
2973
|
+
test
|
|
2974
|
+
(
|
|
2975
|
+
'invoke update: update a record',
|
|
2976
|
+
function(fDone)
|
|
2977
|
+
{
|
|
2978
|
+
// Change animal 1
|
|
2979
|
+
var tmpRecord = {IDAnimal:1, Type:'Corgi'};
|
|
2980
|
+
_MeadowEndpoints.invokeEndpoint('Update', tmpRecord, {UserSession: _MockSessionValidUser},
|
|
2981
|
+
function(pError, pResponse)
|
|
2982
|
+
{
|
|
2983
|
+
Expect(pResponse.body.ErrorCode).to.equal(405);
|
|
2984
|
+
Expect(pResponse.body.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
2985
|
+
|
|
2986
|
+
fDone();
|
|
2987
|
+
}
|
|
2988
|
+
);
|
|
2989
|
+
}
|
|
2990
|
+
);
|
|
2991
|
+
test
|
|
2992
|
+
(
|
|
2993
|
+
'invoke update: update a record, override security to authorize the request',
|
|
2994
|
+
function(fDone)
|
|
2995
|
+
{
|
|
2996
|
+
// Change animal 1
|
|
2997
|
+
var tmpRecord = {IDAnimal:1, Type:'Corgi'};
|
|
2998
|
+
_MeadowEndpoints.invokeEndpoint('Update', tmpRecord, {UserSession: _MockSessionValidUser, Satchel: {AuthorizeOverride: true}},
|
|
2999
|
+
function(pError, pResponse)
|
|
3000
|
+
{
|
|
3001
|
+
// Expect response to be the record we just updated.
|
|
3002
|
+
var tmpResult = pResponse.Record; //JSON.parse(pResponse.text);
|
|
3003
|
+
Expect(tmpResult.Type).to.equal('Corgi');
|
|
3004
|
+
Expect(tmpResult.CreatingIDUser).to.equal(1);
|
|
3005
|
+
Expect(tmpResult.UpdatingIDUser).to.equal(_MockSessionValidUser.UserID);
|
|
3006
|
+
|
|
3007
|
+
fDone();
|
|
3008
|
+
}
|
|
3009
|
+
);
|
|
3010
|
+
}
|
|
3011
|
+
);
|
|
3012
|
+
test
|
|
3013
|
+
(
|
|
3014
|
+
'invoke delete: delete a record',
|
|
3015
|
+
function(fDone)
|
|
3016
|
+
{
|
|
3017
|
+
// Delete animal 1
|
|
3018
|
+
var tmpRecord = {IDAnimal:1};
|
|
3019
|
+
_MeadowEndpoints.invokeEndpoint('Delete', tmpRecord, {UserSession: _MockSessionValidUser},
|
|
3020
|
+
function(pError, pResponse)
|
|
3021
|
+
{
|
|
3022
|
+
Expect(pResponse.body.ErrorCode).to.equal(405);
|
|
3023
|
+
Expect(pResponse.body.Error).to.equal('UNAUTHORIZED ACCESS IS NOT ALLOWED');
|
|
3024
|
+
|
|
3025
|
+
fDone();
|
|
3026
|
+
}
|
|
3027
|
+
);
|
|
3028
|
+
}
|
|
3029
|
+
);
|
|
3030
|
+
test
|
|
3031
|
+
(
|
|
3032
|
+
'bulk creates',
|
|
3033
|
+
function(fDone)
|
|
3034
|
+
{
|
|
3035
|
+
var tmpRecords = [
|
|
3036
|
+
{Name:'Billy', Type:'Cat'},
|
|
3037
|
+
{Name:'Jim', Type:'Cat'},
|
|
3038
|
+
{Name:'Janet', Type:'Cat'},
|
|
3039
|
+
{Name:'Sweeps', Type:'Cat'},
|
|
3040
|
+
{Name:'Stakes', Type:'Dog'},
|
|
3041
|
+
{Name:'Sally', Type:'Dog'},
|
|
3042
|
+
{Name:'Bill', Type:'Dog'},
|
|
3043
|
+
{Name:'Chris', Type:'Dog'},
|
|
3044
|
+
{Name:'Haji', Type:'Snake'}
|
|
3045
|
+
];
|
|
3046
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
3047
|
+
libSuperTest('http://localhost:9080/')
|
|
3048
|
+
.post('1.0/FableTests')
|
|
3049
|
+
.send(tmpRecords)
|
|
3050
|
+
.end(
|
|
3051
|
+
function(pError, pResponse)
|
|
3052
|
+
{
|
|
3053
|
+
// Expect response to be the record we just created.
|
|
3054
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
3055
|
+
//console.log(JSON.stringify(tmpResult,null,4));
|
|
3056
|
+
Expect(tmpResult[0].Name).to.equal('Billy');
|
|
3057
|
+
Expect(tmpResult[5].Type).to.equal('Dog');
|
|
3058
|
+
fDone();
|
|
3059
|
+
}
|
|
3060
|
+
);
|
|
3061
|
+
}
|
|
3062
|
+
);
|
|
3063
|
+
test
|
|
3064
|
+
(
|
|
3065
|
+
'bulk create with a bad record',
|
|
3066
|
+
function(fDone)
|
|
3067
|
+
{
|
|
3068
|
+
var tmpRecords = [
|
|
3069
|
+
{Name:'Astro', Type:'Cartoon'},
|
|
3070
|
+
{Name:'Boy', Type:'Cartoon'},
|
|
3071
|
+
{License:'Whoops', Type:'Cat'},
|
|
3072
|
+
{Name:'Froggy', Type:'Cartoon'}
|
|
3073
|
+
];
|
|
3074
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
3075
|
+
libSuperTest('http://localhost:9080/')
|
|
3076
|
+
.post('1.0/FableTests')
|
|
3077
|
+
.send(tmpRecords)
|
|
3078
|
+
.end(
|
|
3079
|
+
function(pError, pResponse)
|
|
3080
|
+
{
|
|
3081
|
+
// Expect response to be the record we just created.
|
|
3082
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
3083
|
+
Expect(tmpResult[0].Type).to.equal('Cartoon');
|
|
3084
|
+
fDone();
|
|
3085
|
+
}
|
|
3086
|
+
);
|
|
3087
|
+
}
|
|
3088
|
+
);
|
|
3089
|
+
test
|
|
3090
|
+
(
|
|
3091
|
+
'bulk updates',
|
|
3092
|
+
function(fDone)
|
|
3093
|
+
{
|
|
3094
|
+
var tmpRecords = [
|
|
3095
|
+
{IDAnimal: 11, Type:'Hoss'},
|
|
3096
|
+
{IDAnimal: 12, Type:'Hoss'},
|
|
3097
|
+
{IDAnimal: 14, Type:'Hoss'},
|
|
3098
|
+
{IDAnimal: 15, Type:'Hoss'}
|
|
3099
|
+
];
|
|
3100
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
3101
|
+
libSuperTest('http://localhost:9080/')
|
|
3102
|
+
.put('1.0/FableTests')
|
|
3103
|
+
.send(tmpRecords)
|
|
3104
|
+
.end(
|
|
3105
|
+
function(pError, pResponse)
|
|
3106
|
+
{
|
|
3107
|
+
// Expect response to be the record we just created.
|
|
3108
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
3109
|
+
//console.log(JSON.stringify(tmpResult,null,4));
|
|
3110
|
+
Expect(tmpResult[0].IDAnimal).to.equal(11);
|
|
3111
|
+
Expect(tmpResult[0].Type).to.equal('Hoss');
|
|
3112
|
+
Expect(tmpResult[1].Type).to.equal('Hoss');
|
|
3113
|
+
Expect(tmpResult[2].Type).to.equal('Hoss');
|
|
3114
|
+
Expect(tmpResult[3].Type).to.equal('Hoss');
|
|
3115
|
+
fDone();
|
|
3116
|
+
}
|
|
3117
|
+
);
|
|
3118
|
+
}
|
|
3119
|
+
);
|
|
3120
|
+
test
|
|
3121
|
+
(
|
|
3122
|
+
'bulk updates with bad record',
|
|
3123
|
+
function(fDone)
|
|
3124
|
+
{
|
|
3125
|
+
var tmpRecords = [
|
|
3126
|
+
{IDAnimal: 11, Type:'Horsse'},
|
|
3127
|
+
{IDAnimal: 12, Type:'Horsse'},
|
|
3128
|
+
{IDAnimal: 14, Genus:'Hosse'},
|
|
3129
|
+
{IDAnimal: 15, Type:'Hosses'}
|
|
3130
|
+
];
|
|
3131
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
3132
|
+
libSuperTest('http://localhost:9080/')
|
|
3133
|
+
.put('1.0/FableTests')
|
|
3134
|
+
.send(tmpRecords)
|
|
3135
|
+
.end(
|
|
3136
|
+
function(pError, pResponse)
|
|
3137
|
+
{
|
|
3138
|
+
// Expect response to be the record we just created.
|
|
3139
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
3140
|
+
//console.log(JSON.stringify(tmpResult,null,4));
|
|
3141
|
+
Expect(tmpResult[3].Type).to.equal('Hosses');
|
|
3142
|
+
fDone();
|
|
3143
|
+
}
|
|
3144
|
+
);
|
|
3145
|
+
}
|
|
3146
|
+
);
|
|
3147
|
+
test
|
|
3148
|
+
(
|
|
3149
|
+
'invoke readlite: get all records',
|
|
3150
|
+
function(fDone)
|
|
3151
|
+
{
|
|
3152
|
+
_MeadowEndpoints.invokeEndpoint('ReadLiteList', {}, {UserSession: _MockSessionValidUser},
|
|
3153
|
+
function (pError, pResponse)
|
|
3154
|
+
{
|
|
3155
|
+
//console.log(pResponse.body)
|
|
3156
|
+
Expect(pResponse.body)
|
|
3157
|
+
.to.be.an('array');
|
|
3158
|
+
//var tmpResults = JSON.parse(pResponse.text);
|
|
3159
|
+
//Expect(tmpResults.Error).to.contain('authenticated');
|
|
3160
|
+
fDone();
|
|
3161
|
+
}
|
|
3162
|
+
);
|
|
3163
|
+
}
|
|
3164
|
+
);
|
|
3165
|
+
test
|
|
3166
|
+
(
|
|
3167
|
+
'upsert: create a record',
|
|
3168
|
+
function(fDone)
|
|
3169
|
+
{
|
|
3170
|
+
var tmpRecord = {GUIDAnimal:'0xHAXXXX', Name:'Jason', Type:'Tyranosaurus'};
|
|
3171
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
3172
|
+
libSuperTest('http://localhost:9080/')
|
|
3173
|
+
.put('1.0/FableTest/Upsert')
|
|
3174
|
+
.send(tmpRecord)
|
|
3175
|
+
.end(
|
|
3176
|
+
function(pError, pResponse)
|
|
3177
|
+
{
|
|
3178
|
+
// Expect response to be the record we just created.
|
|
3179
|
+
//console.log(pResponse.text)
|
|
3180
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
3181
|
+
Expect(tmpResult.Type).to.equal('Tyranosaurus');
|
|
3182
|
+
Expect(tmpResult.CreatingIDUser).to.equal(10);
|
|
3183
|
+
fDone();
|
|
3184
|
+
}
|
|
3185
|
+
);
|
|
3186
|
+
}
|
|
3187
|
+
);
|
|
3188
|
+
test
|
|
3189
|
+
(
|
|
3190
|
+
'upsert: Update a record',
|
|
3191
|
+
function(fDone)
|
|
3192
|
+
{
|
|
3193
|
+
var tmpRecord = {GUIDAnimal:'0xHAXXXX', Type:'Stegosaurus'};
|
|
3194
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
3195
|
+
libSuperTest('http://localhost:9080/')
|
|
3196
|
+
.put('1.0/FableTest/Upsert')
|
|
3197
|
+
.send(tmpRecord)
|
|
3198
|
+
.end(
|
|
3199
|
+
function(pError, pResponse)
|
|
3200
|
+
{
|
|
3201
|
+
// Expect response to be the record we just created.
|
|
3202
|
+
console.log(pResponse.text)
|
|
3203
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
3204
|
+
Expect(tmpResult.Type).to.equal('Stegosaurus');
|
|
3205
|
+
Expect(tmpResult.Name).to.equal('Jason');
|
|
3206
|
+
fDone();
|
|
3207
|
+
}
|
|
3208
|
+
);
|
|
3209
|
+
}
|
|
3210
|
+
);
|
|
3211
|
+
test
|
|
3212
|
+
(
|
|
3213
|
+
'bulk upserts',
|
|
3214
|
+
function(fDone)
|
|
3215
|
+
{
|
|
3216
|
+
_MeadowEndpoints.behaviorModifications.setTemplate('SelectList', '<%= Record.Name %>|<%=Record.Type%>');
|
|
3217
|
+
var tmpRecords = [
|
|
3218
|
+
{GUIDAnimal:'0xHAXXXX', Type:'Triceratops'},
|
|
3219
|
+
{GUIDAnimal:'0xDavison', Name:'Davison', Type:'Dog'},
|
|
3220
|
+
{GUIDAnimal:'0xMartino', Name:'Martin', Type:'Dog'},
|
|
3221
|
+
{Name:'Chino', Type:'Cat'}
|
|
3222
|
+
];
|
|
3223
|
+
_MockSessionValidUser.UserRoleIndex = 2;
|
|
3224
|
+
libSuperTest('http://localhost:9080/')
|
|
3225
|
+
.put('1.0/FableTest/Upserts')
|
|
3226
|
+
.send(tmpRecords)
|
|
3227
|
+
.end(
|
|
3228
|
+
function(pError, pResponse)
|
|
3229
|
+
{
|
|
3230
|
+
// Expect response to be the record we just created.
|
|
3231
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
3232
|
+
console.log(JSON.stringify(tmpResult,null,4));
|
|
3233
|
+
Expect(tmpResult[0].Value).to.equal('Jason|Triceratops');
|
|
3234
|
+
Expect(tmpResult[1].Value).to.equal('Davison|Dog');
|
|
3235
|
+
Expect(tmpResult[2].Value).to.equal('Martin|Dog');
|
|
3236
|
+
Expect(tmpResult[3].Value).to.equal('Chino|Cat');
|
|
3237
|
+
fDone();
|
|
3238
|
+
}
|
|
3239
|
+
);
|
|
3240
|
+
}
|
|
3241
|
+
);
|
|
3242
|
+
}
|
|
3243
|
+
);
|