Skip to content

[STR-985] Fix: Allow only Admin users to access certain APIs#104

Open
mendescamara wants to merge 9 commits intomasterfrom
fix/STR-985
Open

[STR-985] Fix: Allow only Admin users to access certain APIs#104
mendescamara wants to merge 9 commits intomasterfrom
fix/STR-985

Conversation

@mendescamara
Copy link
Copy Markdown
Collaborator

@mendescamara mendescamara commented Apr 16, 2026

Summary

This branch strengthens admin user validation in the VTEX service layer, adds automated unit tests, fixes the .NET build when the test project lives under the same dotnet/ folder as the app, and runs .NET tests in the Quality Engineering GitHub Actions workflow.

NOTE: I am still analyzing the logs to confirm the impact of this change on the APIs.

Changes

Authentication and License Manager (VtexAPIService)

  • After credential/validate, the flow calls the private accounts API /api/pvt/accounts/{account}/logins/{userId}/granted to confirm the login is granted in License Manager.
  • The response body is handled when HTTP 200 is returned with false (denied access), as well as true and JSON boolean forms, instead of relying on HTTP status alone.
  • If validate succeeds without an Id, the user is not treated as valid for the LM check.

Unit tests

  • New AvailabilityNotify.Tests project (xUnit + Moq) with tests focused on VtexAPIService (ValidateUserToken, IsValidAuthUser, ListNotifyRequests) and a test HttpMessageHandler to stub outbound HTTP calls.
  • dotnet/dotnet.sln groups the app and the test project for restore, build, and test from the dotnet/ directory.

Build and NuGet

  • In availability-notify.csproj, DefaultItemExcludes for AvailabilityNotify.Tests/** so the SDK default glob does not compile test sources into the main assembly (typical cause of CS0246 for Moq / Xunit on the wrong project).
  • Optional on the branch: root NuGet.Config pinning nuget.org for reliable restore when machine-level feeds or credential providers fail.

CI (GitHub Actions)

The tests are not yet in GitHub Actions because I don't have permission to modify the .github/workflows files.
I have requested permission from the IT team.

How to verify locally

dotnet restore
dotnet build dotnet/availability-notify.csproj
dotnet test dotnet/AvailabilityNotify.Tests/AvailabilityNotify.Tests.csproj

(Adjust paths if you use a different .sln at the repo root or under dotnet/.)

Checklist

  • .NET build and tests pass locally and in CI after merge.

@vtex-io-ci-cd
Copy link
Copy Markdown

vtex-io-ci-cd Bot commented Apr 16, 2026

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vtex-io-docs-bot
Copy link
Copy Markdown

vtex-io-docs-bot Bot commented Apr 16, 2026

Beep boop 🤖

I noticed you didn't make any changes at the docs/ folder

  • There's nothing new to document 🤔
  • I'll do it later 😞

In order to keep track, I'll create an issue if you decide now is not a good time

  • I just updated 🎉🎉

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 16, 2026

Warnings
⚠️

Looks like this PR is too large [:bulb: smaller PRs are easy to review and approve]

Messages
📖 ❤️ Thanks!
📖

🎉 PR additions = 512, PR deletions = 5520

Generated by 🚫 dangerJS against 97374c0

@mendescamara mendescamara marked this pull request as ready for review April 17, 2026 19:11
@mendescamara mendescamara changed the title Fix/str 985 [STR-985] Fix: Allow only Admin users to access certain APIs Apr 17, 2026
@mendescamara mendescamara reopened this Apr 17, 2026
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

Successfully merging this pull request may close these issues.

1 participant