"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
const vitest_1 = require("vitest");
const index_js_1 = require("../plugins/index.js");
const configuration_js_1 = require("./configuration.js");
(0, vitest_1.describe)('configuration', () => {
    (0, vitest_1.test)('can mask datasource field list secrets', () => {
        const restApiIntegrationDatasourceConfiguration = {
            headers: [
                {
                    key: 'Authorization',
                    value: 'foobar'
                },
                {
                    key: 'Content-Type',
                    value: 'foobar'
                }
            ]
        };
        const restoreConfiguration = (0, lodash_1.cloneDeep)(restApiIntegrationDatasourceConfiguration);
        (0, configuration_js_1.maskSecrets)(restApiIntegrationDatasourceConfiguration, index_js_1.RestApiIntegrationPlugin);
        let headers = restApiIntegrationDatasourceConfiguration.headers;
        (0, vitest_1.expect)(headers[0].value).toBe(configuration_js_1.MASKED_SECRET);
        (0, vitest_1.expect)(headers[1].value).toBe('foobar');
        (0, configuration_js_1.unmaskSecrets)(restApiIntegrationDatasourceConfiguration, index_js_1.RestApiIntegrationPlugin, restoreConfiguration);
        headers = restApiIntegrationDatasourceConfiguration.headers;
        (0, vitest_1.expect)(headers[0].value).toBe('foobar');
    });
    (0, vitest_1.test)('can mask and unmask password input list secrets', () => {
        const postgresDatasourceConfiguration = {
            authentication: {
                username: 'foobar',
                password: 'baz'
            }
        };
        const restoreConfiguration = (0, lodash_1.cloneDeep)(postgresDatasourceConfiguration);
        (0, configuration_js_1.maskSecrets)(postgresDatasourceConfiguration, index_js_1.PostgresPlugin);
        (0, vitest_1.expect)(postgresDatasourceConfiguration.authentication?.password).toBe(configuration_js_1.MASKED_SECRET);
        (0, vitest_1.expect)(postgresDatasourceConfiguration.authentication?.username).toBe('foobar');
        (0, configuration_js_1.unmaskSecrets)(postgresDatasourceConfiguration, index_js_1.PostgresPlugin, restoreConfiguration);
        (0, vitest_1.expect)(postgresDatasourceConfiguration.authentication?.password).toBe('baz');
    });
});
//# sourceMappingURL=configuration.test.js.map