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

[BUG] ApiFunctional TestFramework GraphQL Client Parses Headers Improperly #26425

Closed
damienwebdev opened this issue Jan 16, 2020 · 7 comments · Fixed by #28915
Closed

[BUG] ApiFunctional TestFramework GraphQL Client Parses Headers Improperly #26425

damienwebdev opened this issue Jan 16, 2020 · 7 comments · Fixed by #28915
Labels
Component: TestFramework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development PAP Partners acceleration program Project: GraphQL Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Milestone

Comments

@damienwebdev
Copy link
Member

Preconditions (*)

Magento v2.3.3

Steps to reproduce (*)

  1. Make a call with the GraphQlAbstract::graphQlQueryWithResponseHeaders
  2. Have a header in the response like: Access-Control-Allow-Origin: https://www.example.com
  3. See that the header does NOT show up in the headers array

Expected result (*)

  1. Have a header in the headers array like: ['Access-Control-Allow-Origin'] => 'https://www.example.com'

Actual result (*)

See above.

This is due to a failed preg_split logic in:

https://github.com/magento/magento2/blame/6b4a82b8554917ba78f7bc84ada8ea05a85aca92/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQl/Client.php#L210

/**
     * Parse response headers into associative array
     *
     * @param string $headers
     * @return array
     */
    private function processResponseHeaders(string $headers): array
    {
        $headersArray = [];

        $headerLines = preg_split('/((\r?\n)|(\r\n?))/', $headers);
        foreach ($headerLines as $headerLine) {
            $headerParts = preg_split('/: /', $headerLine);
            if (count($headerParts) == 2) {
                $headersArray[trim($headerParts[0])] = trim($headerParts[1]);
            } elseif (preg_match('/HTTP\/[\.0-9]+/', $headerLine)) {
                $headersArray[trim('Status-Line')] = trim($headerLine);
            }
        }

        return $headersArray;
    }

It should preg_split with a limit of 2:

$headerParts = preg_split('/: /', $headerLine, 2);

cc: @danielrenaud @danmooney2

@m2-assistant
Copy link

m2-assistant bot commented Jan 16, 2020

Hi @damienwebdev. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

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

@damienwebdev do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jan 16, 2020
@engcom-Bravo engcom-Bravo added the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Jan 28, 2020
@magento-engcom-team magento-engcom-team removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Jan 28, 2020
@magento-engcom-team
Copy link
Contributor

@engcom-Bravo Thank you for verifying the issue.

Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:

  • Add "Component: " label(s) to this ticket based on verification result. If uncertain, you may follow the best guess
  • Add "Reproduced on " label(s) to this ticket based on verification result

Once all required information is added, please add label "Issue: Confirmed" again.
Thanks!

@engcom-Bravo engcom-Bravo self-assigned this Jan 28, 2020
@m2-assistant
Copy link

m2-assistant bot commented Jan 28, 2020

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Bravo engcom-Bravo added Component: TestFramework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Jan 28, 2020
@magento-engcom-team magento-engcom-team removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Jan 28, 2020
@ghost ghost unassigned engcom-Bravo Jan 28, 2020
@magento-engcom-team
Copy link
Contributor

@engcom-Bravo Thank you for verifying the issue.

Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:

  • Add "Reproduced on " label(s) to this ticket based on verification result

Once all required information is added, please add label "Issue: Confirmed" again.
Thanks!

@engcom-Bravo engcom-Bravo added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Jan 28, 2020
@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jan 28, 2020
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-Bravo
Thank you for verifying the issue. Based on the provided information internal tickets MC-30844 were created

Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@engcom-Bravo
Copy link
Contributor

Hello @damienwebdev

Thank you, for your report.

Can you please create a pull request on this issue?

Thank you for collaboration

@magento-engcom-team magento-engcom-team added this to Ready for Dev in Community Backlog Mar 24, 2020
@nrkapoor nrkapoor added this to the 2.4.1 milestone Jun 11, 2020
@nrkapoor nrkapoor moved this from Ready for Dev to Good First Issue in Community Backlog Jun 21, 2020
@nrkapoor nrkapoor added the PAP Partners acceleration program label Jun 25, 2020
@michalderlatka michalderlatka self-assigned this Jun 29, 2020
@m2-assistant
Copy link

m2-assistant bot commented Jun 29, 2020

Hi @michalderlatka. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

    1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
    1. If the issue is not relevant or is not reproducible any more, feel free to close it.

@ghost ghost moved this from Good First Issue to Dev in Progress in Community Backlog Jun 29, 2020
michalderlatka added a commit to michalderlatka/magento2 that referenced this issue Jun 29, 2020
@ghost ghost moved this from Dev in Progress to PR In Progress in Community Backlog Jun 29, 2020
@nrkapoor nrkapoor modified the milestones: 2.4.1, 2.4.2 Aug 15, 2020
@ghost ghost moved this from PR In Progress to Done (last 30 days) in Community Backlog Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: TestFramework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development PAP Partners acceleration program Project: GraphQL Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
No open projects
Community Backlog
  
Done (last 30 days)
Development

Successfully merging a pull request may close this issue.

6 participants