"use strict";
/*
 *  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *  SPDX-License-Identifier: Apache-2.0
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const paabHelper_1 = require("../../../support/complex/paabHelper");
const HttpError_1 = __importDefault(require("../../../support/utils/HttpError"));
const utilities_1 = require("../../../support/utils/utilities");
describe('Soft Delete Project negative tests', () => {
    const paabHelper = new paabHelper_1.PaabHelper(2);
    let adminSession;
    let pa1Session;
    let rs1Session;
    let anonymousSession;
    let project1Id;
    let project2Id;
    beforeEach(() => {
        expect.hasAssertions();
    });
    beforeAll(async () => {
        ({ adminSession, pa1Session, rs1Session, anonymousSession, project1Id, project2Id } =
            await paabHelper.createResources(__filename));
    });
    afterAll(async () => {
        await paabHelper.cleanup();
    });
    describe('with Project that does not exist', () => {
        const invalidProjectId = 'proj-00000000-0000-0000-0000-000000000000';
        test('it throws 404 error', async () => {
            try {
                await adminSession.resources.projects.project(invalidProjectId).delete();
            }
            catch (e) {
                (0, utilities_1.checkHttpError)(e, new HttpError_1.default(404, {
                    error: 'Not Found',
                    message: `Could not find project ${invalidProjectId}`
                }));
            }
        });
    });
    test('Project Admin passing in project it does not belong to gets 403', async () => {
        try {
            await pa1Session.resources.projects.project(project2Id).delete();
        }
        catch (e) {
            (0, utilities_1.checkHttpError)(e, new HttpError_1.default(403, {
                error: 'User is not authorized'
            }));
        }
    });
    test('Researcher gets 403', async () => {
        try {
            await rs1Session.resources.projects.project(project1Id).delete();
        }
        catch (e) {
            (0, utilities_1.checkHttpError)(e, new HttpError_1.default(403, {
                error: 'User is not authorized'
            }));
        }
    });
    test('unauthenticated user gets 403', async () => {
        try {
            await anonymousSession.resources.projects.project(project1Id).delete();
        }
        catch (e) {
            (0, utilities_1.checkHttpError)(e, new HttpError_1.default(403, {}));
        }
    });
});
//# sourceMappingURL=softDelete.test.js.map