@@ -195,19 +195,33 @@ public void CanCloneWithCredentials()
195195 }
196196 }
197197
198+ static Credentials CreateUsernamePasswordCredentials ( string user , string pass , bool secure )
199+ {
200+ if ( secure )
201+ {
202+ return new SecureUsernamePasswordCredentials
203+ {
204+ Username = user ,
205+ Password = Constants . StringToSecureString ( pass ) ,
206+ } ;
207+ }
208+
209+ return new UsernamePasswordCredentials {
210+ Username = user ,
211+ Password = pass ,
212+ } ;
213+ }
214+
198215 [ Theory ]
199- [ InlineData ( "https://libgit2@bitbucket.org/libgit2/testgitrepository.git" , "libgit3" , "libgit3" ) ]
200- public void CanCloneFromBBWithCredentials ( string url , string user , string pass )
216+ [ InlineData ( "https://libgit2@bitbucket.org/libgit2/testgitrepository.git" , "libgit3" , "libgit3" , true ) ]
217+ [ InlineData ( "https://libgit2@bitbucket.org/libgit2/testgitrepository.git" , "libgit3" , "libgit3" , false ) ]
218+ public void CanCloneFromBBWithCredentials ( string url , string user , string pass , bool secure )
201219 {
202220 var scd = BuildSelfCleaningDirectory ( ) ;
203221
204222 string clonedRepoPath = Repository . Clone ( url , scd . DirectoryPath , new CloneOptions ( )
205223 {
206- CredentialsProvider = ( _url , _user , _cred ) => new UsernamePasswordCredentials
207- {
208- Username = user ,
209- Password = pass ,
210- }
224+ CredentialsProvider = ( _url , _user , _cred ) => CreateUsernamePasswordCredentials ( user , pass , secure )
211225 } ) ;
212226
213227 using ( var repo = new Repository ( clonedRepoPath ) )
0 commit comments