22// Licensed under the MIT License.
33
44using Microsoft . VisualStudio . Services . Agent . Util ;
5- using System ;
6- using System . Text ;
75using System . Globalization ;
86using Xunit ;
97
@@ -24,66 +22,14 @@ public class StringUtilL0
2422 [ InlineData ( "##VsO" , "**vso" ) ]
2523 [ InlineData ( "" , "" ) ]
2624 [ InlineData ( null , "" ) ]
27- [ InlineData ( " " , "" ) ]
25+ [ InlineData ( " " , " " ) ]
2826 public void DeactivateVsoCommandsFromStringTest ( string input , string expected )
2927 {
3028 var result = StringUtil . DeactivateVsoCommands ( input ) ;
3129
3230 Assert . Equal ( expected , result ) ;
3331 }
3432
35- /// <summary>
36- /// In this test, a vso command is encoded as a bse64 string and being passed as input to the DeactivateBase64EncodedVsoCommands
37- /// The returned string when decoded will have ## replaced with **, deactivating the vso command.
38- /// </summary>
39- [ Fact ]
40- [ Trait ( "Level" , "L0" ) ]
41- [ Trait ( "Category" , "Common" ) ]
42- public void DeactivateVsoCommandsIfBase64Encoded_EncodedVsoCommands_Returns_DeactivatedVsoCommands ( )
43- {
44- string vsoCommand = "##vso[task.setvariable variable=downloadUrl]https://www.evil.com" ;
45- string encodedVsoCommand = Convert . ToBase64String ( Encoding . UTF8 . GetBytes ( vsoCommand ) ) ;
46-
47- string result = StringUtil . DeactivateVsoCommandsIfBase64Encoded ( encodedVsoCommand ) ;
48-
49- string deactivatedVsoCommand = "**vso[task.setvariable variable=downloadUrl]https://www.evil.com" ;
50- var expected = Convert . ToBase64String ( Encoding . UTF8 . GetBytes ( deactivatedVsoCommand ) ) ;
51-
52- Assert . Equal ( expected , result ) ;
53- }
54-
55- /// <summary>
56- /// In this test, a vso command is being passed as input to the DeactivateBase64EncodedVsoCommands
57- /// The unmodified string would be returned.
58- /// </summary>
59- [ Fact ]
60- [ Trait ( "Level" , "L0" ) ]
61- [ Trait ( "Category" , "Common" ) ]
62- public void DeactivateVsoCommandsIfBase64Encoded_NotEncodedVsoCommands_Throws_FormatException ( )
63- {
64- string vsoCommand = "##vso[task.setvariable variable=downloadUrl]https://www.evil.com" ;
65- Assert . Throws < FormatException > ( ( ) => StringUtil . DeactivateVsoCommandsIfBase64Encoded ( vsoCommand ) ) ;
66- }
67-
68- [ Fact ]
69- [ Trait ( "Level" , "L0" ) ]
70- [ Trait ( "Category" , "Common" ) ]
71- public void DeactivateVsoCommandsIfBase64Encoded_InputEmpty_Returns_UnmodifiedString ( )
72- {
73- string vsoCommand = "" ;
74- string result = StringUtil . DeactivateVsoCommandsIfBase64Encoded ( vsoCommand ) ;
75- Assert . Equal ( vsoCommand , result ) ;
76- }
77-
78- [ Fact ]
79- [ Trait ( "Level" , "L0" ) ]
80- [ Trait ( "Category" , "Common" ) ]
81- public void DeactivateVsoCommandsIfBase64Encoded_InputNull_Throws_Exception ( )
82- {
83- string vsoCommand = null ;
84- Assert . Throws < ArgumentNullException > ( ( ) => StringUtil . DeactivateVsoCommandsIfBase64Encoded ( vsoCommand ) ) ;
85- }
86-
8733 [ Fact ]
8834 [ Trait ( "Level" , "L0" ) ]
8935 [ Trait ( "Category" , "Common" ) ]
0 commit comments