"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 client_sagemaker_1 = require("@aws-sdk/client-sagemaker");
const client_sts_1 = require("@aws-sdk/client-sts");
const aws_sdk_client_mock_1 = require("aws-sdk-client-mock");
const sagemakerNotebookEnvironmentConnectionService_1 = __importDefault(require("./sagemakerNotebookEnvironmentConnectionService"));
describe('SagemakerNotebookEnvironmentConnectionService', () => {
    test('getAuthCreds should return mocked value', async () => {
        // BUILD
        const sm = new sagemakerNotebookEnvironmentConnectionService_1.default();
        const instanceName = 'instance-abc123';
        const sagemakerMock = (0, aws_sdk_client_mock_1.mockClient)(client_sagemaker_1.SageMakerClient);
        const url = 'authorized-url-123';
        sagemakerMock.on(client_sagemaker_1.CreatePresignedNotebookInstanceUrlCommand).resolvesOnce({
            AuthorizedUrl: url
        });
        const iamMock = (0, aws_sdk_client_mock_1.mockClient)(client_sts_1.STSClient);
        iamMock.on(client_sts_1.AssumeRoleCommand).resolvesOnce({
            Credentials: {
                AccessKeyId: 'sampleAccessKey',
                SecretAccessKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
                SessionToken: 'sampleSessionToken',
                Expiration: new Date()
            }
        });
        // OPERATE & CHECK
        await expect(sm.getAuthCreds(instanceName, {
            roleArn: 'arn:aws:iam::<HOSTING-ACCOUNT-ID>:role/swb-dev-oh-env-mgmt',
            externalId: 'external-id-123'
        })).resolves.toEqual({
            url
        });
    });
    test('getConnectionInstruction should return mocked value', async () => {
        const sm = new sagemakerNotebookEnvironmentConnectionService_1.default();
        await expect(sm.getConnectionInstruction()).resolves.toEqual('To access Sagemaker Notebook, open #{"type":"link","hrefKey":"url","text":"Sagemaker URL"}');
    });
});
//# sourceMappingURL=sagemakerNotebookEnvironmentConnectionService.test.js.map