5
5
using System . Threading . Tasks ;
6
6
using Microsoft . Git . CredentialManager ;
7
7
using Microsoft . Git . CredentialManager . Authentication ;
8
+ using Microsoft . Git . CredentialManager . Tests ;
8
9
using Microsoft . Git . CredentialManager . Tests . Objects ;
9
10
using Moq ;
10
11
using Xunit ;
@@ -14,6 +15,8 @@ namespace Microsoft.AzureRepos.Tests
14
15
{
15
16
public class AzureReposHostProviderTests
16
17
{
18
+ private static readonly string HelperKey =
19
+ $ "{ Constants . GitConfiguration . Credential . SectionName } .{ Constants . GitConfiguration . Credential . Helper } ";
17
20
private static readonly string AzDevUseHttpPathKey =
18
21
$ "{ Constants . GitConfiguration . Credential . SectionName } .https://dev.azure.com.{ Constants . GitConfiguration . Credential . UseHttpPath } ";
19
22
@@ -222,7 +225,6 @@ public async Task AzureReposHostProvider_ConfigureAsync_UseHttpPathUnset_SetsUse
222
225
Assert . Equal ( "true" , actualValues [ 0 ] ) ;
223
226
}
224
227
225
-
226
228
[ Fact ]
227
229
public async Task AzureReposHostProvider_UnconfigureAsync_UseHttpPathSet_RemovesEntry ( )
228
230
{
@@ -235,5 +237,48 @@ public async Task AzureReposHostProvider_UnconfigureAsync_UseHttpPathSet_Removes
235
237
236
238
Assert . Empty ( context . Git . GlobalConfiguration . Dictionary ) ;
237
239
}
240
+
241
+ [ PlatformFact ( Platforms . Windows ) ]
242
+ public async Task AzureReposHostProvider_UnconfigureAsync_System_Windows_UseHttpPathSetAndManagerCoreHelper_DoesNotRemoveEntry ( )
243
+ {
244
+ var context = new TestCommandContext ( ) ;
245
+ var provider = new AzureReposHostProvider ( context ) ;
246
+
247
+ context . Git . SystemConfiguration . Dictionary [ HelperKey ] = new List < string > { "manager-core" } ;
248
+ context . Git . SystemConfiguration . Dictionary [ AzDevUseHttpPathKey ] = new List < string > { "true" } ;
249
+
250
+ await provider . UnconfigureAsync ( ConfigurationTarget . System ) ;
251
+
252
+ Assert . True ( context . Git . SystemConfiguration . Dictionary . TryGetValue ( AzDevUseHttpPathKey , out IList < string > actualValues ) ) ;
253
+ Assert . Single ( actualValues ) ;
254
+ Assert . Equal ( "true" , actualValues [ 0 ] ) ;
255
+ }
256
+
257
+ [ PlatformFact ( Platforms . Windows ) ]
258
+ public async Task AzureReposHostProvider_UnconfigureAsync_System_Windows_UseHttpPathSetNoManagerCoreHelper_RemovesEntry ( )
259
+ {
260
+ var context = new TestCommandContext ( ) ;
261
+ var provider = new AzureReposHostProvider ( context ) ;
262
+
263
+ context . Git . SystemConfiguration . Dictionary [ AzDevUseHttpPathKey ] = new List < string > { "true" } ;
264
+
265
+ await provider . UnconfigureAsync ( ConfigurationTarget . System ) ;
266
+
267
+ Assert . Empty ( context . Git . SystemConfiguration . Dictionary ) ;
268
+ }
269
+
270
+ [ PlatformFact ( Platforms . Windows ) ]
271
+ public async Task AzureReposHostProvider_UnconfigureAsync_User_Windows_UseHttpPathSetAndManagerCoreHelper_RemovesEntry ( )
272
+ {
273
+ var context = new TestCommandContext ( ) ;
274
+ var provider = new AzureReposHostProvider ( context ) ;
275
+
276
+ context . Git . GlobalConfiguration . Dictionary [ HelperKey ] = new List < string > { "manager-core" } ;
277
+ context . Git . GlobalConfiguration . Dictionary [ AzDevUseHttpPathKey ] = new List < string > { "true" } ;
278
+
279
+ await provider . UnconfigureAsync ( ConfigurationTarget . User ) ;
280
+
281
+ Assert . False ( context . Git . GlobalConfiguration . Dictionary . TryGetValue ( AzDevUseHttpPathKey , out _ ) ) ;
282
+ }
238
283
}
239
284
}
0 commit comments