"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 user negative tests', () => {
    const paabHelper = new paabHelper_1.PaabHelper(1);
    let adminSession;
    let pa1Session;
    let rs1Session;
    let anonymousSession;
    let testUserId;
    beforeEach(() => {
        expect.hasAssertions();
    });
    beforeAll(async () => {
        ({ adminSession, pa1Session, rs1Session, anonymousSession } = await paabHelper.createResources(__filename));
        testUserId = rs1Session.getUserId();
    });
    afterAll(async () => {
        await paabHelper.cleanup();
    });
    describe('boundary tests', () => {
        test('cannot list users if user is a researcher', async () => {
            try {
                await rs1Session.resources.users.user(testUserId).get();
            }
            catch (e) {
                (0, utilities_1.checkHttpError)(e, new HttpError_1.default(403, {
                    error: 'User is not authorized'
                }));
            }
        });
        test('cannot list users if user is unauthenticated', async () => {
            try {
                await anonymousSession.resources.users.user(testUserId).get();
            }
            catch (e) {
                (0, utilities_1.checkHttpError)(e, new HttpError_1.default(401, {}));
            }
        });
        test('can list users if user is a ITAdmin', async () => {
            await expect(adminSession.resources.users.user(testUserId).get()).resolves.not.toThrow();
        });
        test('can list users if user is a project admin', async () => {
            await expect(pa1Session.resources.users.user(testUserId).get()).resolves.not.toThrow();
        });
    });
});
//# sourceMappingURL=getUser.test.js.map