Skip to content

Commit

Permalink
feat: throw a warning if require-adobe-auth is set for a non-web acti…
Browse files Browse the repository at this point in the history
…on (#171)


---------

Co-authored-by: Shazron Abdullah <36107+shazron@users.noreply.github.com>
  • Loading branch information
MichaelGoberling and shazron authored Jan 23, 2024
1 parent 5d351ed commit 8b25c82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,10 +1088,16 @@ function rewriteActionsWithAdobeAuthAnnotation (packages, deploymentPackages) {
const isWeb = checkWebFlags(thisAction.web)['web-export']
const isRaw = checkWebFlags(thisAction.web)['raw-http'] || checkWebFlags(thisAction['web-export'])['raw-http']

// check if the annotation is defined AND the action is a web action
if ((isWeb || isWebExport) && thisAction.annotations && thisAction.annotations[ADOBE_AUTH_ANNOTATION]) {
// check if the annotation is defined
if (thisAction.annotations?.[ADOBE_AUTH_ANNOTATION]) {
aioLogger.debug(`found annotation '${ADOBE_AUTH_ANNOTATION}' in action '${key}/${actionName}', cli env = ${env}`)

// check if the action is a web action
if (!(isWeb || isWebExport)) {
aioLogger.warn(`The action '${key}/${actionName}' is not a web action, the annotation '${ADOBE_AUTH_ANNOTATION}' will be ignored.`)
return
}

// 1. rename the action
const renamedAction = REWRITE_ACTION_PREFIX + actionName
/* istanbul ignore if */
Expand Down
2 changes: 2 additions & 0 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,8 @@ describe('processPackage', () => {
let packagesCopy = cloneDeep(basicPackage)
delete packagesCopy.pkg1.actions.theaction.web
res = utils.processPackage(packagesCopy, {}, {}, {}, false, { apihost: 'https://adobeioruntime.net' })
const loggerSpy = jest.spyOn(aioLogger, 'warn')
expect(loggerSpy).toHaveBeenLastCalledWith('The action \'pkg1/theaction\' is not a web action, the annotation \'require-adobe-auth\' will be ignored.')
expect(res).toEqual({
actions: [{
name: 'pkg1/theaction',
Expand Down

0 comments on commit 8b25c82

Please sign in to comment.