@@ -3705,188 +3705,3 @@ func TestOCIContentConfigChanged(t *testing.T) {
3705
3705
})
3706
3706
}
3707
3707
}
3708
-
3709
- func TestOCIRepositoryReconciler_getProxyURL (t * testing.T ) {
3710
- tests := []struct {
3711
- name string
3712
- ociRepo * sourcev1.OCIRepository
3713
- objects []client.Object
3714
- expectedURL string
3715
- expectedErr string
3716
- }{
3717
- {
3718
- name : "empty proxySecretRef" ,
3719
- ociRepo : & sourcev1.OCIRepository {
3720
- Spec : sourcev1.OCIRepositorySpec {
3721
- ProxySecretRef : nil ,
3722
- },
3723
- },
3724
- },
3725
- {
3726
- name : "non-existing proxySecretRef" ,
3727
- ociRepo : & sourcev1.OCIRepository {
3728
- Spec : sourcev1.OCIRepositorySpec {
3729
- ProxySecretRef : & meta.LocalObjectReference {
3730
- Name : "non-existing" ,
3731
- },
3732
- },
3733
- },
3734
- expectedErr : "secrets \" non-existing\" not found" ,
3735
- },
3736
- {
3737
- name : "missing address in proxySecretRef" ,
3738
- ociRepo : & sourcev1.OCIRepository {
3739
- Spec : sourcev1.OCIRepositorySpec {
3740
- ProxySecretRef : & meta.LocalObjectReference {
3741
- Name : "dummy" ,
3742
- },
3743
- },
3744
- },
3745
- objects : []client.Object {
3746
- & corev1.Secret {
3747
- ObjectMeta : metav1.ObjectMeta {
3748
- Name : "dummy" ,
3749
- },
3750
- Data : map [string ][]byte {},
3751
- },
3752
- },
3753
- expectedErr : "invalid proxy secret '/dummy': key 'address' is missing" ,
3754
- },
3755
- {
3756
- name : "invalid address in proxySecretRef" ,
3757
- ociRepo : & sourcev1.OCIRepository {
3758
- Spec : sourcev1.OCIRepositorySpec {
3759
- ProxySecretRef : & meta.LocalObjectReference {
3760
- Name : "dummy" ,
3761
- },
3762
- },
3763
- },
3764
- objects : []client.Object {
3765
- & corev1.Secret {
3766
- ObjectMeta : metav1.ObjectMeta {
3767
- Name : "dummy" ,
3768
- },
3769
- Data : map [string ][]byte {
3770
- "address" : {0x7f },
3771
- },
3772
- },
3773
- },
3774
- expectedErr : "failed to parse proxy address '\x7f ': parse \" \\ x7f\" : net/url: invalid control character in URL" ,
3775
- },
3776
- {
3777
- name : "no user, no password" ,
3778
- ociRepo : & sourcev1.OCIRepository {
3779
- Spec : sourcev1.OCIRepositorySpec {
3780
- ProxySecretRef : & meta.LocalObjectReference {
3781
- Name : "dummy" ,
3782
- },
3783
- },
3784
- },
3785
- objects : []client.Object {
3786
- & corev1.Secret {
3787
- ObjectMeta : metav1.ObjectMeta {
3788
- Name : "dummy" ,
3789
- },
3790
- Data : map [string ][]byte {
3791
- "address" : []byte ("http://proxy.example.com" ),
3792
- },
3793
- },
3794
- },
3795
- expectedURL : "http://proxy.example.com" ,
3796
- },
3797
- {
3798
- name : "user, no password" ,
3799
- ociRepo : & sourcev1.OCIRepository {
3800
- Spec : sourcev1.OCIRepositorySpec {
3801
- ProxySecretRef : & meta.LocalObjectReference {
3802
- Name : "dummy" ,
3803
- },
3804
- },
3805
- },
3806
- objects : []client.Object {
3807
- & corev1.Secret {
3808
- ObjectMeta : metav1.ObjectMeta {
3809
- Name : "dummy" ,
3810
- },
3811
- Data : map [string ][]byte {
3812
- "address" : []byte ("http://proxy.example.com" ),
3813
- "username" : []byte ("user" ),
3814
- },
3815
- },
3816
- },
3817
- expectedURL : "http://user:@proxy.example.com" ,
3818
- },
3819
- {
3820
- name : "no user, password" ,
3821
- ociRepo : & sourcev1.OCIRepository {
3822
- Spec : sourcev1.OCIRepositorySpec {
3823
- ProxySecretRef : & meta.LocalObjectReference {
3824
- Name : "dummy" ,
3825
- },
3826
- },
3827
- },
3828
- objects : []client.Object {
3829
- & corev1.Secret {
3830
- ObjectMeta : metav1.ObjectMeta {
3831
- Name : "dummy" ,
3832
- },
3833
- Data : map [string ][]byte {
3834
- "address" : []byte ("http://proxy.example.com" ),
3835
- "password" : []byte ("password" ),
3836
- },
3837
- },
3838
- },
3839
- expectedURL :
"http://:[email protected] " ,
3840
- },
3841
- {
3842
- name : "user, password" ,
3843
- ociRepo : & sourcev1.OCIRepository {
3844
- Spec : sourcev1.OCIRepositorySpec {
3845
- ProxySecretRef : & meta.LocalObjectReference {
3846
- Name : "dummy" ,
3847
- },
3848
- },
3849
- },
3850
- objects : []client.Object {
3851
- & corev1.Secret {
3852
- ObjectMeta : metav1.ObjectMeta {
3853
- Name : "dummy" ,
3854
- },
3855
- Data : map [string ][]byte {
3856
- "address" : []byte ("http://proxy.example.com" ),
3857
- "username" : []byte ("user" ),
3858
- "password" : []byte ("password" ),
3859
- },
3860
- },
3861
- },
3862
- expectedURL :
"http://user:[email protected] " ,
3863
- },
3864
- }
3865
-
3866
- for _ , tt := range tests {
3867
- t .Run (tt .name , func (t * testing.T ) {
3868
- g := NewWithT (t )
3869
-
3870
- c := fakeclient .NewClientBuilder ().
3871
- WithScheme (testEnv .Scheme ()).
3872
- WithObjects (tt .objects ... ).
3873
- Build ()
3874
-
3875
- r := & OCIRepositoryReconciler {
3876
- Client : c ,
3877
- }
3878
-
3879
- u , err := r .getProxyURL (ctx , tt .ociRepo )
3880
- if tt .expectedErr == "" {
3881
- g .Expect (err ).To (BeNil ())
3882
- } else {
3883
- g .Expect (err .Error ()).To (ContainSubstring (tt .expectedErr ))
3884
- }
3885
- if tt .expectedURL == "" {
3886
- g .Expect (u ).To (BeNil ())
3887
- } else {
3888
- g .Expect (u .String ()).To (Equal (tt .expectedURL ))
3889
- }
3890
- })
3891
- }
3892
- }
0 commit comments