Skip to content

Commit 8b25c82

Browse files
feat: throw a warning if require-adobe-auth is set for a non-web action (#171)
--------- Co-authored-by: Shazron Abdullah <36107+shazron@users.noreply.github.com>
1 parent 5d351ed commit 8b25c82

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/utils.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,10 +1088,16 @@ function rewriteActionsWithAdobeAuthAnnotation (packages, deploymentPackages) {
10881088
const isWeb = checkWebFlags(thisAction.web)['web-export']
10891089
const isRaw = checkWebFlags(thisAction.web)['raw-http'] || checkWebFlags(thisAction['web-export'])['raw-http']
10901090

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

1095+
// check if the action is a web action
1096+
if (!(isWeb || isWebExport)) {
1097+
aioLogger.warn(`The action '${key}/${actionName}' is not a web action, the annotation '${ADOBE_AUTH_ANNOTATION}' will be ignored.`)
1098+
return
1099+
}
1100+
10951101
// 1. rename the action
10961102
const renamedAction = REWRITE_ACTION_PREFIX + actionName
10971103
/* istanbul ignore if */

test/utils.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,8 @@ describe('processPackage', () => {
987987
let packagesCopy = cloneDeep(basicPackage)
988988
delete packagesCopy.pkg1.actions.theaction.web
989989
res = utils.processPackage(packagesCopy, {}, {}, {}, false, { apihost: 'https://adobeioruntime.net' })
990+
const loggerSpy = jest.spyOn(aioLogger, 'warn')
991+
expect(loggerSpy).toHaveBeenLastCalledWith('The action \'pkg1/theaction\' is not a web action, the annotation \'require-adobe-auth\' will be ignored.')
990992
expect(res).toEqual({
991993
actions: [{
992994
name: 'pkg1/theaction',

0 commit comments

Comments
 (0)