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

Incorrect localStorage value after running authentication setup test. #160

Open
dtng95 opened this issue Oct 30, 2024 · 1 comment
Open

Comments

@dtng95
Copy link

dtng95 commented Oct 30, 2024

  • I got this issue SyntaxError: Unexpected number in JSON at position 4 when running my tests for Forms.
image
  • After some digging, I found out that the user.json file that has been generated by the authentication setup test has an issue. Here's my user.json file looks like.
{
  "cookies": [
    {
      "name": "UMB_UCONTEXT",
      "value": "too long so I replace with this text",
      "domain": "localhost",
      "path": "/",
      "expires": 1730285391.9487,
      "httpOnly": true,
      "secure": true,
      "sameSite": "Lax"
    }
  ],
  "origins": [
    {
      "origin": "https://localhost:44337",
      "localStorage": [
        {
          "name": "umb:serverUpgradeCheck",
          "value": "{\"type\":\"Minor\",\"comment\":\"14.3.1.0 is released. Upgrade today - it's free!\",\"url\":\"http://our.umbraco.org/contribute/releases/1431?version=14.3.0\",\"expires\":\"2024-11-06T10:29:53.981Z\"}"
        },
        {
          "name": "umb:lastUpgradeCheck",
          "value": "2024-10-30T10:29:53.517Z"
        },
        {
          "name": "umb:userAuthTokenResponse",
          "value": "{\"access_token\":\"MbUYnSVIAxyFPERMF2K-4eKEGhmStVoHVlpmoHfy8X8\",\"refresh_token\":\"-9oFAFT4vmhCvwmZkhF4OEhw4TRqsUELbz_5yjpwr34\",\"scope\":\"offline_access\",\"token_type\":\"Bearer\",\"issued_at\":1730284192,\"expires_in\":\"300\"}"
        }
      ]
    }
  ]
}
  • By removing umb:lastUpgradeCheck, my tests run successfully. I figured out the value 2024-10-30T10:29:53.517Z is somehow causing the issue. I updated it to this:
{
  "name": "umb:lastUpgradeCheck",
  "value": "{\"date\":\"2024-10-30T09:24:53.264Z\"}
}

and everything is ok.

  • Also, by looking at the updateLocalStorage() in ApiHelpers, I believe using data.origins[0].localStorage[0] to get umb:userAuthTokenResponse is inappropriate. With my above json file, umb:userAuthTokenResponse is the third element, not the first, so data.origins[0].localStorage[0] would return incorrect result.
    I would suggest using other approach like
    data.origins[0].localStorage.find(l => l.name == "umb:userAuthTokenResponse") or any other approach that fits would be better.

  • I'm not really sure if this is the correct repo to create this issue or not. Let me know if I need to create this in another repo.
    Thanks.

@andr317c
Copy link
Contributor

Hey!

Thanks a lot for creating this issue; it is in the correct repo 💪.

Regarding the updateLocaleStorage, you are correct that it should be updated to the example you mentioned, it is in the PR linked to this issue.

For the issue itself about umb:lastUpgradeCheck, I was unable to reproduce this. My tests runs without any issues. Are you able to reproduce this from a clean install? If you are, please let me know what steps you took to get this issue 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants