Skip to content

Commit

Permalink
Ema 145 security issues fix (#63)
Browse files Browse the repository at this point in the history
Co-authored-by: Sanyi <sandor.deli-szabo@itgcommerce.com>
Co-authored-by: bognar.tamas <tamas.bognar@itgcommerce.com>
  • Loading branch information
3 people authored Jul 5, 2024
1 parent f5f5326 commit fa05570
Show file tree
Hide file tree
Showing 29 changed files with 195 additions and 156 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
permissions:
contents: "read"
strategy:
max-parallel: 2
max-parallel: 1
fail-fast: false
matrix:
magento-versions:
["2.3.3ce", "2.3.5ce", "2.4.0ce", "2.4.2ce", "2.4.4ce", "2.4.6ce"]
["2.3.5ce", "2.4.0ce", "2.4.2ce", "2.4.4ce", "2.4.6ce"]
steps:
- name: Extract branch name
shell: bash
Expand Down Expand Up @@ -48,24 +48,31 @@ jobs:
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-compose-plugin -y
- name: Build mage_node image
shell: bash
run: |
cd magento2-extension/dev
docker build -f testv2/tools/docker/Dockerfile-mage-node --build-arg NPM_TOKEN=$NPM_TOKEN -t "mage_node" .
env:
NPM_TOKEN: ${{ secrets.GITLAB_TOKEN }}
- name: Run unittest
shell: bash
run: |
cd magento2-extension
bash dev/testv2/tools/scripts/run-unit.sh
env:
VERSION: ${{ matrix.magento-versions }}
NPM_TOKEN: ${{ secrets.NPM_DEPLOYER_TOKEN }}
NPM_TOKEN: ${{ secrets.GITLAB_TOKEN }}
e2e-tests:
runs-on: github-actions-runner-emarsys
permissions:
contents: "read"
strategy:
max-parallel: 2
max-parallel: 1
fail-fast: false
matrix:
magento-versions:
["2.3.3ce", "2.3.5ce", "2.4.0ce", "2.4.2ce", "2.4.4ce", "2.4.6ce"]
["2.3.5ce", "2.4.0ce", "2.4.2ce", "2.4.4ce", "2.4.6ce"]
steps:
- name: Extract branch name
shell: bash
Expand Down Expand Up @@ -97,11 +104,18 @@ jobs:
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-compose-plugin -y
- name: Build mage_node image
shell: bash
run: |
cd magento2-extension/dev
docker build -f testv2/tools/docker/Dockerfile-mage-node --build-arg NPM_TOKEN=$NPM_TOKEN -t "mage_node" .
env:
NPM_TOKEN: ${{ secrets.GITLAB_TOKEN }}
- name: Run e2stest
shell: bash
run: |
cd magento2-extension
bash dev/testv2/tools/scripts/run-e2e.sh
env:
VERSION: ${{ matrix.magento-versions }}
NPM_TOKEN: ${{ secrets.NPM_DEPLOYER_TOKEN }}
NPM_TOKEN: ${{ secrets.GITLAB_TOKEN }}
1 change: 1 addition & 0 deletions dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,4 @@ git push -f --tags
## Update Cypress
* Update the version in `package.json`
* Run `make build-cypress VERSION=new-version` from project root

3 changes: 3 additions & 0 deletions dev/testv2/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
always-auth=true
@itg-commerce:registry=https://gitlab.itg.cloud/api/v4/projects/295/packages/npm/
//gitlab.itg.cloud/api/v4/projects/295/packages/npm/:_authToken=${NPM_TOKEN}
22 changes: 11 additions & 11 deletions dev/testv2/attributes/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const websiteId = 1;

const mapAttributes = attributes => attributes.map(attribute => ({ code: attribute.code, name: attribute.name }));

describe('Attributes endpoint', function() {
afterEach(async function() {});
describe('Attributes endpoint', function () {
afterEach(async function () {});

after(async function() {});
after(async function () {});

describe('get', function() {
it('should fetch attributes including extra fields for customer', async function() {
describe('get', function () {
it('should fetch attributes including extra fields for customer', async function () {
const { attributes } = await this.magentoApi.execute('attributes', 'get', { type: 'customer' });
const mappedAttributes = mapAttributes(attributes);

Expand All @@ -29,7 +29,7 @@ describe('Attributes endpoint', function() {
}
});

it('should fetch attributes including extra fields for customer_address', async function() {
it('should fetch attributes including extra fields for customer_address', async function () {
const { attributes } = await this.magentoApi.execute('attributes', 'get', { type: 'customer_address' });
const mappedAttributes = mapAttributes(attributes);

Expand All @@ -40,7 +40,7 @@ describe('Attributes endpoint', function() {
}
});

it('should fetch attributes including extra fields for products', async function() {
it('should fetch attributes including extra fields for products', async function () {
const { attributes } = await this.magentoApi.execute('attributes', 'get', { type: 'product' });
const mappedAttributes = attributes.map(attribute => {
return { code: attribute.code, name: attribute.name };
Expand All @@ -58,8 +58,8 @@ describe('Attributes endpoint', function() {
});
});

describe('set', function() {
it('should modify customer attribute config for website', async function() {
describe('set', function () {
it('should modify customer attribute config for website', async function () {
await this.magentoApi.execute('attributes', 'set', {
websiteId,
type: 'customer',
Expand All @@ -76,7 +76,7 @@ describe('Attributes endpoint', function() {
expect(config.value).to.equal(JSON.stringify(['hello_attribute']));
});

it('should modify customer_address attribute config for website', async function() {
it('should modify customer_address attribute config for website', async function () {
await this.magentoApi.execute('attributes', 'set', {
websiteId,
type: 'customer_address',
Expand All @@ -93,7 +93,7 @@ describe('Attributes endpoint', function() {
expect(config.value).to.equal(JSON.stringify(['hello_attribute']));
});

it('should modify product attribute config for website', async function() {
it('should modify product attribute config for website', async function () {
await this.magentoApi.execute('attributes', 'set', {
websiteId: 0,
type: 'product',
Expand Down
12 changes: 6 additions & 6 deletions dev/testv2/config/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ const dbKeys = {
};

const websiteId = 1;
describe('Config endpoint', function() {
before(async function() {
describe('Config endpoint', function () {
before(async function () {
await this.turnOffEverySetting(1);
});

afterEach(async function() {
afterEach(async function () {
await this.turnOffEverySetting(1);
});

after(async function() {
after(async function () {
await this.setDefaultStoreSettings();
});

describe('set', function() {
it('should modify config values for website', async function() {
describe('set', function () {
it('should modify config values for website', async function () {
await this.magentoApi.execute('config', 'set', {
websiteId,
config: fullConfig
Expand Down
10 changes: 5 additions & 5 deletions dev/testv2/customers/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const customers = [
}
];

describe('Customers endpoint', function() {
before(async function() {
describe('Customers endpoint', function () {
before(async function () {
await this.magentoApi.execute('attributes', 'set', {
websiteId: 1,
type: 'customer',
Expand All @@ -35,7 +35,7 @@ describe('Customers endpoint', function() {
}
});

after(async function() {
after(async function () {
await this.magentoApi.execute('attributes', 'set', {
websiteId: 1,
type: 'customer',
Expand All @@ -44,7 +44,7 @@ describe('Customers endpoint', function() {
await this.db.raw(`DELETE FROM ${this.getTableName('customer_entity')} where email like "%@customer.net"`);
});

it('returns customers according to page and page_size inlcuding last_page', async function() {
it('returns customers according to page and page_size inlcuding last_page', async function () {
const page = 1;
const limit = 2;

Expand All @@ -66,7 +66,7 @@ describe('Customers endpoint', function() {
expect(customer).to.have.property('shipping_address');
});

it('returns extra_fields for customers', async function() {
it('returns extra_fields for customers', async function () {
const page = 1;
const limit = 1;

Expand Down
6 changes: 3 additions & 3 deletions dev/testv2/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const { defineConfig } = require('cypress');
module.exports = defineConfig({
video: false,
trashAssetsBeforeRuns: false,
requestTimeout: 30000,
defaultCommandTimeout: 30000,
pageLoadTimeout: 30000,
requestTimeout: 120000,
defaultCommandTimeout: 120000,
pageLoadTimeout: 120000,
blockHosts: ['*snippet.url.com', '*scarabresearch.com'],
env: {
snippetUrl: 'http://snippet.url.com/main.js'
Expand Down
20 changes: 10 additions & 10 deletions dev/testv2/cypress/integration/default-behaviour.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

describe('Default behaviour with everything turned off', function() {
describe('Default behaviour with everything turned off', function () {
before(() => {
cy.task('setConfig', {});
});
Expand All @@ -14,13 +14,13 @@ describe('Default behaviour with everything turned off', function() {
cy.task('clearMails');
});

context('MarketingEvents - Customer', function() {
context('MarketingEvents - Customer', function () {
afterEach(() => {
cy.task('clearEvents');
cy.logout();
});

it('should not create customer_password_reset event', function() {
it('should not create customer_password_reset event', function () {
const newPassword = 'newPassword1';

cy.loginWithCustomer(this.defaultCustomer);
Expand All @@ -36,7 +36,7 @@ describe('Default behaviour with everything turned off', function() {
});
});

it('should not create customer_email_changed event', function() {
it('should not create customer_email_changed event', function () {
const oldEmail = this.defaultCustomer.email;
const newEmail = 'cypress2@default.com';

Expand All @@ -52,7 +52,7 @@ describe('Default behaviour with everything turned off', function() {
});
});

it('should not create customer_email_and_password_changed event', function() {
it('should not create customer_email_and_password_changed event', function () {
const newEmail = 'cypress5@default.com';
const newPassword = 'newPassword4';

Expand All @@ -70,7 +70,7 @@ describe('Default behaviour with everything turned off', function() {
});
});

context('MarketingEvents - Subscription', function() {
context('MarketingEvents - Subscription', function () {
const unsubscribe = email => {
cy.task('getSubscription', email).then(subscription => {
cy.visit(`/newsletter/subscriber/unsubscribe?id=${subscription.subscriber_id}\
Expand All @@ -84,8 +84,8 @@ describe('Default behaviour with everything turned off', function() {
cy.get('.action.subscribe.primary[type="submit"]').click();
};

context('guest with double optin off', function() {
it('should not create subscription events', function() {
context('guest with double optin off', function () {
it('should not create subscription events', function () {
const guestEmail = 'no-event.doptin-off@guest-cypress.com';
subscribe(guestEmail);

Expand All @@ -110,7 +110,7 @@ describe('Default behaviour with everything turned off', function() {
});
});

context('guest with double optin on', function() {
context('guest with double optin on', function () {
before(() => {
cy.task('setDoubleOptin', true);
cy.task('flushMagentoCache');
Expand All @@ -120,7 +120,7 @@ describe('Default behaviour with everything turned off', function() {
cy.task('setDoubleOptin', false);
});

it('should not create subscription events', function() {
it('should not create subscription events', function () {
const guestEmail = 'no-event.doptin-on@guest-cypress.com';
subscribe(guestEmail);

Expand Down
18 changes: 9 additions & 9 deletions dev/testv2/cypress/integration/marketing-events-customer.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

describe('Marketing Events', function() {
describe('Marketing Events', function () {
beforeEach(() => {
cy.task('clearMails');
cy.task('getDefaultCustomer').as('defaultCustomer');
Expand All @@ -10,7 +10,7 @@ describe('Marketing Events', function() {
cy.logout();
});

context('magentoSendEmails config is disabled', function() {
context('magentoSendEmails config is disabled', function () {
before(() => {
cy.task('setConfig', {
collectMarketingEvents: 'enabled',
Expand All @@ -19,7 +19,7 @@ describe('Marketing Events', function() {
cy.task('clearEvents');
});

it('should create customer_password_reset event', function() {
it('should create customer_password_reset event', function () {
const newPassword = 'newPassword2';

cy.loginWithCustomer(this.defaultCustomer);
Expand All @@ -36,7 +36,7 @@ describe('Marketing Events', function() {
});
});

it('should create customer_email_changed event', function() {
it('should create customer_email_changed event', function () {
const newEmail = 'cypress3@default.com';

cy.loginWithCustomer(this.defaultCustomer);
Expand All @@ -53,7 +53,7 @@ describe('Marketing Events', function() {
});
});

it('should create customer_email_and_password_changed event', function() {
it('should create customer_email_and_password_changed event', function () {
const newEmail = 'cypress4@default.com';
const newPassword = 'newPassword3';

Expand All @@ -72,7 +72,7 @@ describe('Marketing Events', function() {
});
});

context('magentoSendEmails config is enabled', function() {
context('magentoSendEmails config is enabled', function () {
before(() => {
cy.task('setConfig', {
collectMarketingEvents: 'enabled',
Expand All @@ -81,7 +81,7 @@ describe('Marketing Events', function() {
cy.task('clearEvents');
});

it('should create customer_password_reset event', function() {
it('should create customer_password_reset event', function () {
const newPassword = 'newPassword2';

cy.loginWithCustomer(this.defaultCustomer);
Expand All @@ -98,7 +98,7 @@ describe('Marketing Events', function() {
});
});

it('should create customer_email_changed event', function() {
it('should create customer_email_changed event', function () {
const oldEmail = this.defaultCustomer.email;
const newEmail = 'cypress3@default.com';

Expand All @@ -116,7 +116,7 @@ describe('Marketing Events', function() {
});
});

it('should create customer_email_and_password_changed event', function() {
it('should create customer_email_and_password_changed event', function () {
const oldEmail = this.defaultCustomer.email;
const newEmail = 'cypress4@default.com';
const newPassword = 'newPassword3';
Expand Down
Loading

0 comments on commit fa05570

Please sign in to comment.