@@ -892,3 +892,38 @@ def test_credentail(self):
892892 "username" : "user" ,
893893 "password" : "pass"
894894 }])
895+
896+ @mock .patch ('SoftLayer.CLI.formatting.confirm' )
897+ def test_authorize_storage_vs_no_confirm (self , confirm_mock ):
898+ confirm_mock .return_value = False
899+ result = self .run_command (['vs' , 'authorize-storage' , '-u' , '1234' ])
900+
901+ self .assertEqual (result .exit_code , 2 )
902+
903+ @mock .patch ('SoftLayer.CLI.formatting.confirm' )
904+ def test_authorize_vs_empty (self , confirm_mock ):
905+ confirm_mock .return_value = True
906+ storage_result = self .set_mock ('SoftLayer_Account' , 'getNetworkStorage' )
907+ storage_result .return_value = []
908+ result = self .run_command (['vs' , 'authorize-storage' , '--username-storage=#' , '1234' ])
909+
910+ self .assertEqual (str (result .exception ), "The Storage with username: # was not found, "
911+ "please enter a valid storage username" )
912+
913+ def test_authorize_storage_vs (self ):
914+ result = self .run_command (['vs' , 'authorize-storage' , '--username-storage=SL01SEL301234-11' , '1234' ])
915+ self .assert_no_fail (result )
916+
917+ def test_authorize_portable_storage_vs (self ):
918+ mock = self .set_mock ('SoftLayer_Virtual_Guest' , 'attachDiskImage' )
919+ mock .return_value = {
920+ "createDate" : "2021-03-22T13:15:31-06:00" ,
921+ "id" : 1234567
922+ }
923+ result = self .run_command (['vs' , 'authorize-storage' , '--portable-id=12345' , '1234' ])
924+ self .assert_no_fail (result )
925+
926+ def test_authorize_volume_and_portable_storage_vs (self ):
927+ result = self .run_command (['vs' , 'authorize-storage' , '--username-storage=SL01SEL301234-11' ,
928+ '--portable-id=12345' , '1234' ])
929+ self .assert_no_fail (result )
0 commit comments