Add "fetch with CORS" test
This commit is contained in:
1 parent
383522372f
commit
a5766c41ce
5 files changed
+55
-1
No files matched your search
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- An invidious instance "fetch with CORS" test
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- a bug where public Invidious instances all showed `N/A` in the health column
|
- a bug where public Invidious instances all showed `N/A` in the health column
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@
|
|||||||
iconVisible="false"
|
iconVisible="false"
|
||||||
anchor="[0.5,0.5]"
|
anchor="[0.5,0.5]"
|
||||||
padding="[30,30]"
|
padding="[30,30]"
|
||||||
translation="[580,530]" />
|
translation="[580,545]" />
|
||||||
</Rectangle>
|
</Rectangle>
|
||||||
</children>
|
</children>
|
||||||
</component>
|
</component>
|
||||||
+35
@@ -32,6 +32,7 @@ function PrepareTests() as object
|
|||||||
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoComments), CanFetchVideoComments))
|
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoComments), CanFetchVideoComments))
|
||||||
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoCaptions), CanFetchVideoCaptions))
|
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoCaptions), CanFetchVideoCaptions))
|
||||||
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoThumbnails), CanFetchVideoThumbails))
|
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoThumbnails), CanFetchVideoThumbails))
|
||||||
|
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchWithCors), CanFetchWithCors))
|
||||||
return content
|
return content
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -312,3 +313,37 @@ function CanFetchVideoThumbails(instance as string, testNode as object, cancella
|
|||||||
testNode.details = ErrorUtils.Format(e)
|
testNode.details = ErrorUtils.Format(e)
|
||||||
end try
|
end try
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function CanFetchWithCors(instance as string, testNode as object, cancellation as object) as void
|
||||||
|
try
|
||||||
|
url = `${instance}/api/v1/trending`
|
||||||
|
response = HttpClient.Get(url).NoCache().Cancellation(cancellation).Await()
|
||||||
|
|
||||||
|
if not response.IsSuccess()
|
||||||
|
testNode.state = "failed"
|
||||||
|
testNode.details = response.ErrorMessage()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
json = response.Json()
|
||||||
|
if json = invalid
|
||||||
|
testNode.state = "failed"
|
||||||
|
testNode.details = Tr(Locale.InvidiousTesting.InvalidJsonFrom).Replace("%1", url)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
headers = response.Headers()
|
||||||
|
corsHeader = headers["Access-Control-Allow-Origin"]
|
||||||
|
if not IsString(corsHeader) or corsHeader <> "*"
|
||||||
|
testNode.state = "failed"
|
||||||
|
testNode.details = Tr(Locale.InvidiousTesting.CorsHeaderNotSetCorrectly).Replace("%1", url)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
testNode.state = "passed"
|
||||||
|
testNode.details = Tr(Locale.InvidiousTesting.TheInstanceCanFetchWithCors).Replace("%1", url)
|
||||||
|
catch e
|
||||||
|
testNode.state = "failed"
|
||||||
|
testNode.details = ErrorUtils.Format(e)
|
||||||
|
end try
|
||||||
|
end function
|
||||||
@@ -364,6 +364,10 @@
|
|||||||
<source>Fetch video thumbnails</source>
|
<source>Fetch video thumbnails</source>
|
||||||
<translation>Fetch video thumbnails</translation>
|
<translation>Fetch video thumbnails</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Fetch with CORS</source>
|
||||||
|
<translation>Fetch with CORS</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Press 'OK' for details</source>
|
<source>Press 'OK' for details</source>
|
||||||
<translation>Press 'OK' for details</translation>
|
<translation>Press 'OK' for details</translation>
|
||||||
@@ -432,6 +436,14 @@
|
|||||||
<source>The instance can fetch video thumbnail for ID %1 (%2)</source>
|
<source>The instance can fetch video thumbnail for ID %1 (%2)</source>
|
||||||
<translation>The instance can fetch video thumbnail for ID %1 (%2)</translation>
|
<translation>The instance can fetch video thumbnail for ID %1 (%2)</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>CORS header not set correctly from %1</source>
|
||||||
|
<translation>CORS header not set correctly from %1</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>The instance can fetch with CORS from %1</source>
|
||||||
|
<translation>The instance can fetch with CORS from %1</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Passed</source>
|
<source>Passed</source>
|
||||||
<translation>Passed</translation>
|
<translation>Passed</translation>
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ namespace Locale
|
|||||||
FetchVideoComments = "Fetch video comments"
|
FetchVideoComments = "Fetch video comments"
|
||||||
FetchVideoCaptions = "Fetch video captions"
|
FetchVideoCaptions = "Fetch video captions"
|
||||||
FetchVideoThumbnails = "Fetch video thumbnails"
|
FetchVideoThumbnails = "Fetch video thumbnails"
|
||||||
|
FetchWithCors = "Fetch with CORS"
|
||||||
|
|
||||||
PressOkForDetails = "Press 'OK' for details"
|
PressOkForDetails = "Press 'OK' for details"
|
||||||
|
|
||||||
@@ -138,6 +139,8 @@ namespace Locale
|
|||||||
ThumbnailNotReachable = "%1 is not reachable"
|
ThumbnailNotReachable = "%1 is not reachable"
|
||||||
InvalidThumbnailData = "Invalid thumbnail data %1 (Content-Type is not image/*)"
|
InvalidThumbnailData = "Invalid thumbnail data %1 (Content-Type is not image/*)"
|
||||||
TheInstanceCanFetchVideoThumbnails = "The instance can fetch video thumbnail for ID %1 (%2)"
|
TheInstanceCanFetchVideoThumbnails = "The instance can fetch video thumbnail for ID %1 (%2)"
|
||||||
|
CorsHeaderNotSetCorrectly = "CORS header not set correctly from %1"
|
||||||
|
TheInstanceCanFetchWithCors = "The instance can fetch with CORS from %1"
|
||||||
|
|
||||||
Passed = "Passed"
|
Passed = "Passed"
|
||||||
Failed = "Failed"
|
Failed = "Failed"
|
||||||
|
|||||||
Reference in new issue
Block a user