Skip to content

Patched file for MageMojo Google session collection when Content Security Policies (CSP) enabled or enforced.

License

OSL-3.0 and 2 other licenses found

Licenses found

OSL-3.0
LICENSE.txt
Unknown
COPYING.txt
AFL-3.0
LICENSE_AFL.txt
Notifications You must be signed in to change notification settings

practik/Magento2-MM-CSP-fix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Magento2-MM-CSP-fix

Patched file for MageMojo Google session collection when Content Security Policies (CSP) enabled or enforced.

Basically here we follow https://devdocs.magento.com/guides/v2.3/comp-mgr/patching/composer.html official M2 DevDocs guidelines.

  1. Open your command line application and navigate to your project directory.
  2. Add the cweagans/composer-patches plugin to the composer.json file.

composer require cweagans/composer-patches 3) Edit the composer.json file and add the following section to specify:

    "patches": {
    "magento/module-google-adwords": {
          "INFRA-123456: MageMojo CSP fix to whitelist googletagmanager.com domain": "https://github.com/magemojo/Magento2-MM-CSP-fix/commit/5faa8f1619e4f6b600ce4fedb9a54d7fe5a4debb.patch"
      }
  }

Text is added in the "extra": { section, with following content:

Module: "magento/module-google-adwords" ← That’s the Magento 2 Core module we are patching

Title: We link this with internal STRAT or INFRA tasks.

URL to patch: "https://github.com/magemojo/Magento2-MM-CSP-fix/pull/2/commits/5faa8f1619e4f6b600ce4fedb9a54d7fe5a4debb " ← That’s link from above and our demo repository.

If a patch affects multiple modules, you must create multiple patch files targeting multiple modules.

  1. Apply the patch. Use the -v option only if you want to see debugging information. composer -v install

  2. Update the composer.lock file. The lock file tracks which patches have been applied to each Composer package in an object. composer update --lock

  • Everything ready!!! Lucky each Magento 2 core module comes with integration/unit tests ready. For the end let’s run the PHP Unit test against the Core module we just patched with changes.

https://devdocs.magento.com/guides/v2.4/test/unit/unit_test_execution_cli.html

Edit dev/tests/unit/phpunit.xml.dist file and under just keep following:

../../../vendor/magento/module-google-adwords/Test/Unit Remove everything else since we are running test only against one specific Magento 2 core module.

Execute following: ./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist vendor/magento/module-google-adwords/Test/Unit

About

Patched file for MageMojo Google session collection when Content Security Policies (CSP) enabled or enforced.

Resources

License

OSL-3.0 and 2 other licenses found

Licenses found

OSL-3.0
LICENSE.txt
Unknown
COPYING.txt
AFL-3.0
LICENSE_AFL.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 67.3%
  • HTML 17.4%
  • JavaScript 7.8%
  • Less 5.8%
  • CSS 1.7%