@@ -772,8 +772,23 @@ func TestDetectorRegistry(t *testing.T) {
772772 t .Fatal ("expected registered detectors, got none" )
773773 }
774774
775- // Check that some expected detectors are registered
776- expectedDetectors := []string {"Laravel" , "Django" , "React" , "Vue.js" , "Angular" , "Next.js" , "WordPress" , "Astro" }
775+ // Check that expected detectors are registered: a spot-check of the
776+ // originals plus every detector added to the backend, cms, and meta sets.
777+ expectedDetectors := []string {
778+ "Laravel" , "Django" , "React" , "Vue.js" , "Angular" , "Next.js" , "WordPress" , "Astro" ,
779+ "Tornado" , "CherryPy" , "Play Framework" , "Sails.js" , "Beego" ,
780+ "JavaServer Faces" , "Google Web Toolkit" , "Vaadin" , "ColdFusion" ,
781+ "TYPO3" , "Contao" , "Wix" , "Webflow" , "HubSpot" , "PrestaShop" ,
782+ "Sitecore" , "OpenCart" , "DotNetNuke" , "Liferay" ,
783+ "Hugo" , "Jekyll" , "Docusaurus" , "MkDocs" ,
784+ "Alpine.js" , "Qwik" ,
785+ "Squarespace" , "WooCommerce" , "Craft CMS" , "Concrete CMS" , "Bitrix" , "Blogger" ,
786+ "Eleventy" , "Hexo" , "VuePress" , "Sphinx" ,
787+ "MediaWiki" , "Discourse" , "XenForo" , "Moodle" , "Plone" , "Grav" ,
788+ "Textpattern" , "October CMS" , "Statamic" , "Livewire" ,
789+ "Stimulus" , "Turbo" , "Knockout.js" , "Unpoly" , "Flarum" , "NodeBB" ,
790+ "XWiki" , "Bolt CMS" , "Nikola" , "Publii" , "ExpressionEngine" ,
791+ }
777792 for _ , name := range expectedDetectors {
778793 if _ , ok := frameworks .GetDetector (name ); ! ok {
779794 t .Errorf ("expected detector %q to be registered" , name )
@@ -905,8 +920,9 @@ func TestDetectFramework_Backbone(t *testing.T) {
905920func TestDetectFramework_CakePHPFalsePositive (t * testing.T ) {
906921 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
907922 w .WriteHeader (http .StatusOK )
908- w .Write ([]byte (`<!DOCTYPE html><html><body><p>our cupcake and cheesecake recipes,
909- plus the best pancake stack in town.</p></body></html>` ))
923+ // a Q&A/listicle page that merely names the framework, as on the live
924+ // stackoverflow homepage that the bare body substring used to misfire on
925+ w .Write ([]byte (`<!DOCTYPE html><html><body><a href="/questions/tagged/cakephp">cakephp</a></body></html>` ))
910926 }))
911927 defer server .Close ()
912928
@@ -915,7 +931,7 @@ func TestDetectFramework_CakePHPFalsePositive(t *testing.T) {
915931 t .Fatalf ("unexpected error: %v" , err )
916932 }
917933 if result != nil && result .Name == "CakePHP" {
918- t .Errorf ("false positive: detected CakePHP (confidence %.2f) on prose about cakes " , result .Confidence )
934+ t .Errorf ("false positive: detected CakePHP (confidence %.2f) on prose naming cakephp " , result .Confidence )
919935 }
920936}
921937
@@ -956,7 +972,8 @@ func TestDetectFramework_SvelteFalsePositive(t *testing.T) {
956972func TestDetectFramework_StrapiFalsePositive (t * testing.T ) {
957973 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
958974 w .WriteHeader (http .StatusOK )
959- w .Write ([]byte (`<!DOCTYPE html><html><body><script>fetch("/api/v1/users")</script></body></html>` ))
975+ // prose naming the CMS plus a plain /api/ path: neither is the powered-by header
976+ w .Write ([]byte (`<!DOCTYPE html><html><body><p>built with Strapi</p><script>fetch("/api/v1/users")</script></body></html>` ))
960977 }))
961978 defer server .Close ()
962979
@@ -965,14 +982,16 @@ func TestDetectFramework_StrapiFalsePositive(t *testing.T) {
965982 t .Fatalf ("unexpected error: %v" , err )
966983 }
967984 if result != nil && result .Name == "Strapi" {
968- t .Errorf ("false positive: detected Strapi (confidence %.2f) on a plain /api/ path " , result .Confidence )
985+ t .Errorf ("false positive: detected Strapi (confidence %.2f) on prose naming strapi " , result .Confidence )
969986 }
970987}
971988
972989func TestDetectFramework_Strapi (t * testing.T ) {
973990 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
991+ // the default poweredBy middleware sets this header on every response
992+ w .Header ().Set ("X-Powered-By" , "Strapi <strapi.io>" )
974993 w .WriteHeader (http .StatusOK )
975- w .Write ([]byte (`<!DOCTYPE html><html><body><div>powered by strapi </div></body></html>` ))
994+ w .Write ([]byte (`<!DOCTYPE html><html><body><div>welcome </div></body></html>` ))
976995 }))
977996 defer server .Close ()
978997
0 commit comments