Files
LlamaCasty/ytLive.Tests/AnalyticsScopeTests.cs
T
gramps 9a6099af7c feat(scoreboard): unit 9 — the Analytics scope, requested incrementally
Scope becomes youtube + yt-analytics.readonly, with include_granted_scopes=true so an existing
session is asked for the NEW permission only. GrantedScopes records what Google says on the token
response (both the code exchange and the refresh), and HasAnalyticsScope is the flag the scoreboard
uses to offer a one-click re-consent instead of failing anonymously mid-stream.

TokenStore is unchanged on purpose: a launch-time refresh carries the scope list, so old sessions
report 'not granted' until the creator re-consents — the honest state.

The old auth test asserted 'exactly one scope'; it now asserts the new DECISION (two scopes, no
force-ssl, analytics read-only) rather than loosening.
2026-10-30 14:42:40 -07:00

26 lines
1.0 KiB
C#

using Xunit;
namespace ytLive.Tests;
/// <summary>Adding the Analytics scope means existing sessions lack it. The app must be able to TELL
/// — an anonymous 403 mid-stream is the failure this guards against.</summary>
public class AnalyticsScopeTests
{
[Fact]
public void The_app_asks_for_analytics_and_can_tell_when_a_session_lacks_it()
{
var source = SourceAssert.Text("Services", "YouTubeAuthService.cs");
// Requested, incrementally (so an existing user sees only the new prompt).
Assert.Contains("yt-analytics.readonly", source);
Assert.Contains("include_granted_scopes", source);
// And the grant is inspected from the token response, not assumed.
Assert.Contains("CaptureScopes", source);
Assert.Contains("HasAnalyticsScope", source);
// A connection type that exposes the flag, so the scoreboard can offer the one-click path.
Assert.NotNull(typeof(ytLive.Services.YouTubeAuthService).GetProperty("HasAnalyticsScope"));
}
}