raft-tech / TANF-app

Repo for development of a new TANF Data Reporting System
Other
16 stars 3 forks source link

test-deployment-e2e is failing integration test #3141

Open andrew-jameson opened 2 months ago

andrew-jameson commented 2 months ago

Thank you for taking the time to let us know about the issue you found. The basic rule for bug reporting is that something isn't working the way one would expect it to work. Please provide us with the information requested below and we will look at it as soon as we are able.

Description

For weeks/months, develop environment fails our e2e cypress test. I can't find origin of when it failed.

Action Taken

Upon merge of successful and tested branch to develop, e2e test fails.

What I expected to see

Screenshot 2024-08-13 at 12 56 11 PM

What I did see

Test failure in develop

Screenshot 2024-08-13 at 12 54 06 PM

Other Helpful Information

andrew-jameson commented 1 month ago

Well, halfway there: https://app.circleci.com/pipelines/github/raft-tech/TANF-app/28427/workflows/7444288b-5fcf-448b-a571-e4f472c4ded7/jobs/83752

User was created, seems there may need to be an approval happening.

andrew-jameson commented 1 month ago

First pipeline to fail on this cypress step

Originating ticket: Link PR: Link Commit: Link

However, looking over this, I don't see any code that would invalidate the POST being used. A local run of e2e is successful and same in the pipeline so this is only at the deployed "point-and-login" so perhaps the auth upgrade is being certified as a bad request over CRSF violation or equivalent. There were a number of nginx changes to support the new domain name for tdp-frontend-develop.acf.hhs.gov:

Kibana Deployment PR 1 Nginx DNS for Kibana/ClamAV Originating ticket - Cloud.gov resetting Kibana route

Original ACF domain tickets Per this comment domains reworked in this PR.

andrew-jameson commented 1 month ago

Reworking nginx config with @raftmsohani didn't yield the results we'd hoped for. Will re-convene on it Monday.

Failed pipeline

   -----> Installing nginx 1.25.1
   Copy [/tmp/cache/final/dependencies/88daf4e79c4db8bf01ae3de3795661fd9a8b443ba4e498af6362be2d3e695a22/nginx_1.25.1_linux_x64_cflinuxfs4_c030b0cf.tgz]
   2024/09/13 21:15:03 [emerg] 445#0: invalid number of arguments in "proxy_set_header" directive in /tmp/conf310622263/locations.conf:7
   nginx: configuration file /tmp/conf310622263/nginx.conf test failed
   **ERROR** Could not validate nginx.conf: nginx.conf contains syntax errors: exit status 1
   Failed to compile droplet: Failed to run all supply scripts: exit status 14
   Exit status 223
BuildpackCompileFailed - App staging failed in the buildpack compile phase
FAILED

Exited with code exit status 1

Offending line:

        proxy_set_header Host ;
andrew-jameson commented 1 month ago

Working on the e2e test failing, it appears our cypress version is out of date for a bit. I found a bug report that lines up with the error I'm seeing. However, before/after upgrading the version, the referer is still not in cypress's OUTGOING post request. The original code added it directly in the header like this:

Cypress.Commands.add(
  'adminApiRequest',
  (method = 'POST', path = '', body = {}) => {
    options = {
      method,
      body,
      url: `${Cypress.env('adminUrl')}${path}`,
      form: true,
      headers: {
        Referer: `${Cypress.env('adminUrl')}`,   //'https://tdp-frontend-develop.acf.hhs.gov/admin', //
      },
    }

However, the workaround lin that bug report show a decidedly different handling, albeit theirs appears to be a simple GET or visit:

it('should visit with referrer', () => {
    const onBeforeLoad = (contentWindow) => {
      Object.defineProperty(contentWindow.document, 'referrer', {
        value: 'http://test.com/',
        enumerable: true,
        configurable: true,
      });
    };

    cy.visit('/', { onBeforeLoad });
    . . .
})

Using version 11 cypress, no referer.

Screenshot 2024-09-16 at 11 02 20 AM

Using versions 12/13, now have referer but it's insecure:

Screenshot 2024-09-16 at 11 27 07 AM Screenshot 2024-09-16 at 11 27 28 AM
andrew-jameson commented 1 month ago

https://stackoverflow.com/a/71314689 Setup tests like pytest vs needing to run Given The admin logs in before each

Could also remove need for auth/sessions when utilizing the admin API in cypress endpoints.

andrew-jameson commented 1 week ago

As documented in our new tech memo, we have the following tasks to move this forward: