"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const server_commands_1 = require("../../../../shared/server-commands");
describe('Test video sources API validator', function () {
    let server = null;
    let uuid;
    let userToken;
    before(function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            this.timeout(30000);
            server = yield (0, server_commands_1.createSingleServer)(1);
            yield (0, server_commands_1.setAccessTokensToServers)([server]);
            const created = yield server.videos.quickUpload({ name: 'video' });
            uuid = created.uuid;
            userToken = yield server.users.generateUserAndToken('user');
        });
    });
    it('Should fail without a valid uuid', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield server.videos.getSource({ id: '4da6fde3-88f7-4d16-b119-108df563d0b0', expectedStatus: 404 });
        });
    });
    it('Should receive 404 when passing a non existing video id', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield server.videos.getSource({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: 404 });
        });
    });
    it('Should not get the source as unauthenticated', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield server.videos.getSource({ id: uuid, expectedStatus: 401, token: null });
        });
    });
    it('Should not get the source with another user', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield server.videos.getSource({ id: uuid, expectedStatus: 403, token: userToken });
        });
    });
    it('Should succeed with the correct parameters get the source as another user', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield server.videos.getSource({ id: uuid });
        });
    });
    after(function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield (0, server_commands_1.cleanupTests)([server]);
        });
    });
});
//# sourceMappingURL=video-source.js.map