Skip to content

tests: assert the embedded inject.js is present before reading it (CS8602) - #202

Open
camarigor wants to merge 1 commit into
ZL154:mainfrom
camarigor:fix/tests-cs8602-jellyfin12-shell
Open

camarigor wants to merge 1 commit into
ZL154:mainfrom
camarigor:fix/tests-cs8602-jellyfin12-shell

Conversation

@camarigor

Copy link
Copy Markdown
Contributor

Summary

Two tests in Jellyfin12ShellTests.cs (mine, from #193) read inject.js through ResourceReader.ReadEmbeddedText, which returns string?, and went straight to IndexOf on the result. With <Nullable>enable</Nullable> that is four CS8602 warnings on every build of the test project. Each test now asserts the resource is present before using it, the way the file's third test and AdminPageContractTests already do.

Type of change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change (existing behaviour, config, or API changes)
  • Security fix
  • Documentation only
  • CI / build / tests only
  • Refactor (no functional change)

Related issues

Follow-up to #193, noted in #201.

How was this tested?

  • Added or updated unit tests: two Assert.NotNull(js) lines
  • Added or updated integration tests
  • Tested manually against a running Jellyfin server (state version)
  • N/A (explain why below)

Test-only change. dotnet build tests/Jellyfin.Plugin.TwoFactorAuth.Tests -c Release: zero warnings (four CS8602 before). dotnet test -c Release: 502 passed, 0 failed.

What changed

  • tests/Jellyfin.Plugin.TwoFactorAuth.Tests/Jellyfin12ShellTests.cs: Assert.NotNull(js); after the two ReadEmbeddedText calls. xunit's Assert.NotNull carries the [NotNull] annotation, so the compiler treats js as non-null from there on, and a missing embedded resource now fails the test with a clear message instead of a NullReferenceException.

Checklist

  • My code follows the existing style (run dotnet format if unsure)
  • I've added comments only where the why isn't obvious from the code
  • I've updated the README / SECURITY.md / docs if behaviour or config changed (nothing user-facing changed)
  • I've considered backwards compatibility (config migration, file formats, on-disk state)
  • I've checked the security implications (auth bypass, secret handling, input validation)
  • CI passes (dotnet build + dotnet test green)

Screenshots / log slices

before: Jellyfin12ShellTests.cs(24,22): warning CS8602  (x2, both frameworks of the test host)
        Jellyfin12ShellTests.cs(42,20): warning CS8602  (x2)
after:  0 warnings

Additional notes

None.

…8602)

Two tests from ZL154#193 read inject.js through ResourceReader.ReadEmbeddedText,
which returns string?, and dereferenced the result without a null check,
which is four CS8602 warnings on every build of the test project. Each now
asserts the resource is present first, like the rest of the suite does.
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