"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const tape_1 = __importDefault(require("tape-promise/tape"));
const uuid_1 = require("uuid");
const cactus_common_1 = require("@hyperledger/cactus-common");
const public_api_1 = require("../../../../main/typescript/public-api");
const public_api_2 = require("../../../../main/typescript/public-api");
tape_1.default("Generates valid example config for the API server", async (t) => {
    const pluginsPath = path_1.default.join(__dirname, "../../../../../../", // walk back up to the project root
    ".tmp/test/test-cmd-api-server/config-service-example-config-validity_test/", // the dir path from the root
    uuid_1.v4());
    const pluginManagerOptionsJson = JSON.stringify({ pluginsPath });
    const configService = new public_api_2.ConfigService();
    t.ok(configService, "Instantiated ConfigService truthy OK");
    const exampleConfig = configService.newExampleConfig();
    t.ok(exampleConfig, "configService.newExampleConfig() truthy OK");
    exampleConfig.pluginManagerOptionsJson = pluginManagerOptionsJson;
    // FIXME - this hack should not be necessary, we need to re-think how we
    // do configuration parsing. The convict library may not be the path forward.
    exampleConfig.authorizationConfigJson = JSON.stringify(exampleConfig.authorizationConfigJson);
    exampleConfig.configFile = "";
    exampleConfig.apiPort = 0;
    exampleConfig.cockpitPort = 0;
    const convictConfig = configService.newExampleConfigConvict(exampleConfig);
    t.ok(convictConfig, "configService.newExampleConfigConvict() truthy OK");
    const config = convictConfig.getProperties();
    t.ok(config, "convictConfig.getProperties() truthy OK");
    cactus_common_1.LoggerProvider.setLogLevel(config.logLevel);
    const apiServer = new public_api_1.ApiServer({ config });
    await apiServer.start();
    tape_1.default.onFinish(() => apiServer.shutdown());
    t.end();
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLXNlcnZpY2UtZXhhbXBsZS1jb25maWctdmFsaWRpdHkudGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL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