"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('Get Project negative tests', () => {
    const paabHelper = new paabHelper_1.PaabHelper(2);
    let pa1Session;
    let rs1Session;
    let anonymousSession;
    let project2Id;
    beforeEach(async () => {
        expect.hasAssertions();
    });
    beforeAll(async () => {
        const paabResources = await paabHelper.createResources(__filename);
        pa1Session = paabResources.pa1Session;
        rs1Session = paabResources.rs1Session;
        anonymousSession = paabResources.anonymousSession;
        project2Id = paabResources.project2Id;
    });
    afterAll(async () => {
        await paabHelper.cleanup();
    });
    describe('when a ProjectAdmin GETs a project they do not belong to', () => {
        test('it returns a 403', async () => {
            try {
                await pa1Session.resources.projects.project(project2Id).get();
            }
            catch (e) {
                (0, utilities_1.checkHttpError)(e, new HttpError_1.default(403, {
                    error: 'User is not authorized'
                }));
            }
        });
    });
    describe('when a Researcher GETs a project they do not belong to', () => {
        test('it returns a 403', async () => {
            try {
                await rs1Session.resources.projects.project(project2Id).get();
            }
            catch (e) {
                (0, utilities_1.checkHttpError)(e, new HttpError_1.default(403, {
                    error: 'User is not authorized'
                }));
            }
        });
    });
    test('Unauthenticated user gets 401', async () => {
        try {
            await anonymousSession.resources.projects.project(project2Id).get();
        }
        catch (e) {
            (0, utilities_1.checkHttpError)(e, new HttpError_1.default(401, {}));
        }
    });
});
//# sourceMappingURL=get.test.js.map