meadow-endpoints 2.0.20 → 2.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -43,7 +43,7 @@ var doAPIDeleteEndpoint = function(pRequest, pResponse, fNext)
|
|
|
43
43
|
tmpIDRecord = pRequest.body[pRequest.DAL.defaultIdentifier];
|
|
44
44
|
}
|
|
45
45
|
// Although the delete request does allow multiple deletes, we require an identifier.
|
|
46
|
-
if (tmpIDRecord < 1)
|
|
46
|
+
if (!parseInt(tmpIDRecord) || tmpIDRecord < 1)
|
|
47
47
|
{
|
|
48
48
|
return pRequest.CommonServices.sendError('Record delete failure - a valid record ID is required in the passed-in record.', pRequest, pResponse, fNext);
|
|
49
49
|
}
|
|
@@ -41,7 +41,7 @@ var doAPIUpdateEndpoint = function(pRequest, pResponse, fNext)
|
|
|
41
41
|
{
|
|
42
42
|
return pRequest.CommonServices.sendError('Record update failure - a valid record is required.', pRequest, pResponse, fNext);
|
|
43
43
|
}
|
|
44
|
-
if (pRequest.body[pRequest.DAL.defaultIdentifier] < 1)
|
|
44
|
+
if (!parseInt(pRequest.body[pRequest.DAL.defaultIdentifier]) || pRequest.body[pRequest.DAL.defaultIdentifier] < 1)
|
|
45
45
|
{
|
|
46
46
|
return pRequest.CommonServices.sendError('Record update failure - a valid record ID is required in the passed-in record.', pRequest, pResponse, fNext);
|
|
47
47
|
}
|
|
@@ -18,7 +18,7 @@ var doUpdate = function(pRecordToModify, pRequest, pResponse, fCallback, pOption
|
|
|
18
18
|
pRequest.MeadowOperation = (typeof(pRequest.MeadowOperation) === 'string') ? pRequest.MeadowOperation : 'Update';
|
|
19
19
|
|
|
20
20
|
// If there is not a default identifier or cached record, fail
|
|
21
|
-
if ((pRecordToModify[pRequest.DAL.defaultIdentifier] < 1) && (typeof(pOptionalCachedUpdatingRecord) === 'undefined'))
|
|
21
|
+
if ((!parseInt(pRecordToModify[pRequest.DAL.defaultIdentifier]) || pRecordToModify[pRequest.DAL.defaultIdentifier] < 1) && (typeof(pOptionalCachedUpdatingRecord) === 'undefined'))
|
|
22
22
|
{
|
|
23
23
|
return fCallback('Record update failure - a valid record ID is required in the passed-in record.');
|
|
24
24
|
}
|
|
@@ -961,6 +961,48 @@ suite
|
|
|
961
961
|
}
|
|
962
962
|
);
|
|
963
963
|
test
|
|
964
|
+
(
|
|
965
|
+
'update: update a record with a missing ID',
|
|
966
|
+
function(fDone)
|
|
967
|
+
{
|
|
968
|
+
// Update animal but don't provide ID
|
|
969
|
+
var tmpRecord = { Type:'Corgi' };
|
|
970
|
+
libSuperTest('http://localhost:9080/')
|
|
971
|
+
.del('1.0/FableTest')
|
|
972
|
+
.send(tmpRecord)
|
|
973
|
+
.end(
|
|
974
|
+
function(pError, pResponse)
|
|
975
|
+
{
|
|
976
|
+
// Expect response to be the count of deleted records.
|
|
977
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
978
|
+
Expect(tmpResult.Error).to.contain('a valid record ID is required');
|
|
979
|
+
fDone();
|
|
980
|
+
}
|
|
981
|
+
);
|
|
982
|
+
}
|
|
983
|
+
);
|
|
984
|
+
test
|
|
985
|
+
(
|
|
986
|
+
'update: update a record with a malformed ID',
|
|
987
|
+
function(fDone)
|
|
988
|
+
{
|
|
989
|
+
// Update animal but don't provide ID
|
|
990
|
+
var tmpRecord = { IDAnimal: { ID: 3 }, Type:'Corgi' };
|
|
991
|
+
libSuperTest('http://localhost:9080/')
|
|
992
|
+
.del('1.0/FableTest')
|
|
993
|
+
.send(tmpRecord)
|
|
994
|
+
.end(
|
|
995
|
+
function(pError, pResponse)
|
|
996
|
+
{
|
|
997
|
+
// Expect response to be the count of deleted records.
|
|
998
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
999
|
+
Expect(tmpResult.Error).to.contain('a valid record ID is required');
|
|
1000
|
+
fDone();
|
|
1001
|
+
}
|
|
1002
|
+
);
|
|
1003
|
+
}
|
|
1004
|
+
);
|
|
1005
|
+
test
|
|
964
1006
|
(
|
|
965
1007
|
'update: update a record',
|
|
966
1008
|
function(fDone)
|
|
@@ -1006,7 +1048,28 @@ suite
|
|
|
1006
1048
|
);
|
|
1007
1049
|
test
|
|
1008
1050
|
(
|
|
1009
|
-
'delete: delete a record with a
|
|
1051
|
+
'delete: delete a record with a missing ID',
|
|
1052
|
+
function(fDone)
|
|
1053
|
+
{
|
|
1054
|
+
// Delete animal but don't provide ID
|
|
1055
|
+
var tmpRecord = { Type: 'Corgi' };
|
|
1056
|
+
libSuperTest('http://localhost:9080/')
|
|
1057
|
+
.del('1.0/FableTest')
|
|
1058
|
+
.send(tmpRecord)
|
|
1059
|
+
.end(
|
|
1060
|
+
function(pError, pResponse)
|
|
1061
|
+
{
|
|
1062
|
+
// Expect response to be the count of deleted records.
|
|
1063
|
+
var tmpResult = JSON.parse(pResponse.text);
|
|
1064
|
+
Expect(tmpResult.Error).to.contain('a valid record ID is required');
|
|
1065
|
+
fDone();
|
|
1066
|
+
}
|
|
1067
|
+
);
|
|
1068
|
+
}
|
|
1069
|
+
);
|
|
1070
|
+
test
|
|
1071
|
+
(
|
|
1072
|
+
'delete: delete a record with a bad ID',
|
|
1010
1073
|
function(fDone)
|
|
1011
1074
|
{
|
|
1012
1075
|
// Delete animal 3 ("Red")
|