From f7e48e0f3fd6528373352616913e4473dd877abe Mon Sep 17 00:00:00 2001 From: Demian Leon Florin <74616552+florind12@users.noreply.github.com> Date: Thu, 17 Mar 2022 21:20:38 +0200 Subject: [PATCH] fix: ACNA-1493 - pick up logs from __secure actions (#515) --- src/commands/app/logs.js | 14 +++++++++++--- test/commands/app/logs.test.js | 8 ++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/commands/app/logs.js b/src/commands/app/logs.js index c873e635..6929ea58 100644 --- a/src/commands/app/logs.js +++ b/src/commands/app/logs.js @@ -16,15 +16,19 @@ const { wrapError } = require('../../lib/app-helper') const rtLib = require('@adobe/aio-lib-runtime') const LogForwarding = require('../../lib/log-forwarding') +const SECURED = 'require-adobe-auth' + class Logs extends BaseCommand { _processEachAction (fullConfig, processFn) { + const isSecuredAction = (pkg, aName) => pkg && pkg.actions && pkg.actions[aName] && + pkg.actions[aName].annotations && pkg.actions[aName].annotations[SECURED] + Object.entries(fullConfig.all).forEach(([, config]) => { Object.entries(config.manifest.full.packages).forEach(([packageName, pkg]) => { // handle default package packageName = packageName.replace(/__APP_PACKAGE__/g, config.ow.package) - Object.keys(pkg.actions).forEach((aName) => { - processFn(packageName, aName) + processFn(packageName, aName, isSecuredAction(pkg, aName)) }) }) }) @@ -80,7 +84,11 @@ class Logs extends BaseCommand { } }) } else { - this._processEachAction(fullConfig, (packageName, aName) => { + this._processEachAction(fullConfig, (packageName, aName, isSecured) => { + if (isSecured) { + const securedAName = '__secured_' + aName + filterActions.push(`${packageName}/${securedAName}`) + } filterActions.push(`${packageName}/${aName}`) }) } diff --git a/test/commands/app/logs.test.js b/test/commands/app/logs.test.js index 79da2b72..4492fa29 100644 --- a/test/commands/app/logs.test.js +++ b/test/commands/app/logs.test.js @@ -86,7 +86,7 @@ describe('run', () => { await command.run() const ow = owConfig() - const actionList = ['legacy-app-1.0.0/action', 'legacy-app-1.0.0/action-zip'] + const actionList = ['legacy-app-1.0.0/__secured_action', 'legacy-app-1.0.0/action', 'legacy-app-1.0.0/action-zip'] expect(printActionLogs).toHaveBeenCalledWith({ ow }, command.log, 1, actionList, false, false) expect(command.error).not.toHaveBeenCalled() }) @@ -108,7 +108,7 @@ describe('run', () => { await command.run() expect(command.log).toHaveBeenCalledWith(expect.stringContaining('using --limit=1')) const ow = owConfig() - const actionList = ['legacy-app-1.0.0/action', 'legacy-app-1.0.0/action-zip'] + const actionList = ['legacy-app-1.0.0/__secured_action', 'legacy-app-1.0.0/action', 'legacy-app-1.0.0/action-zip'] expect(printActionLogs).toHaveBeenCalledWith({ ow }, command.log, 1, actionList, false, false) expect(command.error).not.toHaveBeenCalled() }) @@ -120,7 +120,7 @@ describe('run', () => { await command.run() expect(command.log).toHaveBeenCalledWith(expect.stringContaining('using --limit=50')) const ow = owConfig() - const actionList = ['legacy-app-1.0.0/action', 'legacy-app-1.0.0/action-zip'] + const actionList = ['legacy-app-1.0.0/__secured_action', 'legacy-app-1.0.0/action', 'legacy-app-1.0.0/action-zip'] expect(printActionLogs).toHaveBeenCalledWith({ ow }, command.log, 50, actionList, false, false) expect(command.error).not.toHaveBeenCalled() }) @@ -131,7 +131,7 @@ describe('run', () => { await command.run() const ow = owConfig() - const actionList = ['legacy-app-1.0.0/action', 'legacy-app-1.0.0/action-zip'] + const actionList = ['legacy-app-1.0.0/__secured_action', 'legacy-app-1.0.0/action', 'legacy-app-1.0.0/action-zip'] expect(printActionLogs).toHaveBeenCalledWith({ ow }, command.log, 32, actionList, false, false) expect(command.error).not.toHaveBeenCalled() })