@@ -145,7 +145,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_Succeeds_ForValidStor
145
145
var context = new TestCommandContext ( ) ;
146
146
147
147
MockStoredAccount ( context , input , password ) ;
148
- MockRemoteBasicAuthAccountIsValidNo2FA ( bitbucketApi , input , password ) ;
148
+ MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , twoFactor : false ) ;
149
149
150
150
var provider = new BitbucketHostProvider ( context , bitbucketAuthentication . Object , bitbucketApi . Object ) ;
151
151
@@ -213,7 +213,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_Succeeds_ForFreshVali
213
213
MockRemoteOAuthAccountIsValid ( bitbucketApi , input , password , true ) ;
214
214
}
215
215
216
- MockRemoteBasicAuthAccountIsValidNo2FA ( bitbucketApi , input , password ) ;
216
+ MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , twoFactor : false ) ;
217
217
218
218
var provider = new BitbucketHostProvider ( context , bitbucketAuthentication . Object , bitbucketApi . Object ) ;
219
219
@@ -236,7 +236,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_Succeeds_ForFreshVali
236
236
// user is prompted for basic auth credentials
237
237
MockUserEntersValidBasicCredentials ( bitbucketAuthentication , input , password ) ;
238
238
// basic auth credentials are valid but 2FA is ON
239
- MockRemoteBasicAuthAccountIsValidRequires2FA ( bitbucketApi , input , password ) ;
239
+ MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , twoFactor : true ) ;
240
240
MockRemoteOAuthAccountIsValid ( bitbucketApi , input , password , true ) ;
241
241
MockRemoteValidRefreshToken ( ) ;
242
242
@@ -266,7 +266,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_ForcedAuthMode_IsResp
266
266
}
267
267
268
268
MockUserEntersValidBasicCredentials ( bitbucketAuthentication , input , password ) ;
269
- MockRemoteBasicAuthAccountIsValidRequires2FA ( bitbucketApi , input , password ) ;
269
+ MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , twoFactor : true ) ;
270
270
bitbucketAuthentication . Setup ( m => m . ShowOAuthRequiredPromptAsync ( ) ) . ReturnsAsync ( true ) ;
271
271
272
272
var provider = new BitbucketHostProvider ( context , bitbucketAuthentication . Object , bitbucketApi . Object ) ;
@@ -315,7 +315,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_AlwaysRefreshCredenti
315
315
MockStoredAccount ( context , input , password ) ;
316
316
MockUserEntersValidBasicCredentials ( bitbucketAuthentication , input , password ) ;
317
317
MockRemoteOAuthAccountIsValid ( bitbucketApi , input , password , true ) ;
318
- MockRemoteBasicAuthAccountIsValidNo2FA ( bitbucketApi , input , password ) ;
318
+ MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , twoFactor : false ) ;
319
319
320
320
var provider = new BitbucketHostProvider ( context , bitbucketAuthentication . Object , bitbucketApi . Object ) ;
321
321
@@ -390,7 +390,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_ValidateTargetUriAsyn
390
390
else
391
391
{
392
392
MockUserEntersValidBasicCredentials ( bitbucketAuthentication , input , password ) ;
393
- MockRemoteBasicAuthAccountIsValidRequires2FA ( bitbucketApi , input , password ) ;
393
+ MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , twoFactor : true ) ;
394
394
MockRemoteValidRefreshToken ( ) ;
395
395
bitbucketAuthentication . Setup ( m => m . ShowOAuthRequiredPromptAsync ( ) ) . ReturnsAsync ( true ) ;
396
396
bitbucketAuthentication . Setup ( m => m . CreateOAuthCredentialsAsync ( It . IsAny < Uri > ( ) ) ) . ReturnsAsync ( new OAuth2TokenResult ( MOCK_ACCESS_TOKEN , "access_token" ) ) ;
@@ -615,25 +615,15 @@ private static void MockUserDoesNotEntersValidBasicCredentials(Mock<IBitbucketAu
615
615
. ReturnsAsync ( new CredentialsPromptResult ( AuthenticationModes . Basic , null ) ) ;
616
616
}
617
617
618
- private static void MockRemoteBasicAuthAccountIsValid ( Mock < IBitbucketRestApi > bitbucketApi , InputArguments input , string password , bool twoFAEnabled )
618
+ private static void MockRemoteBasicAuthAccountIsValid ( Mock < IBitbucketRestApi > bitbucketApi , InputArguments input , string password , bool twoFactor )
619
619
{
620
- var userInfo = new UserInfo ( ) { IsTwoFactorAuthenticationEnabled = twoFAEnabled } ;
620
+ var userInfo = new UserInfo ( ) { IsTwoFactorAuthenticationEnabled = twoFactor } ;
621
621
// Basic
622
622
bitbucketApi . Setup ( x => x . GetUserInformationAsync ( input . UserName , password , false ) )
623
623
. ReturnsAsync ( new RestApiResult < UserInfo > ( System . Net . HttpStatusCode . OK , userInfo ) ) ;
624
624
625
625
}
626
626
627
- private static void MockRemoteBasicAuthAccountIsValidRequires2FA ( Mock < IBitbucketRestApi > bitbucketApi , InputArguments input , string password )
628
- {
629
- MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , true ) ;
630
- }
631
-
632
- private static void MockRemoteBasicAuthAccountIsValidNo2FA ( Mock < IBitbucketRestApi > bitbucketApi , InputArguments input , string password )
633
- {
634
- MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , false ) ;
635
- }
636
-
637
627
private static void MockRemoteBasicAuthAccountIsInvalid ( Mock < IBitbucketRestApi > bitbucketApi , InputArguments input , string password )
638
628
{
639
629
var userInfo = new UserInfo ( ) ;
0 commit comments