Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for multiple actions using the require-adobe-auth annotation in the same package #137

Merged
merged 1 commit into from
Mar 17, 2020

Conversation

moritzraho
Copy link
Member

Description

The current implementation of require-adobe-auth is not working when multiple actions in the same action use the annotation.
This is a fix for it using lodash.clonedeep.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@moritzraho moritzraho changed the title fix for multiple secured actions in same package fix for multiple actions using the require-adobe-auth annotation in the same package Mar 17, 2020
@codecov
Copy link

codecov bot commented Mar 17, 2020

Codecov Report

Merging #137 into master will not change coverage by %.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #137   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           57        57           
  Lines         1809      1809           
  Branches       325       326    +1     
=========================================
  Hits          1809      1809           
Impacted Files Coverage Δ
src/runtime-helpers.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c73737f...207ccd8. Read the comment docs.

@@ -423,74 +424,61 @@ function rewriteActionsWithAdobeAuthAnnotation (packages, deploymentPackages) {
const REWRITE_ACTION_PREFIX = '__secured_'

// avoid side effects, do not modify input packages
const newPackages = { ...packages }
const newDeploymentPackages = { ...deploymentPackages }
const newPackages = cloneDeep(packages)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going with clone deep adds a (small) dependency but makes the implementation clearer and less error prone

// unlikely
throw new Error(`Failed to rename the action '${key}/${actionName}' to '${key}/${renamedAction}': an action with the same name exists already.`)
}

// copy actions to the new package and move the action content to the new key
newPackages[key]['actions'] = {
...packages[key]['actions'],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here was the problem as we were overriding any previous action rewrites

@moritzraho moritzraho requested review from purplecabbage and removed request for purplecabbage March 17, 2020 08:57
@moritzraho moritzraho merged commit 539a1de into adobe:master Mar 17, 2020
@moritzraho moritzraho deleted the fix-adobe-annotation branch March 17, 2020 09:14
bhageena pushed a commit to bhageena/aio-cli-plugin-runtime that referenced this pull request Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants