Skip to content

Commit

Permalink
fix: ACNA-1493 - pick up logs from __secure actions (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
florind-ens authored Mar 17, 2022
1 parent 1c0363d commit f7e48e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/commands/app/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
})
})
Expand Down Expand Up @@ -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}`)
})
}
Expand Down
8 changes: 4 additions & 4 deletions test/commands/app/logs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand All @@ -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()
})
Expand All @@ -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()
})
Expand All @@ -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()
})
Expand Down

0 comments on commit f7e48e0

Please sign in to comment.