@@ -272,11 +272,12 @@ func TestGitRepositoryReconciler_reconcileSource_emptyRepository(t *testing.T) {
272272
273273func TestGitRepositoryReconciler_reconcileSource_authStrategy (t * testing.T ) {
274274 type options struct {
275- username string
276- password string
277- publicKey []byte
278- privateKey []byte
279- ca []byte
275+ username string
276+ password string
277+ publicKey []byte
278+ privateKey []byte
279+ ca []byte
280+ bearerToken []byte
280281 }
281282
282283 tests := []struct {
@@ -381,9 +382,29 @@ func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) {
381382 * conditions .UnknownCondition (meta .ReadyCondition , meta .ProgressingReason , "foo" ),
382383 },
383384 },
384- // TODO: Add test case for HTTPS with bearer token auth secret. It
385- // depends on gitkit to have support for bearer token based
386- // authentication.
385+ {
386+ name : "HTTP with bearer-token secret makes Reconciling=True" ,
387+ protocol : "http" ,
388+ server : options {
389+ bearerToken : []byte ("ghp_baM3qnEE0O41WluceBL4udt2N0vVZS4R0hMS" ),
390+ },
391+ secret : & corev1.Secret {
392+ ObjectMeta : metav1.ObjectMeta {
393+ Name : "bearer-token" ,
394+ },
395+ Data : map [string ][]byte {
396+ "bearerToken" : []byte ("ghp_baM3qnEE0O41WluceBL4udt2N0vVZS4R0hMS" ),
397+ },
398+ },
399+ beforeFunc : func (obj * sourcev1.GitRepository ) {
400+ obj .Spec .SecretRef = & meta.LocalObjectReference {Name : "bearer-token" }
401+ },
402+ want : sreconcile .ResultSuccess ,
403+ assertConditions : []metav1.Condition {
404+ * conditions .TrueCondition (meta .ReconcilingCondition , meta .ProgressingReason , "building artifact: new upstream revision 'master@sha1:<commit>'" ),
405+ * conditions .UnknownCondition (meta .ReadyCondition , meta .ProgressingReason , "building artifact: new upstream revision 'master@sha1:<commit>'" ),
406+ },
407+ },
387408 {
388409 name : "SSH with private key secret makes Reconciling=True" ,
389410 protocol : "ssh" ,
@@ -405,7 +426,7 @@ func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) {
405426 want : sreconcile .ResultSuccess ,
406427 assertConditions : []metav1.Condition {
407428 * conditions .TrueCondition (meta .ReconcilingCondition , meta .ProgressingReason , "building artifact: new upstream revision 'master@sha1:<commit>'" ),
408- * conditions .UnknownCondition (meta .ReadyCondition , meta .ProgressingReason , "building artifact: new upstream revision 'master@sha1:<commit>" ),
429+ * conditions .UnknownCondition (meta .ReadyCondition , meta .ProgressingReason , "building artifact: new upstream revision 'master@sha1:<commit>' " ),
409430 },
410431 },
411432 {
0 commit comments