test(core/browser/platform): 26 extreme RED/GREEN TDD cycles and full regression hardening (3,235 PASS)
This commit is contained in:
parent
bcd242691f
commit
8677853822
100 changed files with 4814 additions and 333 deletions
71
tests/Paca.Tests/Core/SocialSiteDetectorExtremeRedTests.cs
Normal file
71
tests/Paca.Tests/Core/SocialSiteDetectorExtremeRedTests.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
using Paca.Core.Detection;
|
||||
using Xunit;
|
||||
|
||||
namespace Paca.Tests.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Cycle 6: 극한 RED 시나리오 - 소셜 사이트 감지기의 상대 URI 크래시, 비-HTTP 스킴, 변칙/불완전 URL 방어선 검증
|
||||
/// </summary>
|
||||
public class SocialSiteDetectorExtremeRedTests
|
||||
{
|
||||
[Fact]
|
||||
public void Cycle6_Gate1_RelativeUri_MustNotThrowInvalidOperationException()
|
||||
{
|
||||
// 브라우저 탭 주소나 페이지 내 상대 링크에서 상대 URI가 유입될 때
|
||||
// url.Host 접근으로 인한 InvalidOperationException 크래시 방지
|
||||
var relUri1 = new Uri("/watch?v=dQw4w9WgXcQ", UriKind.Relative);
|
||||
var relUri2 = new Uri("shorts/dQw4w9WgXcQ", UriKind.Relative);
|
||||
var relUri3 = new Uri("media.mp4", UriKind.Relative);
|
||||
|
||||
bool matched1 = SocialSiteDetector.TryMatch(relUri1, out _, out _);
|
||||
Assert.False(matched1);
|
||||
|
||||
bool matched2 = SocialSiteDetector.TryMatch(relUri2, out _, out _);
|
||||
Assert.False(matched2);
|
||||
|
||||
bool matched3 = SocialSiteDetector.TryMatch(relUri3, out _, out _);
|
||||
Assert.False(matched3);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("data:text/html,<html>test</html>")]
|
||||
[InlineData("javascript:alert(1)")]
|
||||
[InlineData("file:///C:/videos/test.mp4")]
|
||||
[InlineData("about:blank")]
|
||||
public void Cycle6_Gate2_NonHttpSchemes_MustReturnFalseSafely(string uriString)
|
||||
{
|
||||
var uri = new Uri(uriString);
|
||||
bool matched = SocialSiteDetector.TryMatch(uri, out _, out _);
|
||||
Assert.False(matched);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("https://www.youtube.com/watch?v=short")]
|
||||
[InlineData("https://www.youtube.com/watch?v=waytoolongid1234567890")]
|
||||
[InlineData("https://www.youtube.com/watch?v=invalid@id!")]
|
||||
[InlineData("https://www.youtube.com/watch?v=")]
|
||||
[InlineData("https://www.youtube.com/watch")]
|
||||
[InlineData("https://www.youtube.com/channel/UC123456")]
|
||||
[InlineData("https://www.youtube.com/user/pewdiepie")]
|
||||
public void Cycle6_Gate3_YouTubeIdBoundaryFuzzing_MustRejectInvalidUrls(string urlString)
|
||||
{
|
||||
var uri = new Uri(urlString);
|
||||
bool matched = SocialSiteDetector.TryMatch(uri, out _, out _);
|
||||
Assert.False(matched);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("https://www.instagram.com/p/")]
|
||||
[InlineData("https://www.instagram.com/reel/")]
|
||||
[InlineData("https://www.tiktok.com/@someuser")]
|
||||
[InlineData("https://www.tiktok.com/")]
|
||||
[InlineData("https://www.facebook.com/watch/")]
|
||||
[InlineData("https://www.facebook.com/reel/")]
|
||||
public void Cycle6_Gate4_InstagramAndTikTok_MalformedPaths_MustReject(string urlString)
|
||||
{
|
||||
var uri = new Uri(urlString);
|
||||
bool matched = SocialSiteDetector.TryMatch(uri, out _, out _);
|
||||
Assert.False(matched);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue