diff --git a/test/api.feeds.upload.feed-method.js b/test/api.feeds.upload.feed-method.js index 8a83014..1371df4 100644 --- a/test/api.feeds.upload.feed-method.js +++ b/test/api.feeds.upload.feed-method.js @@ -58,6 +58,26 @@ describe("REST API", function() { response : requireNew('./fixtures/feed-upload8-response.json') }; + const invalidChannelName1 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-1-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-1-response.json') + } + + const invalidChannelName2 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-2-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-2-response.json') + } + + const invalidChannelName3 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-3-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-3-response.json') + } + + const invalidChannelName4 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-4-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-4-response.json') + } + before(function(initDone) { flow.series( [ @@ -312,9 +332,61 @@ describe("REST API", function() { expectedHttpStatus : httpStatus.UNAUTHORIZED, expectedStatusText : 'error', hasEmptyBody : true + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : ESDR_FEED_API_URL, + headers : function() { + return { + FeedApiKey : feed1.apiKey + } + }, + dataToUpload : invalidChannelName1.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName1.response, + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : ESDR_FEED_API_URL, + headers : function() { + return { + FeedApiKey : feed1.apiKey + } + }, + dataToUpload : invalidChannelName2.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName2.response, + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : ESDR_FEED_API_URL, + headers : function() { + return { + FeedApiKey : feed1.apiKey + } + }, + dataToUpload : invalidChannelName3.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName3.response, + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : ESDR_FEED_API_URL, + headers : function() { + return { + FeedApiKey : feed1.apiKey + } + }, + dataToUpload : invalidChannelName4.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName4.response, } ].forEach(executeUploadTest); }); // End To /feed method }); // End Upload }); // End Feeds -}); // End REST API \ No newline at end of file +}); // End REST API diff --git a/test/api.feeds.upload.feeds-method.apikey-auth.request-header.js b/test/api.feeds.upload.feeds-method.apikey-auth.request-header.js index fcfe2d8..fb07370 100644 --- a/test/api.feeds.upload.feeds-method.apikey-auth.request-header.js +++ b/test/api.feeds.upload.feeds-method.apikey-auth.request-header.js @@ -60,6 +60,26 @@ describe("REST API", function() { response : requireNew('./fixtures/feed-upload8-response.json') }; + const invalidChannelName1 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-1-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-1-response.json') + } + + const invalidChannelName2 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-2-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-2-response.json') + } + + const invalidChannelName3 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-3-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-3-response.json') + } + + const invalidChannelName4 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-4-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-4-response.json') + } + before(function(initDone) { flow.series( [ @@ -370,6 +390,58 @@ describe("REST API", function() { expectedHttpStatus : httpStatus.NOT_FOUND, expectedStatusText : 'error', expectedResponseData : null + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : function() { + return ESDR_FEEDS_API_URL + "/" + feed1.id; + }, + headers : function() { + return { FeedApiKey : feed1.apiKey }; + }, + dataToUpload : invalidChannelName1.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName1.response, + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : function() { + return ESDR_FEEDS_API_URL + "/" + feed1.id; + }, + headers : function() { + return { FeedApiKey : feed1.apiKey }; + }, + dataToUpload : invalidChannelName2.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName2.response, + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : function() { + return ESDR_FEEDS_API_URL + "/" + feed1.id; + }, + headers : function() { + return { FeedApiKey : feed1.apiKey }; + }, + dataToUpload : invalidChannelName3.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName3.response, + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : function() { + return ESDR_FEEDS_API_URL + "/" + feed1.id; + }, + headers : function() { + return { FeedApiKey : feed1.apiKey }; + }, + dataToUpload : invalidChannelName4.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName4.response, } ].forEach(executeUploadTest); @@ -378,4 +450,4 @@ describe("REST API", function() { }); // End To /feeds method }); // End Upload }); // End Feeds -}); // End REST API \ No newline at end of file +}); // End REST API diff --git a/test/api.feeds.upload.feeds-method.apikey-auth.url.js b/test/api.feeds.upload.feeds-method.apikey-auth.url.js index b8311f1..a20e4a7 100644 --- a/test/api.feeds.upload.feeds-method.apikey-auth.url.js +++ b/test/api.feeds.upload.feeds-method.apikey-auth.url.js @@ -60,6 +60,26 @@ describe("REST API", function() { response : requireNew('./fixtures/feed-upload8-response.json') }; + const invalidChannelName1 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-1-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-1-response.json') + } + + const invalidChannelName2 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-2-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-2-response.json') + } + + const invalidChannelName3 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-3-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-3-response.json') + } + + const invalidChannelName4 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-4-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-4-response.json') + } + before(function(initDone) { flow.series( [ @@ -263,6 +283,46 @@ describe("REST API", function() { expectedHttpStatus : httpStatus.NOT_FOUND, expectedStatusText : 'error', expectedResponseData : null + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : function() { + return ESDR_FEEDS_API_URL + "/" + feed1.apiKey; + }, + dataToUpload : invalidChannelName1.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName1.response, + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : function() { + return ESDR_FEEDS_API_URL + "/" + feed1.apiKey; + }, + dataToUpload : invalidChannelName2.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName2.response, + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : function() { + return ESDR_FEEDS_API_URL + "/" + feed1.apiKey; + }, + dataToUpload : invalidChannelName3.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName3.response, + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : function() { + return ESDR_FEEDS_API_URL + "/" + feed1.apiKey; + }, + dataToUpload : invalidChannelName4.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName4.response, } ].forEach(executeUploadTest); @@ -271,4 +331,4 @@ describe("REST API", function() { }); // End To /feeds method }); // End Upload }); // End Feeds -}); // End REST API \ No newline at end of file +}); // End REST API diff --git a/test/api.feeds.upload.feeds-method.oauth2-auth.js b/test/api.feeds.upload.feeds-method.oauth2-auth.js index a831053..ca6d8ae 100644 --- a/test/api.feeds.upload.feeds-method.oauth2-auth.js +++ b/test/api.feeds.upload.feeds-method.oauth2-auth.js @@ -61,6 +61,26 @@ describe("REST API", function() { response : requireNew('./fixtures/feed-upload8-response.json') }; + const invalidChannelName1 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-1-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-1-response.json') + } + + const invalidChannelName2 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-2-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-2-response.json') + } + + const invalidChannelName3 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-3-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-3-response.json') + } + + const invalidChannelName4 = { + request : requireNew('./fixtures/feed-upload-invalid-channel-name-4-request.json'), + response : requireNew('./fixtures/feed-upload-invalid-channel-name-4-response.json') + } + before(function(initDone) { flow.series( [ @@ -361,6 +381,58 @@ describe("REST API", function() { expectedHttpStatus : httpStatus.UNAUTHORIZED, expectedStatusText : 'error', expectedResponseData : null + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : function() { + return ESDR_FEEDS_API_URL + "/" + feed1.id; + }, + headers : function() { + return createAuthorizationHeader(user1.accessToken); + }, + dataToUpload : invalidChannelName1.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName1.response, + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : function() { + return ESDR_FEEDS_API_URL + "/" + feed1.id; + }, + headers : function() { + return createAuthorizationHeader(user1.accessToken); + }, + dataToUpload : invalidChannelName2.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName2.response, + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : function() { + return ESDR_FEEDS_API_URL + "/" + feed1.id; + }, + headers : function() { + return createAuthorizationHeader(user1.accessToken); + }, + dataToUpload : invalidChannelName3.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName3.response, + }, + { + description : "Should fail to upload to a feed if one or more channel names is invalid", + url : function() { + return ESDR_FEEDS_API_URL + "/" + feed1.id; + }, + headers : function() { + return createAuthorizationHeader(user1.accessToken); + }, + dataToUpload : invalidChannelName4.request, + expectedHttpStatus : httpStatus.UNPROCESSABLE_ENTITY, + expectedStatusText : 'error', + expectedResponseData : invalidChannelName4.response, } ].forEach(executeUploadTest); @@ -369,4 +441,4 @@ describe("REST API", function() { }); // End To /feeds method }); // End Upload }); // End Feeds -}); // End REST API \ No newline at end of file +}); // End REST API diff --git a/test/fixtures/feed-upload-invalid-channel-name-1-request.json b/test/fixtures/feed-upload-invalid-channel-name-1-request.json new file mode 100644 index 0000000..000d153 --- /dev/null +++ b/test/fixtures/feed-upload-invalid-channel-name-1-request.json @@ -0,0 +1,6 @@ +{ + "channel_names" : ["my channel"], + "data" : [ + [1441856362, 42] + ] +} diff --git a/test/fixtures/feed-upload-invalid-channel-name-1-response.json b/test/fixtures/feed-upload-invalid-channel-name-1-response.json new file mode 100644 index 0000000..b5d8104 --- /dev/null +++ b/test/fixtures/feed-upload-invalid-channel-name-1-response.json @@ -0,0 +1 @@ +{ "data" : ["my channel"] } diff --git a/test/fixtures/feed-upload-invalid-channel-name-2-request.json b/test/fixtures/feed-upload-invalid-channel-name-2-request.json new file mode 100644 index 0000000..f085276 --- /dev/null +++ b/test/fixtures/feed-upload-invalid-channel-name-2-request.json @@ -0,0 +1,6 @@ +{ + "channel_names" : ["this_IS_valid", "this+is+not", "also_valid", "neither[is]this"], + "data" : [ + [1441856362, 42, 43, 44, 45] + ] +} diff --git a/test/fixtures/feed-upload-invalid-channel-name-2-response.json b/test/fixtures/feed-upload-invalid-channel-name-2-response.json new file mode 100644 index 0000000..dffa957 --- /dev/null +++ b/test/fixtures/feed-upload-invalid-channel-name-2-response.json @@ -0,0 +1 @@ +{ "data" : ["this+is+not", "neither[is]this"] } diff --git a/test/fixtures/feed-upload-invalid-channel-name-3-request.json b/test/fixtures/feed-upload-invalid-channel-name-3-request.json new file mode 100644 index 0000000..b05019e --- /dev/null +++ b/test/fixtures/feed-upload-invalid-channel-name-3-request.json @@ -0,0 +1,15 @@ +[ + { + "channel_names" : [ + "i-am-valid", + " i am not!", + "hey.mom.look.i.am.valid", + "but..i..am..not", + ".another-invalid", + "and-one-more." + ], + "data" : [ + [1441856362, 1, 2, 3, 4, 5, 6] + ] + } +] diff --git a/test/fixtures/feed-upload-invalid-channel-name-3-response.json b/test/fixtures/feed-upload-invalid-channel-name-3-response.json new file mode 100644 index 0000000..5a55fa5 --- /dev/null +++ b/test/fixtures/feed-upload-invalid-channel-name-3-response.json @@ -0,0 +1,8 @@ +{ + "data" : [ + " i am not!", + "but..i..am..not", + ".another-invalid", + "and-one-more." + ] +} diff --git a/test/fixtures/feed-upload-invalid-channel-name-4-request.json b/test/fixtures/feed-upload-invalid-channel-name-4-request.json new file mode 100644 index 0000000..390aa2a --- /dev/null +++ b/test/fixtures/feed-upload-invalid-channel-name-4-request.json @@ -0,0 +1,41 @@ +[ + { + "channel_names" : ["good-channel", "bad channel"], + "data" : [ + [1441856364, 10, 20] + ] + }, + { + "channel_names" : ["my*other*bad*channel*name", "ok_channel_name"], + "data" : [ + [1441856365, 34, 40] + ] + }, + { + "channel_names" : ["this_one_is_fine"], + "data" : [ + [1441856366, 50] + ] + }, + { + "channel_names" : ["this------is------weird------but------totally------fine", "424242"], + "data" : [ + [1441856367, 60, 70] + ] + }, + { + "channel_names" : [ + ".", + "..", + "..hi", + "bye..", + "?", + "!", + "@", + " " + ], + "data" : [ + [1441856368, 1, 2, 3, 4, 5, 6, 7, 8] + ] + } +] diff --git a/test/fixtures/feed-upload-invalid-channel-name-4-response.json b/test/fixtures/feed-upload-invalid-channel-name-4-response.json new file mode 100644 index 0000000..a068672 --- /dev/null +++ b/test/fixtures/feed-upload-invalid-channel-name-4-response.json @@ -0,0 +1,14 @@ +{ + "data" : [ + "bad channel", + "my*other*bad*channel*name", + ".", + "..", + "..hi", + "bye..", + "?", + "!", + "@", + " " + ] +}