"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const server_commands_1 = require("../../../../shared/server-commands");
describe('Test video tokens', function () {
    let server;
    let videoId;
    let userToken;
    before(function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            this.timeout(300000);
            server = yield (0, server_commands_1.createSingleServer)(1);
            yield (0, server_commands_1.setAccessTokensToServers)([server]);
            const { uuid } = yield server.videos.quickUpload({ name: 'video', privacy: 3 });
            videoId = uuid;
            userToken = yield server.users.generateUserAndToken('user1');
        });
    });
    it('Should not generate tokens for unauthenticated user', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield server.videoToken.create({ videoId, token: null, expectedStatus: 401 });
        });
    });
    it('Should not generate tokens of unknown video', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield server.videoToken.create({ videoId: 404, expectedStatus: 404 });
        });
    });
    it('Should not generate tokens of a non owned video', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield server.videoToken.create({ videoId, token: userToken, expectedStatus: 403 });
        });
    });
    it('Should generate token', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield server.videoToken.create({ videoId });
        });
    });
    after(function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield (0, server_commands_1.cleanupTests)([server]);
        });
    });
});
//# sourceMappingURL=video-token.js.map