@@ -568,53 +568,24 @@ private void VerifyValidateBasicAuthCredentialsRan()
568
568
bitbucketApi . Verify ( m => m . GetUserInformationAsync ( It . IsAny < string > ( ) , It . IsAny < string > ( ) , false ) , Times . Once ) ;
569
569
}
570
570
571
- private void VerifyValidateOAuthCredentialsNeverRan ( )
572
- {
573
- // never check username/password works
574
- bitbucketApi . Verify ( m => m . GetUserInformationAsync ( null , It . IsAny < string > ( ) , false ) , Times . Never ) ;
575
- }
576
-
577
571
private void VerifyValidateOAuthCredentialsRan ( )
578
572
{
579
573
// check username/password works
580
574
bitbucketApi . Verify ( m => m . GetUserInformationAsync ( null , It . IsAny < string > ( ) , true ) , Times . Once ) ;
581
575
}
582
576
583
- private void MockStoredOAuthAccount ( TestCommandContext context , InputArguments input )
584
- {
585
- // refresh token
586
- context . CredentialStore . Add ( "https://bitbucket.org/refresh_token" , new TestCredential ( input . Host , input . UserName , MOCK_REFRESH_TOKEN ) ) ;
587
- // auth token
588
- context . CredentialStore . Add ( "https://bitbucket.org" , new TestCredential ( input . Host , input . UserName , MOCK_ACCESS_TOKEN ) ) ;
589
- }
590
-
591
577
private void MockRemoteValidRefreshToken ( )
592
578
{
593
579
bitbucketAuthentication . Setup ( m => m . RefreshOAuthCredentialsAsync ( MOCK_REFRESH_TOKEN ) ) . ReturnsAsync ( new OAuth2TokenResult ( MOCK_ACCESS_TOKEN , "access_token" ) ) ;
594
580
}
595
581
596
- private static void MockInvalidRemoteBasicAccount ( Mock < IBitbucketRestApi > bitbucketApi , Mock < IBitbucketAuthentication > bitbucketAuthentication )
597
- {
598
- bitbucketAuthentication . Setup ( m => m . GetCredentialsAsync ( It . IsAny < Uri > ( ) , It . IsAny < String > ( ) , It . IsAny < AuthenticationModes > ( ) ) )
599
- . ReturnsAsync ( new CredentialsPromptResult ( AuthenticationModes . Basic , null ) ) ;
600
-
601
- bitbucketApi . Setup ( x => x . GetUserInformationAsync ( It . IsAny < String > ( ) , It . IsAny < String > ( ) , false ) )
602
- . ReturnsAsync ( new RestApiResult < UserInfo > ( System . Net . HttpStatusCode . Unauthorized ) ) ;
603
-
604
- }
605
582
private static void MockUserEntersValidBasicCredentials ( Mock < IBitbucketAuthentication > bitbucketAuthentication , InputArguments input , string password )
606
583
{
607
584
var remoteUri = input . GetRemoteUri ( ) ;
608
585
bitbucketAuthentication . Setup ( m => m . GetCredentialsAsync ( remoteUri , input . UserName , It . IsAny < AuthenticationModes > ( ) ) )
609
586
. ReturnsAsync ( new CredentialsPromptResult ( AuthenticationModes . Basic , new TestCredential ( input . Host , input . UserName , password ) ) ) ;
610
587
}
611
588
612
- private static void MockUserDoesNotEntersValidBasicCredentials ( Mock < IBitbucketAuthentication > bitbucketAuthentication )
613
- {
614
- bitbucketAuthentication . Setup ( m => m . GetCredentialsAsync ( It . IsAny < Uri > ( ) , It . IsAny < String > ( ) , It . IsAny < AuthenticationModes > ( ) ) )
615
- . ReturnsAsync ( new CredentialsPromptResult ( AuthenticationModes . Basic , null ) ) ;
616
- }
617
-
618
589
private static void MockRemoteBasicAuthAccountIsValid ( Mock < IBitbucketRestApi > bitbucketApi , InputArguments input , string password , bool twoFactor )
619
590
{
620
591
var userInfo = new UserInfo ( ) { IsTwoFactorAuthenticationEnabled = twoFactor } ;
@@ -624,15 +595,6 @@ private static void MockRemoteBasicAuthAccountIsValid(Mock<IBitbucketRestApi> bi
624
595
625
596
}
626
597
627
- private static void MockRemoteBasicAuthAccountIsInvalid ( Mock < IBitbucketRestApi > bitbucketApi , InputArguments input , string password )
628
- {
629
- var userInfo = new UserInfo ( ) ;
630
- // Basic
631
- bitbucketApi . Setup ( x => x . GetUserInformationAsync ( input . UserName , password , false ) )
632
- . ReturnsAsync ( new RestApiResult < UserInfo > ( System . Net . HttpStatusCode . Forbidden , userInfo ) ) ;
633
-
634
- }
635
-
636
598
private static void MockRemoteOAuthAccountIsValid ( Mock < IBitbucketRestApi > bitbucketApi , InputArguments input , string password , bool twoFAEnabled )
637
599
{
638
600
var userInfo = new UserInfo ( ) { IsTwoFactorAuthenticationEnabled = twoFAEnabled } ;
@@ -648,14 +610,6 @@ private static void MockStoredAccount(TestCommandContext context, InputArguments
648
610
context . CredentialStore . Add ( remoteUrl , new TestCredential ( input . Host , input . UserName , password ) ) ;
649
611
}
650
612
651
- private static void MockValidStoredOAuthUser ( TestCommandContext context , Mock < IBitbucketRestApi > bitbucketApi )
652
- {
653
- var userInfo = new UserInfo ( ) { IsTwoFactorAuthenticationEnabled = false } ;
654
- bitbucketApi . Setup ( x => x . GetUserInformationAsync ( "jsquire" , "password1" , false ) )
655
- . ReturnsAsync ( new RestApiResult < UserInfo > ( System . Net . HttpStatusCode . OK , userInfo ) ) ;
656
- context . CredentialStore . Add ( "https://bitbucket.org" , new TestCredential ( "https://bitbucket.org" , "jsquire" , "password1" ) ) ;
657
- }
658
-
659
613
#endregion
660
614
}
661
615
}
0 commit comments