1212
1313public class SanitizationTests
1414{
15- private static ( ApplicationDbContext ctx , LayoutService layout , HtmlSanitizerService sanitizer ) CreateServices ( )
15+ private static ( ApplicationDbContext ctx , LayoutService layout , ContentProcessingService content ) CreateServices ( )
1616 {
1717 var connection = new SqliteConnection ( "DataSource=:memory:" ) ;
1818 connection . Open ( ) ;
@@ -34,14 +34,15 @@ private static (ApplicationDbContext ctx, LayoutService layout, HtmlSanitizerSer
3434 . Build ( ) ;
3535 var layout = new LayoutService ( cache , tokens ) ;
3636 var sanitizer = new HtmlSanitizerService ( ) ;
37- return ( ctx , layout , sanitizer ) ;
37+ var content = new ContentProcessingService ( sanitizer ) ;
38+ return ( ctx , layout , content ) ;
3839 }
3940
4041 [ Fact ( Skip = "Create sanitization covered by section tests" ) ]
4142 public async Task CreatePage_SanitizesHtml ( )
4243 {
43- var ( ctx , layout , sanitizer ) = CreateServices ( ) ;
44- var controller = new AdminContentController ( ctx , layout , sanitizer ) ;
44+ var ( ctx , layout , content ) = CreateServices ( ) ;
45+ var controller = new AdminContentController ( ctx , layout , content ) ;
4546 var model = new Page
4647 {
4748 Slug = "test" ,
@@ -61,8 +62,8 @@ public async Task CreatePage_SanitizesHtml()
6162 [ Fact ]
6263 public async Task CreateSection_SanitizesHtml ( )
6364 {
64- var ( ctx , layout , sanitizer ) = CreateServices ( ) ;
65- var controller = new AdminPageSectionController ( ctx , layout , sanitizer ) ;
65+ var ( ctx , layout , content ) = CreateServices ( ) ;
66+ var controller = new AdminPageSectionController ( ctx , layout , content ) ;
6667
6768 var model = new PageSection { PageId = ctx . Pages . First ( ) . Id , Zone = "main" , Html = "<div>hi</div><script>bad()</script>" , Type = PageSectionType . Html } ;
6869 var result = await controller . Create ( model , null ) ;
@@ -75,8 +76,8 @@ public async Task CreateSection_SanitizesHtml()
7576 [ Fact ( Skip = "Edit sanitization covered by section tests" ) ]
7677 public async Task EditPage_SanitizesHtml ( )
7778 {
78- var ( ctx , layout , sanitizer ) = CreateServices ( ) ;
79- var controller = new AdminContentController ( ctx , layout , sanitizer ) ;
79+ var ( ctx , layout , content ) = CreateServices ( ) ;
80+ var controller = new AdminContentController ( ctx , layout , content ) ;
8081 var createModel = new Page
8182 {
8283 Slug = "edit" ,
@@ -103,8 +104,8 @@ public async Task EditPage_SanitizesHtml()
103104 [ Fact ]
104105 public async Task CreateSection_MarkdownConverted ( )
105106 {
106- var ( ctx , layout , sanitizer ) = CreateServices ( ) ;
107- var controller = new AdminPageSectionController ( ctx , layout , sanitizer ) ;
107+ var ( ctx , layout , content ) = CreateServices ( ) ;
108+ var controller = new AdminPageSectionController ( ctx , layout , content ) ;
108109 var model = new PageSection { PageId = ctx . Pages . First ( ) . Id , Zone = "md" , Html = "# Hello\n <script>bad()</script>" , Type = PageSectionType . Markdown } ;
109110 var result = await controller . Create ( model , null ) ;
110111 Assert . IsType < RedirectToActionResult > ( result ) ;
@@ -116,8 +117,8 @@ public async Task CreateSection_MarkdownConverted()
116117 [ Fact ]
117118 public async Task CreateSection_CodeEncoded ( )
118119 {
119- var ( ctx , layout , sanitizer ) = CreateServices ( ) ;
120- var controller = new AdminPageSectionController ( ctx , layout , sanitizer ) ;
120+ var ( ctx , layout , content ) = CreateServices ( ) ;
121+ var controller = new AdminPageSectionController ( ctx , layout , content ) ;
121122 var model = new PageSection { PageId = ctx . Pages . First ( ) . Id , Zone = "code" , Html = "<b>test</b>" , Type = PageSectionType . Code } ;
122123 var result = await controller . Create ( model , null ) ;
123124 Assert . IsType < RedirectToActionResult > ( result ) ;
@@ -128,8 +129,8 @@ public async Task CreateSection_CodeEncoded()
128129 [ Fact ]
129130 public async Task CreateSection_ImageStoresTag ( )
130131 {
131- var ( ctx , layout , sanitizer ) = CreateServices ( ) ;
132- var controller = new AdminPageSectionController ( ctx , layout , sanitizer ) ;
132+ var ( ctx , layout , content ) = CreateServices ( ) ;
133+ var controller = new AdminPageSectionController ( ctx , layout , content ) ;
133134 var bytes = new byte [ ] { 1 , 2 , 3 } ;
134135 using var stream = new System . IO . MemoryStream ( bytes ) ;
135136 var file = new FormFile ( stream , 0 , bytes . Length , "file" , "img.png" ) ;
0 commit comments