@@ -195,19 +195,33 @@ public void CanCloneWithCredentials()
195
195
}
196
196
}
197
197
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
+
198
215
[ Theory ]
199
- [ InlineData ( "https://[email protected] /libgit2/testgitrepository.git" , "libgit3" , "libgit3" ) ]
200
- public void CanCloneFromBBWithCredentials ( string url , string user , string pass )
216
+ [ InlineData ( "https://[email protected] /libgit2/testgitrepository.git" , "libgit3" , "libgit3" , true ) ]
217
+ [ InlineData ( "https://[email protected] /libgit2/testgitrepository.git" , "libgit3" , "libgit3" , false ) ]
218
+ public void CanCloneFromBBWithCredentials ( string url , string user , string pass , bool secure )
201
219
{
202
220
var scd = BuildSelfCleaningDirectory ( ) ;
203
221
204
222
string clonedRepoPath = Repository . Clone ( url , scd . DirectoryPath , new CloneOptions ( )
205
223
{
206
- CredentialsProvider = ( _url , _user , _cred ) => new UsernamePasswordCredentials
207
- {
208
- Username = user ,
209
- Password = pass ,
210
- }
224
+ CredentialsProvider = ( _url , _user , _cred ) => CreateUsernamePasswordCredentials ( user , pass , secure )
211
225
} ) ;
212
226
213
227
using ( var repo = new Repository ( clonedRepoPath ) )
0 commit comments