Skip to content

[UI][Auto] Visual Testing.Populated list > should display JWT Authentication populated list page (Qase ID: 18428) #410

Description

@yonasberhe23

Failure Details

Framework: Cypress
Suite: Visual Testing.Populated list

Failing Environments

Version Environment User
head community @adminUser

Error Summary

`cy.request()` failed on:  [RANCHER_URL]  The response we received from your web server was:    > 401: Unauthorized  This was considered a failure because the status code was not `2xx` or `3xx`.  If you do not want status codes to cause failures pass the option: `failOnStatusCode: false`  -----------------------------------------------------------  The request we sent was:  Method: PUT URL: [RANCHER_URL] Headers: {   "Connection": "keep-alive",   "x-api-csrf": "61d70f573439078a6c2ae144a0beb396",   "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/146.0.0.0 Safari/537.36",   "accept": "application/json",   "cookie": "R_PCS=light; R_LOCALE=en-us; CSRF=ce4284a43bea55647bc3754d38648592",   "accept-encoding": "gzip, deflate",   "content-type": "application/json",   "content-length": 18 } Body: {"value":"modern"}  -----------------------------------------------------------  The response we got was:  Status: 401 - Unauthorized Headers: {   "cache-control": "no-cache, no-store, must-revalidate",   "content-length": "80",   "content-type": "application/json",   "date": "Thu, 06 Aug 2026 00:43:40 GMT",   "x-api-cattle-auth": "false",   "x-content-type-options": "nosniff" } Body: {   "type": "error",   "status": "401",   "message": "Unauthorized 401: must authenticate" }   https://on.cypress.io/request  Because this error occurred during a `after all` hook we are skipping the remaining tests in the current suite: `Visual Testing`  Although you have test retries enabled, we do not retry tests when `before all` or `after all` hooks fail

🤖 AI Fix Suggestions

Explanation of Test Failure:

The test failed because the cy.request() command attempted to send a PUT request to [RANCHER_URL], but the server returned a 401 Unauthorized response. This indicates that the request did not include valid authentication credentials or that the credentials provided were invalid.


Likely Root Causes:

  1. Missing or Invalid Authorization Token: The cy.request() call might not include the required JWT or authentication token in the headers, or the token provided is expired or invalid.
  2. Incorrect RANCHER_URL Configuration: The [RANCHER_URL] environment variable or endpoint might be misconfigured, pointing to the wrong server or endpoint that requires different credentials.
  3. Backend Authentication Issue: The backend server may have an issue validating the provided token or is rejecting requests due to misconfigured authentication settings.
  4. Test Data Setup Issue: The test might not have properly set up or refreshed the authentication token before making the cy.request() call.

Suggested Fix:

Ensure that the cy.request() includes a valid authentication token in the headers. If the token is dynamically generated during the test, verify that it is being fetched and passed correctly.

Code Snippet Fix:

// Assuming the JWT token is stored in Cypress environment variables
const token = Cypress.env('JWT_TOKEN'); // Ensure JWT_TOKEN is set in Cypress config or environment

cy.request({
  method: 'PUT',
  url: Cypress.env('RANCHER_URL'), // Ensure RANCHER_URL is set in Cypress config or environment
  headers: {
    'Authorization': `Bearer ${token}`, // Add the Authorization header with the token
    'Connection': 'keep-alive'
  },
  failOnStatusCode: false // Optional: prevent test failure on non-2xx/3xx responses
}).then((response) => {
  // Assert the response status code if needed
  expect(response.status).to.eq(200); // Adjust expected status code as necessary
});

Additional Notes:

  • Verify Token Validity: Ensure the token is valid and not expired before the test runs. If necessary, add a step to refresh or fetch a new token.
  • Check Environment Variables: Confirm that RANCHER_URL and JWT_TOKEN are correctly set in the Cypress environment configuration.
  • Backend Debugging: If the issue persists, check the backend logs to identify why the server is rejecting the request.

Auto-generated by CI Failure Inspector

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions