diff --git a/src/abstract-server.cmd.js b/src/abstract-server.cmd.js index e2cebe1a7..adbfc7ad3 100644 --- a/src/abstract-server.cmd.js +++ b/src/abstract-server.cmd.js @@ -84,7 +84,7 @@ export class AbstractServerCommand extends AbstractCommand { this.emit('stopped', this); } - async initSeverOptions() { + async initServerOptions() { if (this._cache) { await fse.ensureDir(this._cache); this._project.withCacheDirectory(this._cache); diff --git a/src/import.cmd.js b/src/import.cmd.js index ffe574746..0605eeea4 100644 --- a/src/import.cmd.js +++ b/src/import.cmd.js @@ -88,7 +88,7 @@ export default class ImportCommand extends AbstractServerCommand { this.log.info(chalk`{yellow /_/ v${pkgJson.version}}`); this.log.info(''); - await this.initSeverOptions(); + await this.initServerOptions(); if (!this._skipUI) { await this.setupImporterUI(); diff --git a/src/up.cmd.js b/src/up.cmd.js index f46988aef..a0e3a2178 100644 --- a/src/up.cmd.js +++ b/src/up.cmd.js @@ -35,6 +35,11 @@ export default class UpCommand extends AbstractServerCommand { return this; } + withAllowUnauthorized(value) { + this._allowUnauthorized = value; + return this; + } + async doStop() { await super.doStop(); if (this._watcher) { @@ -79,7 +84,7 @@ export default class UpCommand extends AbstractServerCommand { await this.verifyUrl(this._gitUrl, ref); } this._project.withProxyUrl(this._url); - await this.initSeverOptions(); + await this.initServerOptions(); try { await this._project.init(); @@ -111,7 +116,7 @@ export default class UpCommand extends AbstractServerCommand { // "testProperty": "header"; // } const configUrl = `https://admin.hlx.page/sidekick/${gitUrl.owner}/${gitUrl.repo}/main/config.json`; - const configResp = await getFetch()(configUrl); + const configResp = await getFetch(this._allowUnauthorized)(configUrl); let previewHostBase = 'hlx.page'; if (configResp.ok) { // this is best effort for now diff --git a/src/up.js b/src/up.js index fc443cde8..f68bf6c85 100644 --- a/src/up.js +++ b/src/up.js @@ -92,6 +92,12 @@ export default function up() { type: 'string', }) .group(['url', 'livereload', 'no-livereload', 'open', 'no-open', 'print-index', 'cache'], 'AEM Options') + .option('allow-unauthorized', { + alias: 'allowUnauthorized', + describe: 'Whether to allow unauthorized access to server', + type: 'boolean', + default: false, + }) .help(); }, @@ -112,6 +118,7 @@ export default function up() { .withLiveReload(argv.livereload) .withUrl(argv.url) .withPrintIndex(argv.printIndex) + .withAllowUnauthorized(argv.allowUnauthorized) .withKill(argv.stopOther) .withCache(argv.alphaCache) .run(); diff --git a/test/up-cli.test.js b/test/up-cli.test.js index 1e0d94a9d..2341fde90 100644 --- a/test/up-cli.test.js +++ b/test/up-cli.test.js @@ -42,6 +42,7 @@ describe('hlx up', () => { mockUp.withBindAddr.returnsThis(); mockUp.withUrl.returnsThis(); mockUp.withPrintIndex.returnsThis(); + mockUp.withAllowUnauthorized.returnsThis(); mockUp.withKill.returnsThis(); mockUp.withCache.returnsThis(); mockUp.run.returnsThis(); @@ -121,6 +122,12 @@ describe('hlx up', () => { sinon.assert.calledOnce(mockUp.run); }); + it('hlx up can enable allow unauthorized', async () => { + await cli.run(['up', '--allow-unauthorized']); + sinon.assert.calledWith(mockUp.withAllowUnauthorized, true); + sinon.assert.calledOnce(mockUp.run); + }); + it('hlx up can enable cache', async () => { await cli.run(['up', '--alpha-cache', '.cache/']); sinon.assert.calledWith(mockUp.withCache, '.cache/');