@@ -1303,3 +1303,63 @@ func TestUpgradeDoesNotTryToUpgradeBundledCoreLibraries(t *testing.T) {
13031303 // Empty output means nothing has been updated as expected
13041304 require .Empty (t , stdout )
13051305}
1306+
1307+ func downloadLib (t * testing.T , url string , zipPath * paths.Path ) {
1308+ response , err := http .Get (url )
1309+ require .NoError (t , err )
1310+ require .Equal (t , response .StatusCode , 200 )
1311+ zip , err := zipPath .Create ()
1312+ require .NoError (t , err )
1313+ _ , err = io .Copy (zip , response .Body )
1314+ require .NoError (t , err )
1315+ require .NoError (t , response .Body .Close ())
1316+ require .NoError (t , zip .Close ())
1317+ }
1318+
1319+ func TestInstallGitUrlAndZipPathFlagsVisibility (t * testing.T ) {
1320+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
1321+ defer env .CleanUp ()
1322+
1323+ // Verifies installation fail because flags are not found
1324+ gitUrl := "https://github.com/arduino-libraries/WiFi101.git"
1325+ _ , stderr , err := cli .Run ("lib" , "install" , "--git-url" , gitUrl )
1326+ require .Error (t , err )
1327+ require .Contains (t , string (stderr ), "--git-url and --zip-path are disabled by default, for more information see:" )
1328+
1329+ // Download library
1330+ url := "https://github.com/arduino-libraries/AudioZero/archive/refs/tags/1.1.1.zip"
1331+ zipPath := cli .DownloadDir ().Join ("libraries" , "AudioZero.zip" )
1332+ require .NoError (t , zipPath .Parent ().MkdirAll ())
1333+ downloadLib (t , url , zipPath )
1334+
1335+ _ , stderr , err = cli .Run ("lib" , "install" , "--zip-path" , zipPath .String ())
1336+ require .Error (t , err )
1337+ require .Contains (t , string (stderr ), "--git-url and --zip-path are disabled by default, for more information see:" )
1338+
1339+ envVar := cli .GetDefaultEnv ()
1340+ envVar ["ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL" ] = "true"
1341+ // Verifies installation is successful when flags are enabled with env var
1342+ stdout , _ , err := cli .RunWithCustomEnv (envVar , "lib" , "install" , "--git-url" , gitUrl )
1343+ require .NoError (t , err )
1344+ require .Contains (t , string (stdout ), "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk." )
1345+
1346+ stdout , _ , err = cli .RunWithCustomEnv (envVar , "lib" , "install" , "--zip-path" , zipPath .String ())
1347+ require .NoError (t , err )
1348+ require .Contains (t , string (stdout ), "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk." )
1349+
1350+ // Uninstall libraries to install them again
1351+ _ , _ , err = cli .Run ("lib" , "uninstall" , "WiFi101" , "AudioZero" )
1352+ require .NoError (t , err )
1353+
1354+ // Verifies installation is successful when flags are enabled with settings file
1355+ _ , _ , err = cli .RunWithCustomEnv (envVar , "config" , "init" , "--dest-dir" , "." )
1356+ require .NoError (t , err )
1357+
1358+ stdout , _ , err = cli .Run ("lib" , "install" , "--git-url" , gitUrl )
1359+ require .NoError (t , err )
1360+ require .Contains (t , string (stdout ), "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk." )
1361+
1362+ stdout , _ , err = cli .Run ("lib" , "install" , "--zip-path" , zipPath .String ())
1363+ require .NoError (t , err )
1364+ require .Contains (t , string (stdout ), "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk." )
1365+ }
0 commit comments