Merge pull request #405 from mchangrh/validateVideoID

add check for zero length videoID
This commit is contained in:
Ajay Ramachandran 2021-11-28 11:20:04 -05:00 committed by GitHub
commit ad23ec040b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -302,7 +302,7 @@ async function checkUserActiveWarning(userID: string): Promise<CheckResult> {
function checkInvalidFields(videoID: VideoID, userID: UserID, segments: IncomingSegment[]): CheckResult {
const invalidFields = [];
const errors = [];
if (typeof videoID !== "string") {
if (typeof videoID !== "string" || videoID?.length == 0) {
invalidFields.push("videoID");
}
if (typeof userID !== "string" || userID?.length < 30) {

View file

@ -1084,4 +1084,20 @@ describe("postSkipSegments", () => {
})
.catch(err => done(err));
});
it("Should return 400 if videoID is empty", (done) => {
const videoID = null as string;
postSkipSegmentParam({
videoID,
startTime: 1,
endTime: 5,
category: "sponsor",
userID: submitUserTwo
})
.then(res => {
assert.strictEqual(res.status, 400);
done();
})
.catch(err => done(err));
});
});