@@ -22,7 +22,6 @@ public void CanListRemoteReferences(string url)
2222 Remote remote = repo . Network . Remotes . Add ( remoteName , url ) ;
2323 IList < Reference > references = repo . Network . ListReferences ( remote ) . ToList ( ) ;
2424
25-
2625 foreach ( var reference in references )
2726 {
2827 // None of those references point to an existing
@@ -136,6 +135,133 @@ public void CanListRemoteReferencesWithCredentials()
136135 }
137136 }
138137
138+ [ Theory ]
139+ [ InlineData ( "http://github.com/libgit2/TestGitRepository" ) ]
140+ [ InlineData ( "https://github.com/libgit2/TestGitRepository" ) ]
141+ public void CanListRemoteReferencesWithListRemoteOptions ( string url )
142+ {
143+ string remoteName = "testRemote" ;
144+
145+ string repoPath = InitNewRepository ( ) ;
146+
147+ using ( var repo = new Repository ( repoPath ) )
148+ {
149+ Remote remote = repo . Network . Remotes . Add ( remoteName , url ) ;
150+ var options = new ListRemoteOptions
151+ {
152+ ProxyOptions = new ProxyOptions ( )
153+ } ;
154+
155+ IList < Reference > references = repo . Network . ListReferences ( remote , options ) . ToList ( ) ;
156+
157+ foreach ( var reference in references )
158+ {
159+ Assert . Null ( reference . ResolveToDirectReference ( ) . Target ) ;
160+ }
161+
162+ List < Tuple < string , string > > actualRefs = references .
163+ Select ( directRef => new Tuple < string , string > ( directRef . CanonicalName , directRef . ResolveToDirectReference ( )
164+ . TargetIdentifier ) ) . ToList ( ) ;
165+
166+ Assert . Equal ( TestRemoteRefs . ExpectedRemoteRefs . Count , actualRefs . Count ) ;
167+ Assert . True ( references . Single ( reference => reference . CanonicalName == "HEAD" ) is SymbolicReference ) ;
168+ for ( int i = 0 ; i < TestRemoteRefs . ExpectedRemoteRefs . Count ; i ++ )
169+ {
170+ Assert . Equal ( TestRemoteRefs . ExpectedRemoteRefs [ i ] . Item2 , actualRefs [ i ] . Item2 ) ;
171+ Assert . Equal ( TestRemoteRefs . ExpectedRemoteRefs [ i ] . Item1 , actualRefs [ i ] . Item1 ) ;
172+ }
173+ }
174+ }
175+
176+ [ Theory ]
177+ [ InlineData ( "http://github.com/libgit2/TestGitRepository" ) ]
178+ [ InlineData ( "https://github.com/libgit2/TestGitRepository" ) ]
179+ public void CanListRemoteReferencesFromUrlWithListRemoteOptions ( string url )
180+ {
181+ string repoPath = InitNewRepository ( ) ;
182+
183+ using ( var repo = new Repository ( repoPath ) )
184+ {
185+ var options = new ListRemoteOptions
186+ {
187+ ProxyOptions = new ProxyOptions ( )
188+ } ;
189+
190+ IList < Reference > references = repo . Network . ListReferences ( url , options ) . ToList ( ) ;
191+
192+ foreach ( var reference in references )
193+ {
194+ Assert . Null ( reference . ResolveToDirectReference ( ) . Target ) ;
195+ }
196+
197+ List < Tuple < string , string > > actualRefs = references .
198+ Select ( directRef => new Tuple < string , string > ( directRef . CanonicalName , directRef . ResolveToDirectReference ( )
199+ . TargetIdentifier ) ) . ToList ( ) ;
200+
201+ Assert . Equal ( TestRemoteRefs . ExpectedRemoteRefs . Count , actualRefs . Count ) ;
202+ Assert . True ( references . Single ( reference => reference . CanonicalName == "HEAD" ) is SymbolicReference ) ;
203+ for ( int i = 0 ; i < TestRemoteRefs . ExpectedRemoteRefs . Count ; i ++ )
204+ {
205+ Assert . Equal ( TestRemoteRefs . ExpectedRemoteRefs [ i ] . Item2 , actualRefs [ i ] . Item2 ) ;
206+ Assert . Equal ( TestRemoteRefs . ExpectedRemoteRefs [ i ] . Item1 , actualRefs [ i ] . Item1 ) ;
207+ }
208+ }
209+ }
210+
211+ [ Theory ]
212+ [ InlineData ( "https://github.com/libgit2/TestGitRepository" ) ]
213+ public void CanListRemoteReferencesWithCertificateCheckCallback ( string url )
214+ {
215+ string repoPath = InitNewRepository ( ) ;
216+
217+ bool certificateCheckCalled = false ;
218+
219+ using ( var repo = new Repository ( repoPath ) )
220+ {
221+ var options = new ListRemoteOptions
222+ {
223+ CertificateCheck = ( cert , valid , host ) =>
224+ {
225+ certificateCheckCalled = true ;
226+ return true ;
227+ }
228+ } ;
229+
230+ IList < Reference > references = repo . Network . ListReferences ( url , options ) . ToList ( ) ;
231+
232+ Assert . True ( certificateCheckCalled ) ;
233+ Assert . NotEmpty ( references ) ;
234+ }
235+ }
236+
237+ [ SkippableFact ]
238+ public void CanListRemoteReferencesWithCredentialsInListRemoteOptions ( )
239+ {
240+ InconclusiveIf ( ( ) => string . IsNullOrEmpty ( Constants . PrivateRepoUrl ) ,
241+ "Populate Constants.PrivateRepo* to run this test" ) ;
242+
243+ string remoteName = "origin" ;
244+
245+ string repoPath = InitNewRepository ( ) ;
246+
247+ using ( var repo = new Repository ( repoPath ) )
248+ {
249+ Remote remote = repo . Network . Remotes . Add ( remoteName , Constants . PrivateRepoUrl ) ;
250+
251+ var options = new ListRemoteOptions
252+ {
253+ CredentialsProvider = Constants . PrivateRepoCredentials
254+ } ;
255+
256+ var references = repo . Network . ListReferences ( remote , options ) ;
257+
258+ foreach ( var reference in references )
259+ {
260+ Assert . NotNull ( reference ) ;
261+ }
262+ }
263+ }
264+
139265 [ Theory ]
140266 [ InlineData ( FastForwardStrategy . Default ) ]
141267 [ InlineData ( FastForwardStrategy . NoFastForward ) ]
0 commit comments