@@ -789,3 +789,56 @@ def test_download_package_errors_without_base_url(self):
789789 dl = GitHubPackageDownloader ()
790790 with pytest .raises (RuntimeError , match = "ARTIFACTORY_ONLY is set" ):
791791 dl .download_package ("microsoft/some-package" , Path ("/tmp/test-pkg" ))
792+
793+ def test_virtual_file_errors_without_base_url (self ):
794+ """ARTIFACTORY_ONLY without ARTIFACTORY_BASE_URL raises for virtual file packages."""
795+ with patch .dict (os .environ , {"ARTIFACTORY_ONLY" : "1" }, clear = True ):
796+ dl = GitHubPackageDownloader ()
797+ with pytest .raises (RuntimeError , match = "ARTIFACTORY_ONLY is set" ):
798+ dl .download_package (
799+ "owner/repo/prompts/deploy.prompt.md" , Path ("/tmp/test-pkg" )
800+ )
801+
802+ def test_virtual_collection_errors_without_base_url (self ):
803+ """ARTIFACTORY_ONLY without ARTIFACTORY_BASE_URL raises for virtual collection packages."""
804+ with patch .dict (os .environ , {"ARTIFACTORY_ONLY" : "1" }, clear = True ):
805+ dl = GitHubPackageDownloader ()
806+ with pytest .raises (RuntimeError , match = "ARTIFACTORY_ONLY is set" ):
807+ dl .download_package (
808+ "owner/repo/collections/my-collection" , Path ("/tmp/test-pkg" )
809+ )
810+
811+ def test_virtual_subdirectory_errors_without_base_url (self ):
812+ """ARTIFACTORY_ONLY without ARTIFACTORY_BASE_URL raises for virtual subdirectory packages."""
813+ with patch .dict (os .environ , {"ARTIFACTORY_ONLY" : "1" }, clear = True ):
814+ dl = GitHubPackageDownloader ()
815+ with pytest .raises (RuntimeError , match = "ARTIFACTORY_ONLY is set" ):
816+ dl .download_package (
817+ "owner/repo/skills/my-skill" , Path ("/tmp/test-pkg" )
818+ )
819+
820+ def test_explicit_artifactory_fqdn_virtual_file_passes (self ):
821+ """Explicit Artifactory FQDN on virtual file dep is NOT blocked by ARTIFACTORY_ONLY."""
822+ with patch .dict (os .environ , {"ARTIFACTORY_ONLY" : "1" }, clear = True ):
823+ dl = GitHubPackageDownloader ()
824+ dep = DependencyReference .parse (
825+ "art.example.com/artifactory/github/owner/repo/prompts/deploy.prompt.md"
826+ )
827+ assert dep .is_artifactory ()
828+ assert dep .is_virtual_file ()
829+ # Should not raise - explicit Artifactory FQDN bypasses the guard
830+ with patch .object (dl , 'download_virtual_file_package' , return_value = MagicMock ()):
831+ dl .download_package (dep , Path ("/tmp/test-pkg" ))
832+
833+ def test_explicit_artifactory_fqdn_virtual_collection_passes (self ):
834+ """Explicit Artifactory FQDN on virtual collection dep is NOT blocked by ARTIFACTORY_ONLY."""
835+ with patch .dict (os .environ , {"ARTIFACTORY_ONLY" : "1" }, clear = True ):
836+ dl = GitHubPackageDownloader ()
837+ dep = DependencyReference .parse (
838+ "art.example.com/artifactory/github/owner/repo/collections/my-collection"
839+ )
840+ assert dep .is_artifactory ()
841+ assert dep .is_virtual_collection ()
842+ # Should not raise - explicit Artifactory FQDN bypasses the guard
843+ with patch .object (dl , 'download_collection_package' , return_value = MagicMock ()):
844+ dl .download_package (dep , Path ("/tmp/test-pkg" ))
0 commit comments