@@ -328,3 +328,88 @@ def test_install_from_script(tmp_path, assert_log):
328328 assert_log .skip_until ("Installing %s" , ["Test 1.1 (32)" ]),
329329 ("Tag: %s\\ \\ %s" , ["Test" , "1.1-32" ]),
330330 )
331+
332+
333+ def test_sanitise_install_urls ():
334+ class Cmd :
335+ enable_shortcut_kinds = []
336+ disable_shortcut_kinds = []
337+ fallback_source = None
338+
339+ i = {
340+ "url" : "http://user:placeholder@example.com/package.zip" ,
341+ "source" : "http://user:placeholder@example.com/index.json" ,
342+ }
343+
344+ IC ._sanitise_install (Cmd , i )
345+
346+ assert i ["url" ] == "http://example.com/package.zip"
347+ assert i ["source" ] == "http://example.com/index.json"
348+
349+
350+ def test_sanitise_install_fallback_urls ():
351+ class Cmd :
352+ enable_shortcut_kinds = []
353+ disable_shortcut_kinds = []
354+ fallback_source = "http://user:placeholder@example.com/index.json"
355+
356+ i = {
357+ "url" : "http://user:placeholder@example.com/package.zip" ,
358+ "source" : "http://user:placeholder@example.com/index.json" ,
359+ }
360+
361+ IC ._sanitise_install (Cmd , i )
362+
363+ assert i ["url" ] == "http://example.com/package.zip"
364+ assert i ["source" ] == "http://user:placeholder@example.com/index.json"
365+
366+
367+ def test_sanitise_install_shortcuts ():
368+ class Cmd :
369+ enable_shortcut_kinds = []
370+ disable_shortcut_kinds = []
371+ fallback_source = None
372+
373+ i = {
374+ "url" : "" ,
375+ "shortcuts" : [dict (kind = a ) for a in "abc" ],
376+ }
377+
378+ IC ._sanitise_install (Cmd , i )
379+
380+ assert [j ["kind" ] for j in i ["shortcuts" ]] == ["a" , "b" , "c" ]
381+ assert [j ["kind" ] for j in i ["__original-shortcuts" ]] == ["a" , "b" , "c" ]
382+
383+
384+ def test_sanitise_install_shortcuts_disable ():
385+ class Cmd :
386+ enable_shortcut_kinds = []
387+ disable_shortcut_kinds = ["b" ]
388+ fallback_source = None
389+
390+ i = {
391+ "url" : "" ,
392+ "shortcuts" : [dict (kind = a ) for a in "abc" ],
393+ }
394+
395+ IC ._sanitise_install (Cmd , i )
396+
397+ assert [j ["kind" ] for j in i ["shortcuts" ]] == ["a" , "c" ]
398+ assert [j ["kind" ] for j in i ["__original-shortcuts" ]] == ["a" , "b" , "c" ]
399+
400+
401+ def test_sanitise_install_shortcuts_enable ():
402+ class Cmd :
403+ enable_shortcut_kinds = ["b" ]
404+ disable_shortcut_kinds = []
405+ fallback_source = None
406+
407+ i = {
408+ "url" : "" ,
409+ "shortcuts" : [dict (kind = a ) for a in "abc" ],
410+ }
411+
412+ IC ._sanitise_install (Cmd , i )
413+
414+ assert [j ["kind" ] for j in i ["shortcuts" ]] == ["b" ]
415+ assert [j ["kind" ] for j in i ["__original-shortcuts" ]] == ["a" , "b" , "c" ]
0 commit comments