"use strict";
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 setup_1 = __importDefault(require("../../../support/setup"));
const HttpError_1 = __importDefault(require("../../../support/utils/HttpError"));
const utilities_1 = require("../../../support/utils/utilities");
describe('get environment type configs', () => {
    const paabHelper = new paabHelper_1.PaabHelper(1);
    const setup = setup_1.default.getSetup();
    const envTypeId = setup.getSettings().get('envTypeId');
    const envTypeConfigId = setup.getSettings().get('envTypeConfigId');
    let paSession;
    let researcherSession;
    let anonymousSession;
    beforeEach(() => {
        expect.hasAssertions();
    });
    beforeAll(async () => {
        const paabResources = await paabHelper.createResources(__filename);
        paSession = paabResources.pa1Session;
        researcherSession = paabResources.rs1Session;
        anonymousSession = paabResources.anonymousSession;
    });
    afterAll(async () => {
        await paabHelper.cleanup();
        await setup.cleanup();
    });
    describe('Project Admin tests', () => {
        test('unauthorized to call GetEnvironmentTypeConfig', async () => {
            try {
                await paSession.resources.environmentTypes
                    .environmentType(envTypeId)
                    .configurations()
                    .environmentTypeConfig(envTypeConfigId)
                    .get();
            }
            catch (e) {
                (0, utilities_1.checkHttpError)(e, new HttpError_1.default(403, {
                    error: 'User is not authorized'
                }));
            }
        });
    });
    describe('Researcher tests', () => {
        test('unauthorized to call GetEnvironmentTypeConfig', async () => {
            try {
                await researcherSession.resources.environmentTypes
                    .environmentType(envTypeId)
                    .configurations()
                    .environmentTypeConfig(envTypeConfigId)
                    .get();
            }
            catch (e) {
                (0, utilities_1.checkHttpError)(e, new HttpError_1.default(403, {
                    error: 'User is not authorized'
                }));
            }
        });
    });
    test('Unauthenticated user cannot call GetEnvironmentTypeConfig', async () => {
        try {
            await anonymousSession.resources.environmentTypes
                .environmentType(envTypeId)
                .configurations()
                .environmentTypeConfig(envTypeConfigId)
                .get();
        }
        catch (e) {
            (0, utilities_1.checkHttpError)(e, new HttpError_1.default(401, {}));
        }
    });
});
//# sourceMappingURL=get.test.js.map