fluxcd / source-controller

The GitOps Toolkit source management component
https://fluxcd.io
Apache License 2.0
239 stars 186 forks source link

Git: Add test for http bearer token auth #1005

Open darkowlzz opened 1 year ago

darkowlzz commented 1 year ago

Add a test case for http bearer token in https://github.com/fluxcd/source-controller/blob/9dc4271d30d792cc94963032cca303bfe9a7a8a9/controllers/gitrepository_controller_test.go#L334-L336 once bearer token authentication support is added in gitkit, refer https://github.com/fluxcd/gitkit/pull/11/, and gittestserver.

Refer https://github.com/fluxcd/pkg/pull/442 for more discussions around bearer token support.

Santosh1176 commented 1 year ago

Hey @darkowlzz. Can I take this up? I was working on this task and the test are passing:

santosh@source-controller:fix-1005$ make test GO_TEST_ARGS="-v -run=TestGitRepositoryReconciler_reconcileSource_authStrategy"
mkdir -p /media/coding/coding/contrib/flux/source-controller/build/testbin
/media/coding/coding/contrib/flux/source-controller/build/gobin/setup-envtest use latest --arch=amd64 --bin-dir=/media/coding/coding/contrib/flux/source-controller/build/testbin
Version: 1.26.1
OS/Arch: linux/amd64
md5: q6yUrWDnTJP88foqTLkatA==
Path: /media/coding/coding/contrib/flux/source-controller/build/testbin/k8s/1.26.1-linux-amd64
chmod -R u+w /media/coding/coding/contrib/flux/source-controller/build/testbin
cd api; go test -v -run=TestGitRepositoryReconciler_reconcileSource_authStrategy ./... -coverprofile cover.out
?       github.com/fluxcd/source-controller/api/v1beta1 [no test files]
testing: warning: no tests to run
PASS
<snip>
<snip>

--- PASS: TestGitRepositoryReconciler_reconcileSource_authStrategy (0.99s)
    --- PASS: TestGitRepositoryReconciler_reconcileSource_authStrategy/HTTP_without_secretRef_makes_Reconciling=True (0.06s)
    --- PASS: TestGitRepositoryReconciler_reconcileSource_authStrategy/HTTP_with_Basic_Auth_secret_makes_Reconciling=True (0.06s)
    --- PASS: TestGitRepositoryReconciler_reconcileSource_authStrategy/HTTPS_with_CAFile_secret_makes_Reconciling=True (0.06s)
    --- PASS: TestGitRepositoryReconciler_reconcileSource_authStrategy/HTTPS_with_invalid_CAFile_secret_makes_CheckoutFailed=True_and_returns_error (0.03s)
    --> PASS: TestGitRepositoryReconciler_reconcileSource_authStrategy/HTTP_with_Bearer_token_secret_makes_Reconciling=True (0.06s)
    --- PASS: TestGitRepositoryReconciler_reconcileSource_authStrategy/SSH_with_private_key_secret_makes_Reconciling=True (0.30s)
    --- PASS: TestGitRepositoryReconciler_reconcileSource_authStrategy/SSH_with_password_protected_private_key_secret_makes_Reconciling=True (0.34s)
    --- PASS: TestGitRepositoryReconciler_reconcileSource_authStrategy/Include_get_failure_makes_CheckoutFailed=True_and_returns_error (0.03s)
    --- PASS: TestGitRepositoryReconciler_reconcileSource_authStrategy/Existing_artifact_makes_ArtifactOutdated=True (0.05s)
PASS
coverage: 4.1% of statements
<snip>
<snip>

coverage: 28.6% of statements
ok      github.com/fluxcd/source-controller/pkg/minio   3.666s  coverage: 28.6% of statements [no tests to run]
santosh@source-controller:fix-1005$