"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
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', () => {
    const setup = setup_1.default.getSetup();
    let adminSession;
    let anonymousSession;
    const invalidIds = [
        'et1-prod-1234567890123,pa-1234567890123',
        'et-prod1-1234567890123,pa-1234567890123',
        'et-prod-12345678901234,pa-1234567890123',
        'et-prod-123456789012$,pa-1234567890123',
        'et-prod-1234567890123,pa1-1234567890123',
        'et-prod-1234567890123,pa-1234567890123423',
        'et-prod-1234567890123,pa-123456789012$' //invalid provisioning artifact character
    ];
    const testEnvTypeId = 'et-prod-0123456789012,pa-0123456789012';
    beforeEach(() => {
        expect.hasAssertions();
    });
    beforeAll(async () => {
        adminSession = await setup.getDefaultAdminSession();
        anonymousSession = await setup.createAnonymousSession();
    });
    afterAll(async () => {
        await setup.cleanup();
    });
    test.each(invalidIds)('IT Admin fails when trying to get invalid format id', async (invalidId) => {
        try {
            await adminSession.resources.environmentTypes.environmentType(invalidId).get();
        }
        catch (e) {
            (0, utilities_1.checkHttpError)(e, new HttpError_1.default(400, {
                error: 'Bad Request',
                message: 'envTypeId: Invalid ID'
            }));
        }
    });
    test('IT Admin fails when trying to get non existing environment Type', async () => {
        try {
            await adminSession.resources.environmentTypes.environmentType(testEnvTypeId).get();
        }
        catch (e) {
            (0, utilities_1.checkHttpError)(e, new HttpError_1.default(404, {
                error: 'Not Found',
                message: `Could not find environment type ${testEnvTypeId}`
            }));
        }
    });
    test('Unauthenticated user fails when trying to get environment Type', async () => {
        try {
            await anonymousSession.resources.environmentTypes.environmentType(testEnvTypeId).get();
        }
        catch (e) {
            (0, utilities_1.checkHttpError)(e, new HttpError_1.default(401, {}));
        }
    });
});
//# sourceMappingURL=get.test.js.map