@@ -67,6 +67,7 @@ func TestIssuerReconcile(t *testing.T) {
6767 objects []client.Object
6868 healthCheckerBuilder command.HealthCheckerBuilder
6969 clusterResourceNamespace string
70+ defaultHealthCheckInterval * time.Duration
7071 expectedResult ctrl.Result
7172 expectedError error
7273 expectedReadyConditionStatus commandissuerv1alpha1.ConditionStatus
@@ -114,7 +115,7 @@ func TestIssuerReconcile(t *testing.T) {
114115 healthCheckerBuilder : newFakeHealthCheckerBuilder (nil , nil , false ),
115116 expectedReadyConditionStatus : commandissuerv1alpha1 .ConditionTrue ,
116117 expectedMetadataSupportedConditionStatus : commandissuerv1alpha1 .ConditionFalse ,
117- expectedResult : ctrl.Result {RequeueAfter : defaultHealthCheckInterval },
118+ expectedResult : ctrl.Result {RequeueAfter : time . Minute },
118119 },
119120 "issuer-basicauth-no-username" : {
120121 kind : "Issuer" ,
@@ -236,7 +237,7 @@ func TestIssuerReconcile(t *testing.T) {
236237 clusterResourceNamespace : "kube-system" ,
237238 expectedReadyConditionStatus : commandissuerv1alpha1 .ConditionTrue ,
238239 expectedMetadataSupportedConditionStatus : commandissuerv1alpha1 .ConditionFalse ,
239- expectedResult : ctrl.Result {RequeueAfter : defaultHealthCheckInterval },
240+ expectedResult : ctrl.Result {RequeueAfter : time . Minute },
240241 },
241242 "success-issuer-oauth" : {
242243 kind : "Issuer" ,
@@ -277,7 +278,7 @@ func TestIssuerReconcile(t *testing.T) {
277278 healthCheckerBuilder : newFakeHealthCheckerBuilder (nil , nil , false ),
278279 expectedReadyConditionStatus : commandissuerv1alpha1 .ConditionTrue ,
279280 expectedMetadataSupportedConditionStatus : commandissuerv1alpha1 .ConditionFalse ,
280- expectedResult : ctrl.Result {RequeueAfter : defaultHealthCheckInterval },
281+ expectedResult : ctrl.Result {RequeueAfter : time . Minute },
281282 },
282283 "issuer-oauth-no-tokenurl" : {
283284 kind : "Issuer" ,
@@ -447,7 +448,7 @@ func TestIssuerReconcile(t *testing.T) {
447448 clusterResourceNamespace : "kube-system" ,
448449 expectedReadyConditionStatus : commandissuerv1alpha1 .ConditionTrue ,
449450 expectedMetadataSupportedConditionStatus : commandissuerv1alpha1 .ConditionFalse ,
450- expectedResult : ctrl.Result {RequeueAfter : defaultHealthCheckInterval },
451+ expectedResult : ctrl.Result {RequeueAfter : time . Minute },
451452 },
452453 "issuer-kind-Unrecognized" : {
453454 kind : "UnrecognizedType" ,
@@ -733,7 +734,7 @@ func TestIssuerReconcile(t *testing.T) {
733734 clusterResourceNamespace : "kube-system" ,
734735 expectedReadyConditionStatus : commandissuerv1alpha1 .ConditionTrue ,
735736 expectedMetadataSupportedConditionStatus : commandissuerv1alpha1 .ConditionTrue ,
736- expectedResult : ctrl.Result {RequeueAfter : defaultHealthCheckInterval },
737+ expectedResult : ctrl.Result {RequeueAfter : time . Minute },
737738 },
738739 "success-nil-healthcheck-interval-defaults" : {
739740 kind : "ClusterIssuer" ,
@@ -777,6 +778,46 @@ func TestIssuerReconcile(t *testing.T) {
777778 expectedMetadataSupportedConditionStatus : commandissuerv1alpha1 .ConditionTrue ,
778779 expectedResult : ctrl.Result {RequeueAfter : time .Duration (60 ) * time .Second },
779780 },
781+ "success-default-healthcheck-interval" : {
782+ kind : "ClusterIssuer" ,
783+ name : types.NamespacedName {Name : "clusterissuer1" },
784+ objects : []client.Object {
785+ & commandissuerv1alpha1.ClusterIssuer {
786+ ObjectMeta : metav1.ObjectMeta {
787+ Name : "clusterissuer1" ,
788+ },
789+ Spec : commandissuerv1alpha1.IssuerSpec {
790+ SecretName : "clusterissuer1-credentials" ,
791+ HealthCheck : nil ,
792+ },
793+ Status : commandissuerv1alpha1.IssuerStatus {
794+ Conditions : []commandissuerv1alpha1.IssuerCondition {
795+ {
796+ Type : commandissuerv1alpha1 .IssuerConditionReady ,
797+ Status : commandissuerv1alpha1 .ConditionUnknown ,
798+ },
799+ },
800+ },
801+ },
802+ & corev1.Secret {
803+ Type : corev1 .SecretTypeBasicAuth ,
804+ ObjectMeta : metav1.ObjectMeta {
805+ Name : "clusterissuer1-credentials" ,
806+ Namespace : "kube-system" ,
807+ },
808+ Data : map [string ][]byte {
809+ corev1 .BasicAuthUsernameKey : []byte ("username" ),
810+ corev1 .BasicAuthPasswordKey : []byte ("password" ),
811+ },
812+ },
813+ },
814+ defaultHealthCheckInterval : to .Ptr (time .Duration (2 ) * time .Minute ),
815+ healthCheckerBuilder : newFakeHealthCheckerBuilder (nil , nil , true ),
816+ clusterResourceNamespace : "kube-system" ,
817+ expectedReadyConditionStatus : commandissuerv1alpha1 .ConditionTrue ,
818+ expectedMetadataSupportedConditionStatus : commandissuerv1alpha1 .ConditionTrue ,
819+ expectedResult : ctrl.Result {RequeueAfter : time .Duration (2 ) * time .Minute },
820+ },
780821 "success-nil-healthcheck-defaults" : {
781822 kind : "ClusterIssuer" ,
782823 name : types.NamespacedName {Name : "clusterissuer1" },
@@ -816,48 +857,6 @@ func TestIssuerReconcile(t *testing.T) {
816857 expectedMetadataSupportedConditionStatus : commandissuerv1alpha1 .ConditionTrue ,
817858 expectedResult : ctrl.Result {RequeueAfter : time .Duration (60 ) * time .Second },
818859 },
819- // "error-healthcheck-invalid-parsing": {
820- // kind: "Issuer",
821- // name: types.NamespacedName{Namespace: "ns1", Name: "issuer1"},
822- // objects: []client.Object{
823- // &commandissuerv1alpha1.Issuer{
824- // ObjectMeta: metav1.ObjectMeta{
825- // Name: "issuer1",
826- // Namespace: "ns1",
827- // },
828- // Spec: commandissuerv1alpha1.IssuerSpec{
829- // SecretName: "issuer1-credentials",
830- // HealthCheck: &commandissuerv1alpha1.HealthCheckConfig{
831- // Enabled: true,
832- // Interval: to.Ptr(metav1.Duration{Duration: 30 * time.Second}),
833- // },
834- // },
835- // Status: commandissuerv1alpha1.IssuerStatus{
836- // Conditions: []commandissuerv1alpha1.IssuerCondition{
837- // {
838- // Type: commandissuerv1alpha1.IssuerConditionReady,
839- // Status: commandissuerv1alpha1.ConditionUnknown,
840- // },
841- // },
842- // },
843- // },
844- // &corev1.Secret{
845- // Type: corev1.SecretTypeBasicAuth,
846- // ObjectMeta: metav1.ObjectMeta{
847- // Name: "issuer1-credentials",
848- // Namespace: "ns1",
849- // },
850- // Data: map[string][]byte{
851- // corev1.BasicAuthUsernameKey: []byte("username"),
852- // corev1.BasicAuthPasswordKey: []byte("password"),
853- // },
854- // },
855- // },
856- // healthCheckerBuilder: newFakeHealthCheckerBuilder(nil, nil, false),
857- // expectedReadyConditionStatus: commandissuerv1alpha1.ConditionFalse,
858- // expectedMetadataSupportedConditionStatus: commandissuerv1alpha1.ConditionUnknown,
859- // expectedResult: ctrl.Result{},
860- // },
861860 "error-healthcheck-minimum-value" : {
862861 kind : "Issuer" ,
863862 name : types.NamespacedName {Namespace : "ns1" , Name : "issuer1" },
@@ -916,15 +915,23 @@ func TestIssuerReconcile(t *testing.T) {
916915 if tc .kind == "" {
917916 tc .kind = "Issuer"
918917 }
918+
919+ defaultHealthcheckInterval := time .Minute
920+
921+ if tc .defaultHealthCheckInterval != nil {
922+ defaultHealthcheckInterval = * tc .defaultHealthCheckInterval
923+ }
924+
919925 controller := IssuerReconciler {
920926 Kind : tc .kind ,
921927 Client : fakeClient ,
922928 Scheme : scheme ,
923929 HealthCheckerBuilder : tc .healthCheckerBuilder ,
924930 ClusterResourceNamespace : tc .clusterResourceNamespace ,
925931 SecretAccessGrantedAtClusterLevel : true ,
926- DefaultHealthCheckInterval : time . Minute ,
932+ DefaultHealthCheckInterval : defaultHealthcheckInterval ,
927933 }
934+
928935 result , err := controller .Reconcile (
929936 ctrl .LoggerInto (context .TODO (), logrtesting .NewTestLogger (t )),
930937 reconcile.Request {NamespacedName : tc .name },
0 commit comments