Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 add more debug info for autoapprove test #172

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions test/integration/util/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"io/ioutil"
"math/big"
"net"
"os"
Expand Down Expand Up @@ -51,7 +50,7 @@ type TestAuthn struct {
}

func createKubeConfigByClientCert(context string, securePort string, serverCertFile, certFile, keyFile string) (*clientcmdapi.Config, error) {
caData, err := ioutil.ReadFile(serverCertFile)
caData, err := os.ReadFile(serverCertFile)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -123,7 +122,7 @@ func (t *TestAuthn) Start() error {
if err := pem.Encode(&caCertBuffer, &pem.Block{Type: certutil.CertificateBlockType, Bytes: caDERBytes}); err != nil {
return err
}
if err := ioutil.WriteFile(t.caFile, caCertBuffer.Bytes(), 0644); err != nil {
if err := os.WriteFile(t.caFile, caCertBuffer.Bytes(), 0644); err != nil {
return err
}

Expand All @@ -132,7 +131,7 @@ func (t *TestAuthn) Start() error {
&caKeyBuffer, &pem.Block{Type: keyutil.RSAPrivateKeyBlockType, Bytes: x509.MarshalPKCS1PrivateKey(caKey)}); err != nil {
return err
}
if err := ioutil.WriteFile(t.caKeyFile, caKeyBuffer.Bytes(), 0644); err != nil {
if err := os.WriteFile(t.caKeyFile, caKeyBuffer.Bytes(), 0644); err != nil {
return err
}

Expand Down Expand Up @@ -182,10 +181,10 @@ func (t *TestAuthn) CreateBootstrapKubeConfig(configFileName, serverCertFile, se
}
}

if err := ioutil.WriteFile(path.Join(configDir, "bootstrap.crt"), certData, 0644); err != nil {
if err := os.WriteFile(path.Join(configDir, "bootstrap.crt"), certData, 0644); err != nil {
return err
}
if err := ioutil.WriteFile(path.Join(configDir, "bootstrap.key"), keyData, 0644); err != nil {
if err := os.WriteFile(path.Join(configDir, "bootstrap.key"), keyData, 0644); err != nil {
return err
}

Expand All @@ -199,7 +198,7 @@ func (t *TestAuthn) CreateBootstrapKubeConfig(configFileName, serverCertFile, se

func (t *TestAuthn) signClientCertKeyWithCA(user string, groups []string, maxAge time.Duration) ([]byte, []byte, error) {
now := time.Now()
caData, err := ioutil.ReadFile(t.caFile)
caData, err := os.ReadFile(t.caFile)
if err != nil {
return nil, nil, err
}
Expand All @@ -209,7 +208,7 @@ func (t *TestAuthn) signClientCertKeyWithCA(user string, groups []string, maxAge
return nil, nil, err
}

caKeyData, err := ioutil.ReadFile(t.caKeyFile)
caKeyData, err := os.ReadFile(t.caKeyFile)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -388,7 +387,7 @@ func FindAutoApprovedSpokeCSR(kubeClient kubernetes.Interface, spokeClusterName
}

if autoApproved == nil {
return nil, fmt.Errorf("failed to find autoapproved csr for spoke cluster %q", spokeClusterName)
return nil, fmt.Errorf("failed to find autoapproved csr for spoke cluster %q, crs: %+v", spokeClusterName, csrList)
}

return autoApproved, nil
Expand Down Expand Up @@ -444,7 +443,7 @@ func (t *TestAuthn) FillCertificateToApprovedCSR(kubeClient kubernetes.Interface
return err
}

caData, err := ioutil.ReadFile(t.caFile)
caData, err := os.ReadFile(t.caFile)
if err != nil {
return err
}
Expand All @@ -454,7 +453,7 @@ func (t *TestAuthn) FillCertificateToApprovedCSR(kubeClient kubernetes.Interface
return err
}

caKeyData, err := ioutil.ReadFile(t.caKeyFile)
caKeyData, err := os.ReadFile(t.caKeyFile)
if err != nil {
return err
}
Expand Down
4 changes: 1 addition & 3 deletions test/integration/util/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ func (r *IntegrationTestEventRecorder) Warningf(reason, messageFmt string, args
r.Warning(reason, fmt.Sprintf(messageFmt, args...))
}

func (r *IntegrationTestEventRecorder) Shutdown() {
return
}
func (r *IntegrationTestEventRecorder) Shutdown() {}

func HasCondition(
conditions []metav1.Condition,
Expand Down