@@ -145,7 +145,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_Succeeds_ForValidStor
145145 var context = new TestCommandContext ( ) ;
146146
147147 MockStoredAccount ( context , input , password ) ;
148- MockRemoteBasicAuthAccountIsValidNo2FA ( bitbucketApi , input , password ) ;
148+ MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , twoFactor : false ) ;
149149
150150 var provider = new BitbucketHostProvider ( context , bitbucketAuthentication . Object , bitbucketApi . Object ) ;
151151
@@ -213,7 +213,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_Succeeds_ForFreshVali
213213 MockRemoteOAuthAccountIsValid ( bitbucketApi , input , password , true ) ;
214214 }
215215
216- MockRemoteBasicAuthAccountIsValidNo2FA ( bitbucketApi , input , password ) ;
216+ MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , twoFactor : false ) ;
217217
218218 var provider = new BitbucketHostProvider ( context , bitbucketAuthentication . Object , bitbucketApi . Object ) ;
219219
@@ -236,7 +236,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_Succeeds_ForFreshVali
236236 // user is prompted for basic auth credentials
237237 MockUserEntersValidBasicCredentials ( bitbucketAuthentication , input , password ) ;
238238 // basic auth credentials are valid but 2FA is ON
239- MockRemoteBasicAuthAccountIsValidRequires2FA ( bitbucketApi , input , password ) ;
239+ MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , twoFactor : true ) ;
240240 MockRemoteOAuthAccountIsValid ( bitbucketApi , input , password , true ) ;
241241 MockRemoteValidRefreshToken ( ) ;
242242
@@ -266,7 +266,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_ForcedAuthMode_IsResp
266266 }
267267
268268 MockUserEntersValidBasicCredentials ( bitbucketAuthentication , input , password ) ;
269- MockRemoteBasicAuthAccountIsValidRequires2FA ( bitbucketApi , input , password ) ;
269+ MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , twoFactor : true ) ;
270270 bitbucketAuthentication . Setup ( m => m . ShowOAuthRequiredPromptAsync ( ) ) . ReturnsAsync ( true ) ;
271271
272272 var provider = new BitbucketHostProvider ( context , bitbucketAuthentication . Object , bitbucketApi . Object ) ;
@@ -315,7 +315,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_AlwaysRefreshCredenti
315315 MockStoredAccount ( context , input , password ) ;
316316 MockUserEntersValidBasicCredentials ( bitbucketAuthentication , input , password ) ;
317317 MockRemoteOAuthAccountIsValid ( bitbucketApi , input , password , true ) ;
318- MockRemoteBasicAuthAccountIsValidNo2FA ( bitbucketApi , input , password ) ;
318+ MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , twoFactor : false ) ;
319319
320320 var provider = new BitbucketHostProvider ( context , bitbucketAuthentication . Object , bitbucketApi . Object ) ;
321321
@@ -390,7 +390,7 @@ public async Task BitbucketHostProvider_GetCredentialAsync_ValidateTargetUriAsyn
390390 else
391391 {
392392 MockUserEntersValidBasicCredentials ( bitbucketAuthentication , input , password ) ;
393- MockRemoteBasicAuthAccountIsValidRequires2FA ( bitbucketApi , input , password ) ;
393+ MockRemoteBasicAuthAccountIsValid ( bitbucketApi , input , password , twoFactor : true ) ;
394394 MockRemoteValidRefreshToken ( ) ;
395395 bitbucketAuthentication . Setup ( m => m . ShowOAuthRequiredPromptAsync ( ) ) . ReturnsAsync ( true ) ;
396396 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
615615 . ReturnsAsync ( new CredentialsPromptResult ( AuthenticationModes . Basic , null ) ) ;
616616 }
617617
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 )
619619 {
620- var userInfo = new UserInfo ( ) { IsTwoFactorAuthenticationEnabled = twoFAEnabled } ;
620+ var userInfo = new UserInfo ( ) { IsTwoFactorAuthenticationEnabled = twoFactor } ;
621621 // Basic
622622 bitbucketApi . Setup ( x => x . GetUserInformationAsync ( input . UserName , password , false ) )
623623 . ReturnsAsync ( new RestApiResult < UserInfo > ( System . Net . HttpStatusCode . OK , userInfo ) ) ;
624624
625625 }
626626
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-
637627 private static void MockRemoteBasicAuthAccountIsInvalid ( Mock < IBitbucketRestApi > bitbucketApi , InputArguments input , string password )
638628 {
639629 var userInfo = new UserInfo ( ) ;
0 commit comments