@@ -13,6 +13,9 @@ namespace Microsoft.AzureRepos.Tests
13
13
{
14
14
public class AzureReposHostProviderTests
15
15
{
16
+ private static readonly string AzDevUseHttpPathKey =
17
+ $ "{ Constants . GitConfiguration . Credential . SectionName } .https://dev.azure.com.{ Constants . GitConfiguration . Credential . UseHttpPath } ";
18
+
16
19
[ Fact ]
17
20
public void AzureReposProvider_IsSupported_AzureHost_UnencryptedHttp_ReturnsTrue ( )
18
21
{
@@ -171,5 +174,84 @@ public async Task AzureReposProvider_GetCredentialAsync_ReturnsCredential()
171
174
Assert . Equal ( personalAccessToken , credential . Password ) ;
172
175
// We don't care about the username value
173
176
}
177
+
178
+ [ Fact ]
179
+ public async Task AzureReposHostProvider_ConfigureAsync_UseHttpPathSetTrue_DoesNothing ( )
180
+ {
181
+ var provider = new AzureReposHostProvider ( new TestCommandContext ( ) ) ;
182
+
183
+ var environment = new TestEnvironment ( ) ;
184
+ var config = new TestGitConfiguration ( new Dictionary < string , IList < string > >
185
+ {
186
+ [ AzDevUseHttpPathKey ] = new List < string > { "true" }
187
+ } ) ;
188
+
189
+ await provider . ConfigureAsync (
190
+ environment , EnvironmentVariableTarget . User ,
191
+ config , GitConfigurationLevel . Global ) ;
192
+
193
+ Assert . Single ( config . Dictionary ) ;
194
+ Assert . True ( config . Dictionary . TryGetValue ( AzDevUseHttpPathKey , out IList < string > actualValues ) ) ;
195
+ Assert . Single ( actualValues ) ;
196
+ Assert . Equal ( "true" , actualValues [ 0 ] ) ;
197
+ }
198
+
199
+ [ Fact ]
200
+ public async Task AzureReposHostProvider_ConfigureAsync_UseHttpPathSetFalse_SetsUseHttpPathTrue ( )
201
+ {
202
+ var provider = new AzureReposHostProvider ( new TestCommandContext ( ) ) ;
203
+
204
+ var environment = new TestEnvironment ( ) ;
205
+ var config = new TestGitConfiguration ( new Dictionary < string , IList < string > >
206
+ {
207
+ [ AzDevUseHttpPathKey ] = new List < string > { "false" }
208
+ } ) ;
209
+
210
+ await provider . ConfigureAsync (
211
+ environment , EnvironmentVariableTarget . User ,
212
+ config , GitConfigurationLevel . Global ) ;
213
+
214
+ Assert . Single ( config . Dictionary ) ;
215
+ Assert . True ( config . Dictionary . TryGetValue ( AzDevUseHttpPathKey , out IList < string > actualValues ) ) ;
216
+ Assert . Single ( actualValues ) ;
217
+ Assert . Equal ( "true" , actualValues [ 0 ] ) ;
218
+ }
219
+
220
+ [ Fact ]
221
+ public async Task AzureReposHostProvider_ConfigureAsync_UseHttpPathUnset_SetsUseHttpPathTrue ( )
222
+ {
223
+ var provider = new AzureReposHostProvider ( new TestCommandContext ( ) ) ;
224
+
225
+ var environment = new TestEnvironment ( ) ;
226
+ var config = new TestGitConfiguration ( ) ;
227
+
228
+ await provider . ConfigureAsync (
229
+ environment , EnvironmentVariableTarget . User ,
230
+ config , GitConfigurationLevel . Global ) ;
231
+
232
+ Assert . Single ( config . Dictionary ) ;
233
+ Assert . True ( config . Dictionary . TryGetValue ( AzDevUseHttpPathKey , out IList < string > actualValues ) ) ;
234
+ Assert . Single ( actualValues ) ;
235
+ Assert . Equal ( "true" , actualValues [ 0 ] ) ;
236
+ }
237
+
238
+
239
+ [ Fact ]
240
+ public async Task AzureReposHostProvider_UnconfigureAsync_UseHttpPathSet_RemovesEntry ( )
241
+ {
242
+ var provider = new AzureReposHostProvider ( new TestCommandContext ( ) ) ;
243
+
244
+ var environment = new TestEnvironment ( ) ;
245
+ var config = new TestGitConfiguration ( new Dictionary < string , IList < string > >
246
+ {
247
+ [ AzDevUseHttpPathKey ] = new List < string > { "true" }
248
+ } ) ;
249
+
250
+ await provider . UnconfigureAsync (
251
+ environment , EnvironmentVariableTarget . User ,
252
+ config , GitConfigurationLevel . Global ) ;
253
+
254
+ Assert . Empty ( config . Dictionary ) ;
255
+ }
174
256
}
175
257
}
0 commit comments