Skip to content

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

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: DELETE 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-length": 0 }  -----------------------------------------------------------  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: `Populated list`  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 a cy.request() call to the [RANCHER_URL] endpoint (likely during the "after all" cleanup step) returned a 401 Unauthorized status code. This indicates that the request did not include valid authentication credentials required by the server.

Likely Root Causes:

  1. Missing or Expired Authentication Token: The test may not have included a valid JWT or other authentication token in the request headers, or the token may have expired.
  2. Incorrect or Misconfigured Environment Variables: The [RANCHER_URL] or authentication-related environment variables (e.g., AUTH_TOKEN) may be missing, incorrect, or not properly loaded during the test run.
  3. Changes in API Authentication Requirements: The backend API may have updated its authentication mechanism, requiring additional headers or a different token format.
  4. Test Setup Issue: The authentication step (if performed earlier in the test) may have failed silently, resulting in no valid credentials being available for the cleanup request.

Suggested Fix:

Ensure that the request to [RANCHER_URL] includes the correct authentication token in the headers. If the token is dynamically generated during the test, verify that it is successfully retrieved and passed to the cy.request() call.

Here’s a concrete code snippet to fix the issue:

// Ensure the token is retrieved and passed in the request headers
const authToken = Cypress.env('AUTH_TOKEN'); // Ensure AUTH_TOKEN is set in the environment variables

cy.request({
  method: 'DELETE',
  url: Cypress.env('RANCHER_URL'), // Ensure RANCHER_URL is set in the environment variables
  headers: {
    'Authorization': `Bearer ${authToken}`, // Include the token in the Authorization header
    'Connection': 'keep-alive'
  },
  failOnStatusCode: false // Optional: Prevent the test from failing on non-2xx/3xx status codes
}).then((response) => {
  // Optionally, assert the response status code if needed
  expect(response.status).to.eq(200); // Adjust the expected status code as per the API documentation
});

Steps to Verify:

  1. Confirm that AUTH_TOKEN and RANCHER_URL are correctly set in the environment variables.
  2. Validate that the token is still valid and has not expired during the test execution.
  3. Run the test again to ensure the 401 Unauthorized error is resolved.

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