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

[WebApi test] Disallow setting extension attributes as data array #27338

Conversation

amenk
Copy link
Contributor

@amenk amenk commented Mar 18, 2020

Fixes #26682
While working on fix for the issue #26682 - fix already was delivered in fcd1b58#diff-e2b9d1a5f4b9f3503a2f8dd072bc2d8aR360, but it contains only unit tests, while this PR contained also web api tests, that better fits for such cases.

We decided to revert all changes related to the fix and deliver only tests as part of this PR.

@m2-assistant
Copy link

m2-assistant bot commented Mar 18, 2020

Hi @amenk. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@lenaorobei
Copy link
Contributor

@amenk I assume we can close this PR?

@amenk
Copy link
Contributor Author

amenk commented Mar 30, 2020

I have to closer check the results. Actually it seems to be a valid solution to the problem in the linked issue.

@maximbaibakov
Copy link

Looks like valid solution.
Can we get this merged into 2.3.x as well?

@amenk
Copy link
Contributor Author

amenk commented Apr 8, 2020

I have no clue why functional tests fail for B2B and EE -> rerunning

@amenk
Copy link
Contributor Author

amenk commented Apr 16, 2020

Functional tests EE is green now without any change.
Functional Tests B2B is still red, but https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/27338/73c167e6c2bcafd4451bd73a67d6ab3f/Functional/allure-report-b2b/index.html# does not indicate any errors, so I am rerunning Functional B2B once again.

@ihor-sviziev ihor-sviziev added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Apr 28, 2020
Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

Hi @amenk ,
Your changes looks good to me. Could you cover them with any type of tests in order to prevent appearing this issue in future?
I think API test there is the most suitable.

Note: failing functional tests seems to me as false positive, no need to fix them

@amenk
Copy link
Contributor Author

amenk commented Apr 28, 2020

@ihor-sviziev
Thanks for your feedback.

I might not have the time in the near future to cover this with tests, I am happy if someone can take over.

@ihor-sviziev ihor-sviziev added help wanted Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Apr 28, 2020
@engcom-Kilo engcom-Kilo self-assigned this Apr 30, 2020
@engcom-Kilo
Copy link
Contributor

engcom-Kilo commented Apr 30, 2020

@ihor-sviziev
Exist api-functional test
dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationTest.php::testEstimateByExtendedAddress

can be related to this Pull Request

@ihor-sviziev
Copy link
Contributor

@engcom-Kilo good test example! Thank you.
@amenk maybe you could copy just duplicate that test case and a bit adjust it? I think it shouldn’t be really hard

@amenk
Copy link
Contributor Author

amenk commented Apr 30, 2020

@engcom-Kilo thank you
@ihor-sviziev woudn't that mean I have to do the full extension attribute setup during the test?

@ihor-sviziev
Copy link
Contributor

@amenk as I understood - issue appears when you have extension attribute in the request, not in the model they you loaded. In this case it seems to me that declaring attribute is not mandatory. Let me know if I’m wrong

@amenk
Copy link
Contributor Author

amenk commented Apr 30, 2020

unfortunately not,



            $data = [
                AddressInterface::KEY_ID => (int)$address->getId(),
                AddressInterface::KEY_REGION => $address->getRegion(),
                AddressInterface::KEY_REGION_ID => $address->getRegionId(),
                AddressInterface::KEY_REGION_CODE => $address->getRegionCode(),
                AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(),
                AddressInterface::KEY_STREET => $address->getStreet(),
                AddressInterface::KEY_COMPANY => $address->getCompany(),
                AddressInterface::KEY_TELEPHONE => $address->getTelephone(),
                AddressInterface::KEY_POSTCODE => $address->getPostcode(),
                AddressInterface::KEY_CITY => $address->getCity(),
                AddressInterface::KEY_FIRSTNAME => $address->getFirstname(),
                AddressInterface::KEY_LASTNAME => $address->getLastname(),
                AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(),
                AddressInterface::KEY_EMAIL => $address->getEmail(),
                AddressInterface::SAME_AS_BILLING => $address->getSameAsBilling(),
                AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(),
                AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook(),

                'custom_attributes' => [
                    [
                    'attribute_code' =>  'company2',
                    'value' => 'ACME Division',
                    ],
                    [
                    'attribute_code' =>  'company3',
                    'value' => 'ACME Subdivision',
                    ]
                ]
            ];

Test does not fail, even my fix is not in place

@amenk
Copy link
Contributor Author

amenk commented Apr 30, 2020

Also we better would make the test for a registered user...

@engcom-Kilo
Copy link
Contributor

@magento run all tests

@ihor-sviziev
Copy link
Contributor

@engcom-Kilo how come earlier these files were needed and now - no?

@engcom-Kilo
Copy link
Contributor

@engcom-Kilo how come earlier these files were needed and now - no?

Checked again,
and see that these files not working for test.

These sample files only for app/code/ .
Unused files.

Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

✔ Approved.

Failing tests looks not related to changes form this PR.

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-7563 has been created to process this Pull Request

@ihor-sviziev ihor-sviziev changed the title #26682 Disallow setting extension attributes as data array Add web api test for Disallow setting extension attributes as data array Jun 5, 2020
@ihor-sviziev ihor-sviziev changed the title Add web api test for Disallow setting extension attributes as data array [WebApi test] Disallow setting extension attributes as data array Jun 5, 2020
@engcom-Alfa
Copy link
Contributor

QA not applicable

@slavvka slavvka added the Priority: P3 May be fixed according to the position in the backlog. label Jun 12, 2020
@slavvka slavvka added this to the 2.4.1 milestone Jun 12, 2020
@magento-engcom-team magento-engcom-team merged commit 1a8cde2 into magento:2.4-develop Jun 13, 2020
@m2-assistant
Copy link

m2-assistant bot commented Jun 13, 2020

Hi @amenk, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Priority: P3 May be fixed according to the position in the backlog. Progress: accept Release Line: 2.4 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Magento 2.3.4 Quote Address Extension Attribute Issue
8 participants