diff --git a/windows-agent/internal/proservices/landscape/landscape_test.go b/windows-agent/internal/proservices/landscape/landscape_test.go index 7505cb85f..bb4818e62 100644 --- a/windows-agent/internal/proservices/landscape/landscape_test.go +++ b/windows-agent/internal/proservices/landscape/landscape_test.go @@ -1,10 +1,18 @@ package landscape_test import ( + "bytes" "context" + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" "crypto/tls" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" "errors" "fmt" + "math/big" "net" "os" "os/exec" @@ -12,6 +20,7 @@ import ( "strings" "sync" "testing" + "text/template" "time" landscapeapi "github.com/canonical/landscape-hostagent-api" @@ -39,11 +48,24 @@ func TestMain(m *testing.M) { defer os.Exit(exit) } +const defaultLandscapeConfig = ` +[host] +url = "{{ .HostURL }}" +` + func TestConnect(t *testing.T) { if wsl.MockAvailable() { t.Parallel() } + certPath := t.TempDir() + + err := generateTempCertificate(certPath) + require.NoError(t, err, "Setup: could not generate certificates") + + err = os.WriteFile(filepath.Join(certPath, "bad-certificate.pem"), []byte("This is not a valid certificate."), 0600) + require.NoError(t, err, "Setup: could not create bad certificate") + testCases := map[string]struct { precancelContext bool serverNotAvailable bool @@ -51,8 +73,7 @@ func TestConnect(t *testing.T) { landscapeUIDReadErr bool landscapeUIDWriteErr bool - noLandscapeURL bool - tokenErr bool + tokenErr bool requireCertificate bool breakLandscapeClientConfig bool @@ -69,7 +90,7 @@ func TestConnect(t *testing.T) { "Success with an SSL certificate": {requireCertificate: true}, "Error when the context is cancelled before Connected": {precancelContext: true, wantErr: true}, - "Error when the landscape URL cannot be retrieved": {noLandscapeURL: true, wantErr: true}, + "Error when the landscape URL cannot be retrieved": {wantErr: true}, "Error when the landscape UID cannot be retrieved": {landscapeUIDReadErr: true, wantErr: true}, "Error when the landscape UID cannot be stored": {landscapeUIDWriteErr: true, wantErr: true}, "Error when the server cannot be reached": {serverNotAvailable: true, wantErr: true}, @@ -89,7 +110,12 @@ func TestConnect(t *testing.T) { ctx = wsl.WithMock(ctx, wslmock.New()) } - lis, server, mockService := setUpLandscapeMock(t, ctx, "localhost:", tc.requireCertificate) + p := "" + if tc.requireCertificate { + p = certPath + } + + lis, server, mockService := setUpLandscapeMock(t, ctx, "localhost:", p) defer lis.Close() conf := &mockConfig{ @@ -108,18 +134,16 @@ func TestConnect(t *testing.T) { landscapeAgentUID: tc.uid, } - out, err := os.ReadFile(filepath.Join(golden.TestFixturePath(t), "landscape.conf")) - if errors.Is(err, os.ErrNotExist) { - // This fixture is not compulsory - out = []byte{} - err = nil + lconf := defaultLandscapeConfig + if fixture, err := os.ReadFile(filepath.Join(golden.TestFixturePath(t), "landscape.conf")); err != nil { + require.ErrorIs(t, err, os.ErrNotExist, "Setup: could not load landscape config") + // Fixture does not exist: use base Landcape confing + } else { + // Fixture exists: override the Landscape config + lconf = string(fixture) } - require.NoError(t, err, "Setup: could not load landscape config") - conf.landscapeClientConfig = string(out) - if !tc.noLandscapeURL { - conf.landscapeClientConfig = fmt.Sprintf("[host]\nurl=%q\n\n%s", lis.Addr(), conf.landscapeClientConfig) - } + conf.landscapeClientConfig = executeLandscapeConfigTemplate(t, lconf, certPath, lis.Addr()) if !tc.serverNotAvailable { //nolint:errcheck // We don't care about these errors @@ -179,6 +203,59 @@ func TestConnect(t *testing.T) { } } +// generateTempCertificate generates a self-signed certificate valid for one hour. Both the +// certificate and the private key are stored in the specified path. +func generateTempCertificate(path string) error { + priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + return fmt.Errorf("could not generate keys: %v", err) + } + + template := x509.Certificate{ + SerialNumber: big.NewInt(1), + Subject: pkix.Name{ + CommonName: "CanonicalGroupLimited", + Country: []string{"US"}, + Organization: []string{"Canonical"}, + }, + IPAddresses: []net.IP{net.ParseIP("127.0.0.1")}, + NotBefore: time.Now(), + NotAfter: time.Now().Add(time.Hour), + } + + cert, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) + if err != nil { + return fmt.Errorf("could not create certificate: %s", err) + } + + // Marshal and write certificate + out := &bytes.Buffer{} + if err := pem.Encode(out, &pem.Block{Type: "CERTIFICATE", Bytes: cert}); err != nil { + return fmt.Errorf("could not encode certificate: %v", err) + } + + if err := os.WriteFile(filepath.Join(path, "cert.pem"), out.Bytes(), 0600); err != nil { + return fmt.Errorf("could not write certificate to file: %v", err) + } + + // Marshal and write private key + key, err := x509.MarshalECPrivateKey(priv) + if err != nil { + return fmt.Errorf("could not marshal private key: %v", err) + } + + out = &bytes.Buffer{} + if err := pem.Encode(out, &pem.Block{Type: "EC PRIVATE KEY", Bytes: key}); err != nil { + return fmt.Errorf("could not encode private key: %v", err) + } + + if err := os.WriteFile(filepath.Join(path, "key.pem"), out.Bytes(), 0600); err != nil { + return fmt.Errorf("could not write private key to file: %v", err) + } + + return nil +} + func TestSendUpdatedInfo(t *testing.T) { if wsl.MockAvailable() { t.Parallel() @@ -215,11 +292,11 @@ func TestSendUpdatedInfo(t *testing.T) { ctx = wsl.WithMock(ctx, mock) } - lis, server, mockService := setUpLandscapeMock(t, ctx, "localhost:", false) + lis, server, mockService := setUpLandscapeMock(t, ctx, "localhost:", "") conf := &mockConfig{ proToken: "TOKEN", - landscapeClientConfig: fmt.Sprintf("[host]\nurl=%q\n", lis.Addr()), + landscapeClientConfig: executeLandscapeConfigTemplate(t, defaultLandscapeConfig, "", lis.Addr()), } //nolint:errcheck // We don't care about these errors @@ -381,13 +458,13 @@ func TestAutoReconnection(t *testing.T) { ctx = wsl.WithMock(ctx, mock) } - lis, server, mockService := setUpLandscapeMock(t, ctx, "localhost:", false) + lis, server, mockService := setUpLandscapeMock(t, ctx, "localhost:", "") defer lis.Close() defer server.Stop() conf := &mockConfig{ proToken: "TOKEN", - landscapeClientConfig: fmt.Sprintf("[host]\nurl=%q\n", lis.Addr()), + landscapeClientConfig: executeLandscapeConfigTemplate(t, defaultLandscapeConfig, "", lis.Addr()), } db, err := database.New(ctx, t.TempDir(), conf) @@ -433,7 +510,7 @@ func TestAutoReconnection(t *testing.T) { }, 5*time.Second, 100*time.Millisecond, "Client should have disconnected after the server is stopped") // Restart server at the same address - lis, server, _ = setUpLandscapeMock(t, ctx, lis.Addr().String(), false) + lis, server, _ = setUpLandscapeMock(t, ctx, lis.Addr().String(), "") defer lis.Close() //nolint:errcheck // We don't care @@ -514,7 +591,7 @@ func TestReceiveCommands(t *testing.T) { t.Skip("This test can only run with the mock") } - lis, server, service := setUpLandscapeMock(t, ctx, "localhost:", false) + lis, server, service := setUpLandscapeMock(t, ctx, "localhost:", "") defer lis.Close() //nolint:errcheck // We don't care about these errors @@ -523,7 +600,7 @@ func TestReceiveCommands(t *testing.T) { conf := &mockConfig{ proToken: "TOKEN", - landscapeClientConfig: fmt.Sprintf("[host]\nurl=%q\n", lis.Addr()), + landscapeClientConfig: executeLandscapeConfigTemplate(t, defaultLandscapeConfig, "", lis.Addr()), } db, err := database.New(ctx, t.TempDir(), conf) @@ -586,6 +663,25 @@ func TestReceiveCommands(t *testing.T) { } } +func executeLandscapeConfigTemplate(t *testing.T, in string, certPath string, url net.Addr) string { + t.Helper() + + tmpl := template.Must(template.New(t.Name()).Parse(in)) + + data := struct { + CertPath, HostURL string + }{ + CertPath: certPath, + HostURL: url.String(), + } + + out := bytes.Buffer{} + err := tmpl.Execute(&out, data) + require.NoError(t, err, "Setup: could not generate Landscape config from template") + + return out.String() +} + const ( testAppx = "CanonicalGroupLimited.Ubuntu22.04LTS" // The name of the Appx testDistroAppx = "Ubuntu-22.04" // The name used in `wsl --install ` @@ -754,7 +850,7 @@ func isAppxInstalled(t *testing.T, appxPackage string) bool { } //nolint:revive // Context goes after testing.T -func setUpLandscapeMock(t *testing.T, ctx context.Context, addr string, requireCertificate bool) (lis net.Listener, server *grpc.Server, service *landscapemockservice.Service) { +func setUpLandscapeMock(t *testing.T, ctx context.Context, addr string, certPath string) (lis net.Listener, server *grpc.Server, service *landscapemockservice.Service) { t.Helper() var cfg net.ListenConfig @@ -762,11 +858,11 @@ func setUpLandscapeMock(t *testing.T, ctx context.Context, addr string, requireC require.NoError(t, err, "Setup: can't listen") var opts []grpc.ServerOption - if requireCertificate { - certPath := filepath.Join(golden.TestFamilyPath(t), "certificates/cert.pem") - keyPath := filepath.Join(golden.TestFamilyPath(t), "certificates/key.pem") + if certPath != "" { + cert := filepath.Join(certPath, "cert.pem") + key := filepath.Join(certPath, "key.pem") - serverCert, err := tls.LoadX509KeyPair(certPath, keyPath) + serverCert, err := tls.LoadX509KeyPair(cert, key) require.NoError(t, err, "Setup: could not load Landscape mock server credentials") config := &tls.Config{ diff --git a/windows-agent/internal/proservices/landscape/testdata/TestConnect/certificates/bad-certificate.pem b/windows-agent/internal/proservices/landscape/testdata/TestConnect/certificates/bad-certificate.pem deleted file mode 100644 index 13f344e2e..000000000 --- a/windows-agent/internal/proservices/landscape/testdata/TestConnect/certificates/bad-certificate.pem +++ /dev/null @@ -1 +0,0 @@ -This is not a valid certificate diff --git a/windows-agent/internal/proservices/landscape/testdata/TestConnect/certificates/cert.pem b/windows-agent/internal/proservices/landscape/testdata/TestConnect/certificates/cert.pem deleted file mode 100644 index 7214408e8..000000000 --- a/windows-agent/internal/proservices/landscape/testdata/TestConnect/certificates/cert.pem +++ /dev/null @@ -1,32 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFdDCCA1ygAwIBAgIUQ2XcjKTRgC0xuZMtwMAa0OvDxRswDQYJKoZIhvcNAQEL -BQAwQTELMAkGA1UEBhMCVVMxEjAQBgNVBAoMCUNhbm9uaWNhbDEeMBwGA1UEAwwV -Q2Fub25pY2FsR3JvdXBMaW1pdGVkMB4XDTIzMTAxMDEwMDcyM1oXDTIzMTEwOTEw -MDcyM1owQTELMAkGA1UEBhMCVVMxEjAQBgNVBAoMCUNhbm9uaWNhbDEeMBwGA1UE -AwwVQ2Fub25pY2FsR3JvdXBMaW1pdGVkMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A -MIICCgKCAgEAzfI1KuyZgkgrIc48UMN5cHNEchOQlWrP9eo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HYZfriioU+Lqf+92nAmtdFtNTP/g2OWunuOhEvYUI+EfPpjqSB19hvi -vD5qnV/euuWbP9mnoGVXmRcg5ZWVqgm6Yh+syRXYDEf8zwkpjod5DOKHVA0oK4hy -1zp5ufVwVETB/rdfUUS8cPXx8HqqtZienHauH/BO5OZTwSNmLrie7l/v1WUgvXBP -5k8p8wxtvXf0JNdTtNFPL82Q5W0f/4GE6PGAet4TxjNVLs9DolnTdBN7isntm9iI -d6BuuQLzNcd9J2p+7qm0Uu8gh7TeNbnBgaJnJiwCtogYMsOGFiimrF3ce3vJz/Qq -tN/od94ffjun+hWgCGQUIPZNFNNOAx7oUQmjQi0ubm/XiCEvNJHBNkvSImTidrrn -sHTu/FLkntCWzHTA8MfA3eZmqsNNUojQvVcSxs01Bwy/UKgYhcpuijRve5HsloSz -IT0QVhzpIdM= ------END CERTIFICATE----- diff --git a/windows-agent/internal/proservices/landscape/testdata/TestConnect/certificates/generate-certificate.sh b/windows-agent/internal/proservices/landscape/testdata/TestConnect/certificates/generate-certificate.sh deleted file mode 100644 index 4c30a2ce8..000000000 --- a/windows-agent/internal/proservices/landscape/testdata/TestConnect/certificates/generate-certificate.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -openssl req \ - -x509 \ - -newkey rsa:4096 \ - -keyout key.pem \ - -out cert.pem \ - -sha256 \ - -nodes \ - -addext 'subjectAltName = IP:127.0.0.1' \ - -subj "/C=US/O=Canonical/CN=CanonicalGroupLimited" - -echo This is not a valid certificate > bad-certificate.pem \ No newline at end of file diff --git a/windows-agent/internal/proservices/landscape/testdata/TestConnect/certificates/key.pem b/windows-agent/internal/proservices/landscape/testdata/TestConnect/certificates/key.pem deleted file mode 100644 index 542bfb686..000000000 --- a/windows-agent/internal/proservices/landscape/testdata/TestConnect/certificates/key.pem +++ /dev/null @@ -1,52 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDN8jU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-5/F/5KczDXkUkT6l/pipJEAcW6+/AUTdByYlHgcHtbRf6vfRrQ6d/ByWOu23SuPr -hHQ8+kQG/BqprI6lRk93FeRs/hbt8HW0FdpLPwiYJMzUzJnVZNYR+O0YF89Wz3Y0 -C3kB9sxJTtOnvMosWAVi7PCfYtdx0nWwxLbi3eNfK3tUN/7OLEyMLhcFwYnPXez3 -HqrewhVHndMK3MGIW099yqVS/Hll/WNzcowWhK8D+Zp7TgHb23vFjdsyFN0MaGbn -5kmsG7Wy/8Wf0M/+41ttbgTmOcMm9kqwMqiUYxECggEALy5rQ8DRZDEwX0Np6dxt -aDlDQVpKp4WESQtaGhdXAtvLvrhUwA9nh+dYySu2ls26Gxg0Hvktb2K/AxA0UCP6 -DWMtFoMySX4lhH8ICkugRt2GBUj1gjmR79YQRPnbYebBc/iozHMq3FCdHfkpZbg5 -UW/V+K2LfUvrB3CiP4YQ456E7PhPytQVpXm3j8FinPwbkaB5vOZkiNG6c0Zkd27t -kqZ/nRIknt/mm7RdkbLClFXeSnHFXmODBe5vheCSyTZij/FUmZcZZaJD+7nMo0u0 -NPHAeLEdzbWvd+vx87cKb8OsFcXPUsY54xMBMMdcfTDyfYllO8i7Wqrde4w8EFrI -0wKCAQEA4+MpvYBaECc+OtVQNN9AuPtFNj/REkdhJAj4aunqnPSyMaS77//v6BBa -OGoUrF6DObNI5H3S8YXNEqNgX2ybq7VWVk4DJMylzDlreejeK0WqORJ/ra7ieG8n -5uRW2Xlu1YjBdlNoWkoxRT26zUMvcu1wS/P/ge26C9VlMWFq7T2jMwWZnG4kLFG5 -KU8AzRBzQObAHdPeKid6jHnH363W7UA4DO7I8E5hwoCcphKW3La+/MYrHUCDcBB4 -edQhWOM01Y13u9PJO2x7AuLxW5h3NHlBZB1XFeBzaa9sRO0kzQmqXhSND7TXctkg -V4lfPNzmMvwoXBp3kxjmSCzEy6TPDQ== ------END PRIVATE KEY----- diff --git a/windows-agent/internal/proservices/landscape/testdata/TestConnect/error_when_the_landscape_url_cannot_be_retrieved/landscape.conf b/windows-agent/internal/proservices/landscape/testdata/TestConnect/error_when_the_landscape_url_cannot_be_retrieved/landscape.conf new file mode 100644 index 000000000..a8a807a95 --- /dev/null +++ b/windows-agent/internal/proservices/landscape/testdata/TestConnect/error_when_the_landscape_url_cannot_be_retrieved/landscape.conf @@ -0,0 +1,3 @@ +[client] +hello=world +tags=wsl \ No newline at end of file diff --git a/windows-agent/internal/proservices/landscape/testdata/TestConnect/error_when_the_ssl_certificate_cannot_be_read/landscape.conf b/windows-agent/internal/proservices/landscape/testdata/TestConnect/error_when_the_ssl_certificate_cannot_be_read/landscape.conf index e3d102467..a931480e2 100644 --- a/windows-agent/internal/proservices/landscape/testdata/TestConnect/error_when_the_ssl_certificate_cannot_be_read/landscape.conf +++ b/windows-agent/internal/proservices/landscape/testdata/TestConnect/error_when_the_ssl_certificate_cannot_be_read/landscape.conf @@ -1,2 +1,5 @@ [client] -ssl_public_key = testdata/TestConnect/this_path_does_not_exist/certificate.pem \ No newline at end of file +ssl_public_key = testdata/TestConnect/this_path_does_not_exist/certificate.pem + +[host] +url = {{ .HostURL }} \ No newline at end of file diff --git a/windows-agent/internal/proservices/landscape/testdata/TestConnect/error_when_the_ssl_certificate_is_not_valid/landscape.conf b/windows-agent/internal/proservices/landscape/testdata/TestConnect/error_when_the_ssl_certificate_is_not_valid/landscape.conf index fa967798f..20ee5ea4d 100644 --- a/windows-agent/internal/proservices/landscape/testdata/TestConnect/error_when_the_ssl_certificate_is_not_valid/landscape.conf +++ b/windows-agent/internal/proservices/landscape/testdata/TestConnect/error_when_the_ssl_certificate_is_not_valid/landscape.conf @@ -1,2 +1,5 @@ [client] -ssl_public_key = testdata/TestConnect/certificates/bad-certificate.pem \ No newline at end of file +ssl_public_key = {{ .CertPath }}/bad-certificate.pem + +[host] +url = {{ .HostURL }} \ No newline at end of file diff --git a/windows-agent/internal/proservices/landscape/testdata/TestConnect/success_with_an_ssl_certificate/landscape.conf b/windows-agent/internal/proservices/landscape/testdata/TestConnect/success_with_an_ssl_certificate/landscape.conf index 9e0521ef5..dd3fcbdec 100644 --- a/windows-agent/internal/proservices/landscape/testdata/TestConnect/success_with_an_ssl_certificate/landscape.conf +++ b/windows-agent/internal/proservices/landscape/testdata/TestConnect/success_with_an_ssl_certificate/landscape.conf @@ -1,2 +1,5 @@ [client] -ssl_public_key = testdata/TestConnect/certificates/cert.pem \ No newline at end of file +ssl_public_key = {{ .CertPath }}/cert.pem + +[host] +url = {{ .HostURL }} \ No newline at end of file diff --git a/windows-agent/internal/proservices/landscape/testdata/TestConnect/success_with_non-empty_config/landscape.conf b/windows-agent/internal/proservices/landscape/testdata/TestConnect/success_with_non-empty_config/landscape.conf index a8a807a95..fa8035de9 100644 --- a/windows-agent/internal/proservices/landscape/testdata/TestConnect/success_with_non-empty_config/landscape.conf +++ b/windows-agent/internal/proservices/landscape/testdata/TestConnect/success_with_non-empty_config/landscape.conf @@ -1,3 +1,6 @@ [client] hello=world -tags=wsl \ No newline at end of file +tags=wsl + +[host] +url = {{ .HostURL }} \ No newline at end of file