@@ -8,6 +8,10 @@ public class VariablePathTests
88 [ InlineData ( "$foo:bar" , "foo" , "bar" ) ]
99 [ InlineData ( "$foo.bar:baz.x" , "foo.bar" , "baz.x" ) ]
1010 [ InlineData ( "$foo_bar:baz_x" , "foo_bar" , "baz_x" ) ]
11+ [ InlineData ( "$secret:K2b8F2zG9HpJxMI" , "secret" , "K2b8F2zG9HpJxMI" ) ]
12+ [ InlineData ( "$secret:abc+def/ghi==" , "secret" , "abc+def/ghi==" ) ]
13+ [ InlineData ( "$secret:abc/def+ghi=" , "secret" , "abc/def+ghi=" ) ]
14+ [ InlineData ( "$secret:abc-def_ghi" , "secret" , "abc-def_ghi" ) ]
1115 public void Parse_ValidVariableName_CorrectResult ( string variableName , string providerName , string path )
1216 {
1317 // arrange & act
@@ -31,6 +35,22 @@ public void TryParse_ValidVariableName_CorrectResult()
3135 path ! . Value . Path . Should ( ) . Be ( "baz.x" ) ;
3236 }
3337
38+ [ Fact ]
39+ public void TryParse_Base64EncodedPath_CorrectResult ( )
40+ {
41+ // arrange
42+ const string base64 = "K2b8F2zG9HpJxMImaYwlf0ByzArc+abc/def==" ;
43+
44+ // act
45+ bool success = VariablePath . TryParse ( $ "$secret:{ base64 } ", out VariablePath ? path ) ;
46+
47+ // assert
48+ success . Should ( ) . BeTrue ( ) ;
49+ path . HasValue . Should ( ) . BeTrue ( ) ;
50+ path ! . Value . ProviderName . Should ( ) . Be ( "secret" ) ;
51+ path . Value . Path . Should ( ) . Be ( base64 ) ;
52+ }
53+
3454 [ Theory ]
3555 [ InlineData ( "bar" ) ]
3656 [ InlineData ( "$foo.bar" ) ]
@@ -44,4 +64,50 @@ public void TryParse_Invalid_SuccessFalse(string variableName)
4464 success . Should ( ) . BeFalse ( ) ;
4565 path . HasValue . Should ( ) . BeFalse ( ) ;
4666 }
67+
68+ [ Fact ]
69+ public void GetVariables_Base64EncodedPath_ReturnsFullVariable ( )
70+ {
71+ // arrange
72+ const string base64 = "K2b8F2zG9HpJxMImaYwlf0ByzArc+abc/def==" ;
73+ string value = $ "$secret:{ base64 } ";
74+
75+ // act
76+ var variables = value . GetVariables ( ) . ToArray ( ) ;
77+
78+ // assert
79+ variables . Should ( ) . HaveCount ( 1 ) ;
80+ variables [ 0 ] . ProviderName . Should ( ) . Be ( "secret" ) ;
81+ variables [ 0 ] . Path . Should ( ) . Be ( base64 ) ;
82+ }
83+
84+ [ Fact ]
85+ public void GetVariables_InterpolatedBase64EncodedPath_ReturnsFullVariable ( )
86+ {
87+ // arrange
88+ const string base64 = "K2b8F2zG9HpJxMImaYwlf0ByzArc+abc/def==" ;
89+ string value = $ "prefix-{{{{$secret:{ base64 } }}}}-suffix";
90+
91+ // act
92+ var variables = value . GetVariables ( ) . ToArray ( ) ;
93+
94+ // assert
95+ variables . Should ( ) . HaveCount ( 1 ) ;
96+ variables [ 0 ] . ProviderName . Should ( ) . Be ( "secret" ) ;
97+ variables [ 0 ] . Path . Should ( ) . Be ( base64 ) ;
98+ }
99+
100+ [ Fact ]
101+ public void ReplaceVariables_Base64EncodedPath_ReplacesFullVariable ( )
102+ {
103+ // arrange
104+ const string base64 = "K2b8F2zG9HpJxMImaYwlf0ByzArc+abc/def==" ;
105+ string value = $ "$secret:{ base64 } ";
106+
107+ // act
108+ string result = value . ReplaceVariables ( _ => "REPLACED" ) ;
109+
110+ // assert
111+ result . Should ( ) . Be ( "REPLACED" ) ;
112+ }
47113}
0 commit comments