Skip to content

Commit

Permalink
test: re-add unit tests for enforced condition
Browse files Browse the repository at this point in the history
Signed-off-by: KevFan <chfan@redhat.com>
  • Loading branch information
KevFan committed Oct 2, 2024
1 parent d884b14 commit 84f8a86
Show file tree
Hide file tree
Showing 4 changed files with 466 additions and 9 deletions.
7 changes: 3 additions & 4 deletions controllers/tlspolicy_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (t *TLSPolicyStatusTask) isIssuerReady(ctx context.Context, tlsPolicy *kuad
return o.GroupVersionKind().GroupKind() == CertManagerIssuerKind && o.GetNamespace() == tlsPolicy.GetNamespace() && o.GetName() == tlsPolicy.Spec.IssuerRef.Name
})
if !ok {
err := errors.New("unable to find issuer for TLSPolicy")
err := fmt.Errorf("%s \"%s\" not found", tlsPolicy.Spec.IssuerRef.Kind, tlsPolicy.Spec.IssuerRef.Name)
logger.Error(err, "error finding object in topology")
return err
}
Expand All @@ -250,7 +250,7 @@ func (t *TLSPolicyStatusTask) isIssuerReady(ctx context.Context, tlsPolicy *kuad
return o.GroupVersionKind().GroupKind() == CertManagerClusterIssuerKind && o.GetName() == tlsPolicy.Spec.IssuerRef.Name
})
if !ok {
err := errors.New("unable to find cluster issuer for TLSPolicy")
err := fmt.Errorf("%s \"%s\" not found", tlsPolicy.Spec.IssuerRef.Kind, tlsPolicy.Spec.IssuerRef.Name)
logger.Error(err, "error finding object in topology")
return err
}
Expand All @@ -266,7 +266,7 @@ func (t *TLSPolicyStatusTask) isIssuerReady(ctx context.Context, tlsPolicy *kuad
})

if !meta.IsStatusConditionTrue(transformedCond, string(certmanagerv1.IssuerConditionReady)) {
return errors.New("issuer not ready")
return fmt.Errorf("%s not ready", tlsPolicy.Spec.IssuerRef.Kind)
}

return nil
Expand All @@ -281,7 +281,6 @@ func (t *TLSPolicyStatusTask) isCertificatesReady(ctx context.Context, p machine
// Get all gateways that contains this policy
gws := lo.FilterMap(topology.Targetables().Items(), func(item machinery.Targetable, index int) (*machinery.Gateway, bool) {
gw, ok := item.(*machinery.Gateway)

return gw, ok && lo.Contains(gw.Policies(), p)
})

Expand Down
Loading

0 comments on commit 84f8a86

Please sign in to comment.