@@ -272,11 +272,12 @@ func TestGitRepositoryReconciler_reconcileSource_emptyRepository(t *testing.T) {
272
272
273
273
func TestGitRepositoryReconciler_reconcileSource_authStrategy (t * testing.T ) {
274
274
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
280
281
}
281
282
282
283
tests := []struct {
@@ -381,9 +382,29 @@ func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) {
381
382
* conditions .UnknownCondition (meta .ReadyCondition , meta .ProgressingReason , "foo" ),
382
383
},
383
384
},
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-auth" }
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
+ },
387
408
{
388
409
name : "SSH with private key secret makes Reconciling=True" ,
389
410
protocol : "ssh" ,
@@ -405,7 +426,7 @@ func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) {
405
426
want : sreconcile .ResultSuccess ,
406
427
assertConditions : []metav1.Condition {
407
428
* 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>' " ),
409
430
},
410
431
},
411
432
{
0 commit comments