Repository: code-ready/crc
Pull request #2476 (2021-06-24 12:18:19)

Add proxy-ca-file to http transport
Segment and version check may use the proxy via HTTP_PROXY env
variables. This doesn't include the proxy CA.
This change loads the cert from proxy-ca-file configuration key and use
 it when it is possible.

How to test:
* run mitmproxy
* crc config set proxy-ca-file $HOME/.mitmproxy/mitmproxy-ca-cert.cer
* run crc version with telemetry enabled.



openshift-ci[bot]: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/code-ready/crc/pull/2476#" title="Author self-approved">guillaumerose</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=code-ready%2Fcrc).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/code-ready/crc/blob/master/OWNERS)~~ [guillaumerose]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
openshift-ci[bot]: @guillaumerose: The following test **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/integration-crc | 0b749fad887672d9e95746ccddeca245ef9f44ac | [link](https://prow.ci.openshift.org/view/gs/origin-ci-test/pr-logs/pull/code-ready_crc/2476/pull-ci-code-ready-crc-master-integration-crc/1408036772675325952) | `/test integration-crc`

[Full PR test history](https://prow.ci.openshift.org/pr-history?org=code-ready&repo=crc&pr=2476). [Your PR dashboard](https://prow.ci.openshift.org/pr?query=is:pr+state:open+author:guillaumerose).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
openshift-ci[bot]: @guillaumerose: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/integration-crc | 0b749fad887672d9e95746ccddeca245ef9f44ac | [link](https://prow.ci.openshift.org/view/gs/origin-ci-test/pr-logs/pull/code-ready_crc/2476/pull-ci-code-ready-crc-master-integration-crc/1408036772675325952) | `/test integration-crc`
ci/prow/images | 0b749fad887672d9e95746ccddeca245ef9f44ac | [link](https://prow.ci.openshift.org/view/gs/origin-ci-test/pr-logs/pull/code-ready_crc/2476/pull-ci-code-ready-crc-master-images/1408036772641771520) | `/test images`

[Full PR test history](https://prow.ci.openshift.org/pr-history?org=code-ready&repo=crc&pr=2476). [Your PR dashboard](https://prow.ci.openshift.org/pr?query=is:pr+state:open+author:guillaumerose).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
openshift-ci[bot]: @guillaumerose: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/integration-crc | 0b749fad887672d9e95746ccddeca245ef9f44ac | [link](https://prow.ci.openshift.org/view/gs/origin-ci-test/pr-logs/pull/code-ready_crc/2476/pull-ci-code-ready-crc-master-integration-crc/1408036772675325952) | `/test integration-crc`
ci/prow/images | 0b749fad887672d9e95746ccddeca245ef9f44ac | [link](https://prow.ci.openshift.org/view/gs/origin-ci-test/pr-logs/pull/code-ready_crc/2476/pull-ci-code-ready-crc-master-images/1408036772641771520) | `/test images`
ci/prow/e2e-crc | 0b749fad887672d9e95746ccddeca245ef9f44ac | [link](https://prow.ci.openshift.org/view/gs/origin-ci-test/pr-logs/pull/code-ready_crc/2476/pull-ci-code-ready-crc-master-e2e-crc/1408036772608217088) | `/test e2e-crc`

[Full PR test history](https://prow.ci.openshift.org/pr-history?org=code-ready&repo=crc&pr=2476). [Your PR dashboard](https://prow.ci.openshift.org/pr?query=is:pr+state:open+author:guillaumerose).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->

Patch:
diff --git a/.golangci.yml b/.golangci.yml
index ce8ea7c88..6c82b0f8b 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -12,4 +12,4 @@ linters:
     - gocritic
     - deadcode
     - misspell
-    - golint
+    - revive
diff --git a/Makefile b/Makefile
index d3527883c..1ccf22854 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ CRC_VERSION = 1.28.0
 COMMIT_SHA=$(shell git rev-parse --short HEAD)
 MACOS_INSTALL_PATH = /Applications/CodeReady Containers.app/Contents/Resources/
 CONTAINER_RUNTIME ?= podman
-GOLANGCI_LINT_VERSION = v1.39.0
+GOLANGCI_LINT_VERSION = v1.41.1
 
 ifdef OKD_VERSION
     BUNDLE_VERSION = $(OKD_VERSION)
diff --git a/cmd/crc/cmd/root.go b/cmd/crc/cmd/root.go
index 144723b03..063b903ef 100644
--- a/cmd/crc/cmd/root.go
+++ b/cmd/crc/cmd/root.go
@@ -2,9 +2,12 @@ package cmd
 
 import (
 	"context"
+	"crypto/tls"
+	"crypto/x509"
 	"errors"
 	"fmt"
 	"io/ioutil"
+	"net/http"
 	"os"
 	"strings"
 	"time"
@@ -56,7 +59,7 @@ func init() {
 		logging.Fatal(err.Error())
 	}
 	// Initiate segment client
-	if segmentClient, err = segment.NewClient(config); err != nil {
+	if segmentClient, err = segment.NewClient(config, httpTransport()); err != nil {
 		logging.Fatal(err.Error())
 	}
 
@@ -207,3 +210,23 @@ func attachMiddleware(names []string, cmd *cobra.Command) {
 		cmd.RunE = executeWithLogging(fullCmd, src)
 	}
 }
+
+func httpTransport() http.RoundTripper {
+	if config.Get(crcConfig.ProxyCAFile).IsDefault {
+		return http.DefaultTransport
+	}
+	caCert, err := ioutil.ReadFile(config.Get(crcConfig.ProxyCAFile).AsString())
+	if err != nil {
+		logging.Errorf("Cannot read proxy-ca-file, using default http transport: %v", err)
+		return http.DefaultTransport
+	}
+	caCertPool := x509.NewCertPool()
+	caCertPool.AppendCertsFromPEM(caCert)
+	return &http.Transport{
+		Proxy: http.ProxyFromEnvironment,
+		TLSClientConfig: &tls.Config{
+			MinVersion: tls.VersionTLS12,
+			RootCAs:    caCertPool,
+		},
+	}
+}
diff --git a/cmd/crc/cmd/start.go b/cmd/crc/cmd/start.go
index 48693f9c7..8a7853e26 100644
--- a/cmd/crc/cmd/start.go
+++ b/cmd/crc/cmd/start.go
@@ -52,10 +52,7 @@ var startCmd = &cobra.Command{
 		if err := viper.BindFlagSet(cmd.Flags()); err != nil {
 			return err
 		}
-		if err := renderStartResult(runStart(cmd.Context())); err != nil {
-			return err
-		}
-		return nil
+		return renderStartResult(runStart(cmd.Context()))
 	},
 }
 
@@ -211,7 +208,7 @@ func checkIfNewVersionAvailable(noUpdateCheck bool) error {
 }
 
 func newVersionAvailable() (bool, string, string, error) {
-	release, err := crcversion.GetCRCLatestVersionFromMirror()
+	release, err := crcversion.GetCRCLatestVersionFromMirror(httpTransport())
 	if err != nil {
 		return false, "", "", err
 	}
diff --git a/pkg/crc/adminhelper/hosts.go b/pkg/crc/adminhelper/hosts.go
index 2f6f7379b..8b8f8d838 100644
--- a/pkg/crc/adminhelper/hosts.go
+++ b/pkg/crc/adminhelper/hosts.go
@@ -17,10 +17,7 @@ func UpdateHostsFile(instanceIP string, hostnames ...string) error {
 	if err := RemoveFromHostsFile(hostnames...); err != nil {
 		return err
 	}
-	if err := AddToHostsFile(instanceIP, hostnames...); err != nil {
-		return err
-	}
-	return nil
+	return AddToHostsFile(instanceIP, hostnames...)
 }
 
 func AddToHostsFile(instanceIP string, hostnames ...string) error {
diff --git a/pkg/crc/config/settings.go b/pkg/crc/config/settings.go
index d0023bb65..1aee50e88 100644
--- a/pkg/crc/config/settings.go
+++ b/pkg/crc/config/settings.go
@@ -79,8 +79,12 @@ func RegisterSettings(cfg *Config) {
 		"Disable update check (true/false, default: false)")
 	cfg.AddSetting(ExperimentalFeatures, false, ValidateBool, SuccessfullyApplied,
 		"Enable experimental features (true/false, default: false)")
-	cfg.AddSetting(NetworkMode, string(defaultNetworkMode()), network.ValidateMode, network.SuccessfullyAppliedMode,
-		fmt.Sprintf("Network mode (%s or %s)", network.UserNetworkingMode, network.SystemNetworkingMode))
+
+	if !version.IsMacosInstallPathSet() {
+		cfg.AddSetting(NetworkMode, string(defaultNetworkMode()), network.ValidateMode, network.SuccessfullyAppliedMode,
+			fmt.Sprintf("Network mode (%s or %s)", network.UserNetworkingMode, network.SystemNetworkingMode))
+	}
+
 	cfg.AddSetting(HostNetworkAccess, false, validateHostNetworkAccess, SuccessfullyApplied,
 		"Allow TCP/IP connections from the CodeReady Containers VM to services running on the host (true/false, default: false)")
 	// System tray auto-start config
@@ -118,5 +122,8 @@ func defaultNetworkMode() network.Mode {
 }
 
 func GetNetworkMode(config Storage) network.Mode {
+	if version.IsMacosInstallPathSet() {
+		return network.UserNetworkingMode
+	}
 	return network.ParseMode(config.Get(NetworkMode).AsString())
 }
diff --git a/pkg/crc/segment/segment.go b/pkg/crc/segment/segment.go
index 84c309ed5..06267977e 100644
--- a/pkg/crc/segment/segment.go
+++ b/pkg/crc/segment/segment.go
@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"io/ioutil"
 	"net"
+	"net/http"
 	"os"
 	"path/filepath"
 	"strings"
@@ -30,19 +31,20 @@ type Client struct {
 	telemetryFilePath string
 }
 
-func NewClient(config *crcConfig.Config) (*Client, error) {
-	return newCustomClient(config,
+func NewClient(config *crcConfig.Config, transport http.RoundTripper) (*Client, error) {
+	return newCustomClient(config, transport,
 		filepath.Join(constants.GetHomeDir(), ".redhat", "anonymousId"),
 		analytics.DefaultEndpoint)
 }
 
-func newCustomClient(config *crcConfig.Config, telemetryFilePath, segmentEndpoint string) (*Client, error) {
+func newCustomClient(config *crcConfig.Config, transport http.RoundTripper, telemetryFilePath, segmentEndpoint string) (*Client, error) {
 	client, err := analytics.NewWithConfig(WriteKey, analytics.Config{
 		Endpoint: segmentEndpoint,
 		Logger:   &loggingAdapter{},
 		DefaultContext: &analytics.Context{
 			IP: net.IPv4(0, 0, 0, 0),
 		},
+		Transport: transport,
 	})
 	if err != nil {
 		return nil, err
diff --git a/pkg/crc/ssh/keys_windows.go b/pkg/crc/ssh/keys_windows.go
index 92a08933e..573a451af 100644
--- a/pkg/crc/ssh/keys_windows.go
+++ b/pkg/crc/ssh/keys_windows.go
@@ -34,7 +34,7 @@ func (kp *KeyPair) WriteToFile(privateKeyPath string, publicKeyPath string) erro
 			return ErrUnableToWriteFile
 		}
 
-		if err := windowsChmod(v.File, 0600); err != nil {
+		if err := acl.Chmod(v.File, 0600); err != nil {
 			return err
 		}
 
@@ -42,11 +42,3 @@ func (kp *KeyPair) WriteToFile(privateKeyPath string, publicKeyPath string) erro
 
 	return nil
 }
-
-func windowsChmod(filePath string, fileMode os.FileMode) error {
-	if err := acl.Chmod(filePath, fileMode); err != nil {
-		return err
-	}
-
-	return nil
-}
diff --git a/pkg/crc/version/version.go b/pkg/crc/version/version.go
index d75ec7365..dbdd58186 100644
--- a/pkg/crc/version/version.go
+++ b/pkg/crc/version/version.go
@@ -83,9 +83,10 @@ func IsMsiBuild() bool {
 	return msiBuild != "false"
 }
 
-func GetCRCLatestVersionFromMirror() (*CrcReleaseInfo, error) {
+func GetCRCLatestVersionFromMirror(transport http.RoundTripper) (*CrcReleaseInfo, error) {
 	client := &http.Client{
-		Timeout: 5 * time.Second,
+		Timeout:   5 * time.Second,
+		Transport: transport,
 	}
 	req, err := http.NewRequest(http.MethodGet, releaseInfoLink, nil)
 	if err != nil {
diff --git a/pkg/drivers/hyperv/hyperv_windows.go b/pkg/drivers/hyperv/hyperv_windows.go
index 682c60680..f7c835e3d 100644
--- a/pkg/drivers/hyperv/hyperv_windows.go
+++ b/pkg/drivers/hyperv/hyperv_windows.go
@@ -198,13 +198,9 @@ func (d *Driver) Create() error {
 		}
 	}
 
-	if err := cmd("Hyper-V\\Add-VMHardDiskDrive",
+	return cmd("Hyper-V\\Add-VMHardDiskDrive",
 		"-VMName", d.MachineName,
-		"-Path", quote(d.getDiskPath())); err != nil {
-		return err
-	}
-
-	return nil
+		"-Path", quote(d.getDiskPath()))
 }
 
 func (d *Driver) chooseVirtualSwitch() (string, error) {
diff --git a/pkg/os/launchd/launchd_darwin.go b/pkg/os/launchd/launchd_darwin.go
index 3c7befb9d..96370fc70 100644
--- a/pkg/os/launchd/launchd_darwin.go
+++ b/pkg/os/launchd/launchd_darwin.go
@@ -55,10 +55,7 @@ var (
 )
 
 func ensureLaunchAgentsDirExists() error {
-	if err := goos.MkdirAll(launchAgentsDir, 0700); err != nil {
-		return err
-	}
-	return nil
+	return goos.MkdirAll(launchAgentsDir, 0700)
 }
 
 func getPlistPath(label string) string {


Test patch:
diff --git a/pkg/crc/segment/segment_test.go b/pkg/crc/segment/segment_test.go
index d7d1eacb4..fbb985d61 100644
--- a/pkg/crc/segment/segment_test.go
+++ b/pkg/crc/segment/segment_test.go
@@ -88,7 +88,7 @@ func TestClientUploadWithConsentAndWithSerializableError(t *testing.T) {
 
 	uuidFile := filepath.Join(dir, "telemetry")
 
-	c, err := newCustomClient(config, uuidFile, server.URL)
+	c, err := newCustomClient(config, http.DefaultTransport, uuidFile, server.URL)
 	require.NoError(t, err)
 
 	require.NoError(t, c.UploadCmd(context.Background(), "start", time.Minute, crcErr.ToSerializableError(crcErr.VMNotExist)))
@@ -128,7 +128,7 @@ func TestClientUploadWithConsentAndWithoutSerializableError(t *testing.T) {
 	config, err := newTestConfig("yes")
 	require.NoError(t, err)
 
-	c, err := newCustomClient(config, filepath.Join(dir, "telemetry"), server.URL)
+	c, err := newCustomClient(config, http.DefaultTransport, filepath.Join(dir, "telemetry"), server.URL)
 	require.NoError(t, err)
 
 	require.NoError(t, c.UploadCmd(context.Background(), "start", time.Minute, errors.New("an error occurred")))
@@ -163,7 +163,7 @@ func TestClientUploadWithContext(t *testing.T) {
 	config, err := newTestConfig("yes")
 	require.NoError(t, err)
 
-	c, err := newCustomClient(config, filepath.Join(dir, "telemetry"), server.URL)
+	c, err := newCustomClient(config, http.DefaultTransport, filepath.Join(dir, "telemetry"), server.URL)
 	require.NoError(t, err)
 
 	ctx := telemetry.NewContext(context.Background())
@@ -193,7 +193,7 @@ func TestClientUploadWithOutConsent(t *testing.T) {
 	config, err := newTestConfig("no")
 	require.NoError(t, err)
 
-	c, err := newCustomClient(config, filepath.Join(dir, "telemetry"), server.URL)
+	c, err := newCustomClient(config, http.DefaultTransport, filepath.Join(dir, "telemetry"), server.URL)
 	require.NoError(t, err)
 
 	require.NoError(t, c.UploadCmd(context.Background(), "start", time.Second, errors.New("an error occurred")))
diff --git a/test/extended/crc/ux/notification/applescripts/manageNotifications.applescript b/test/extended/crc/ux/notification/applescripts/manageNotifications.applescript
index c0ffba7f9..671ad2168 100644
--- a/test/extended/crc/ux/notification/applescripts/manageNotifications.applescript
+++ b/test/extended/crc/ux/notification/applescripts/manageNotifications.applescript
@@ -10,14 +10,17 @@ set os_version to system attribute "sys1"
 
 -- notifications should be visible to perform actions 
 if not is_notificationmenu_visible() then
-	open_notifications(os_version)
+	click_notifications(os_version)
 end if
 
 -- handle action
 if action = action_get then
-	get_notification(os_version)
+	set notification to get_notification(os_version)
+    click_notifications(os_version)
+    return notification
 else if action = action_clear then
 	clear_notifications(os_version)
+	click_notifications(os_version)
 else 
 	error "not supported action"
 end if
@@ -37,7 +40,7 @@ else
 end if 
 end get_systemmenu_controller
 
-on open_notifications(os_major_version)
+on click_notifications(os_major_version)
 set systemmenu_controler to get_systemmenu_controller(os_major_version)
 tell application "System Events"
 	tell (first application process whose bundle identifier is systemmenu_controler)
@@ -45,7 +48,7 @@ tell application "System Events"
                 delay 0.25
     	end tell
 end tell  
-end open_notifications
+end click_notifications
 
 on is_notificationmenu_visible() 
 try
@@ -87,7 +90,11 @@ try
 	tell application "System Events"
 		tell (first application process whose bundle identifier is "com.apple.notificationcenterui")
 			tell UI Element 1 of row 3 of table 1 of scroll area 1 of window 1
-				return value of static text 5
+				if (value of static text 4) as string is not equal to "" then
+                    return value of static text 4
+                else
+                    return value of static text 5
+                end if
 			end tell
 		end tell
 	end tell
diff --git a/test/extended/crc/ux/notification/const.go b/test/extended/crc/ux/notification/const.go
index b24229792..12aa21359 100644
--- a/test/extended/crc/ux/notification/const.go
+++ b/test/extended/crc/ux/notification/const.go
@@ -4,7 +4,7 @@
 package notification
 
 const (
-	startMessage  string = "OpenShift Cluster is running"
+	startMessage  string = "OpenShift cluster is running"
 	stopMessage   string = "The OpenShift Cluster was successfully stopped"
 	deleteMessage string = "The OpenShift Cluster is successfully deleted"
 	// copyCommandMessage string = "OC Login command copied to clipboard, go ahead and login to your cluster"
diff --git a/test/extended/crc/ux/tray/applescripts/getTrayFieldlValue.applescript b/test/extended/crc/ux/tray/applescripts/getTrayFieldlValue.applescript
index db6437ce8..dd31a758c 100644
--- a/test/extended/crc/ux/tray/applescripts/getTrayFieldlValue.applescript
+++ b/test/extended/crc/ux/tray/applescripts/getTrayFieldlValue.applescript
@@ -1,9 +1,30 @@
 on run {bundleIdentifer, elementAXIdentifier}
+set systemMenuBarId to 2
+set trayMainMenuId to 1
+set statusAndLogsMenuItem to "Status and Logs"
+set statusAndLogsWindowId to "Status and Logs"
+set statusAndLogsWindowCloseButtonId to 1
+set menuClickDelay to 0.5
+try
     tell application "System Events"
         tell (first application process whose bundle identifier is bundleIdentifer)
-            click menu bar item of menu bar 2
-            delay 0.5
-            return name of (first menu item of menu 1 of menu bar 2 whose value of attribute "AXIdentifier" is elementAXIdentifier)
+            tell menu bar item of menu bar systemMenuBarId
+                click
+                delay menuClickDelay
+            end tell
         end tell
+end tell
+on error errMsg
+end try
+tell application "System Events"
+    tell (first application process whose bundle identifier is bundleIdentifer)
+        set elementValue to name of (first menu item of menu 1 of menu bar 2 whose value of attribute "AXIdentifier" is elementAXIdentifier)
+        tell menu item statusAndLogsMenuItem of menu trayMainMenuId of menu bar item of menu bar systemMenuBarId
+            click
+            delay menuClickDelay
+        end tell
+        click button statusAndLogsWindowCloseButtonId of window statusAndLogsWindowId
+        return elementValue
     end tell
+end tell
 end run
diff --git a/test/extended/crc/ux/tray/applescripts/runOCLoginCommand.applescript b/test/extended/crc/ux/tray/applescripts/runOCLoginCommand.applescript
index f55205fe5..3c011fb31 100644
--- a/test/extended/crc/ux/tray/applescripts/runOCLoginCommand.applescript
+++ b/test/extended/crc/ux/tray/applescripts/runOCLoginCommand.applescript
@@ -7,8 +7,10 @@ try
         accept_insecure_connection(terminal)
         execute_command("clear", terminal)
         execute_command("oc whoami", terminal)
-        set result to command_output(whoAmICommandOutput)
-        return result
+        set user to command_output(whoAmICommandOutput)
+        # close terminal
+        close_terminal(terminal)
+        return user
 on error errMsg
         return errMsg
 end try
@@ -16,6 +18,7 @@ end run
 
 on get_terminal()
 tell application "Terminal"
+        activate
         set crcTerminal to do script ("")
         return crcTerminal
 end tell
@@ -29,10 +32,12 @@ end tell
 end execute_command
 
 on command_output(commandOutputLine)
+set result to ""
 tell application "Terminal"
         tell front window to set theText to contents of selected tab as text
-        return (paragraph commandOutputLine of theText)
+        set result to (paragraph commandOutputLine of theText)
 end tell
+return result
 end command_output
 
 on accept_insecure_connection(crcTerminal)
@@ -43,3 +48,12 @@ if insecure contains insecureConnectionQuestion
         execute_command("y", crcTerminal)
 end if
 end accept_insecure_connection
+
+on close_terminal(crcTerminal)
+tell application "Terminal"
+	do script ("") in crcTerminal
+        close window 1
+        delay 1
+        tell application "System Events" to keystroke return
+end tell
+end close_terminal 
\ No newline at end of file
diff --git a/test/extended/crc/ux/tray/applescripts/setPullSecret.applescript b/test/extended/crc/ux/tray/applescripts/setPullSecret.applescript
index ece2c3f9b..6e3a6fcb5 100644
--- a/test/extended/crc/ux/tray/applescripts/setPullSecret.applescript
+++ b/test/extended/crc/ux/tray/applescripts/setPullSecret.applescript
@@ -23,6 +23,7 @@ end paste_pullsecret_content
 
 on get_terminal()
 tell application "Terminal"
+        activate
         set crcTerminal to do script ("")
         return crcTerminal
 end tell
diff --git a/test/extended/crc/ux/tray/tray_unix.go b/test/extended/crc/ux/tray/tray_unix.go
index c6f5797aa..f4ef769a0 100644
--- a/test/extended/crc/ux/tray/tray_unix.go
+++ b/test/extended/crc/ux/tray/tray_unix.go
@@ -10,6 +10,7 @@ import (
 
 	clicumber "github.com/code-ready/clicumber/testsuite"
 	"github.com/code-ready/crc/test/extended/os/applescript"
+	"github.com/code-ready/crc/test/extended/util"
 )
 
 const (
@@ -24,6 +25,8 @@ const (
 
 	bundleIdentifier string = "com.redhat.codeready.containers"
 	appPath          string = "/Applications/CodeReady Containers.app"
+
+	trayClusterStateTimeout = "90"
 )
 
 var (
@@ -114,11 +117,11 @@ func (a applescriptHandler) SetPullSecret() error {
 }
 
 func (a applescriptHandler) IsClusterRunning() error {
-	return checkTrayShowsFieldWithValue(fieldState, stateRunning)
+	return waitTrayShowsFieldWithValue(fieldState, stateRunning)
 }
 
 func (a applescriptHandler) IsClusterStopped() error {
-	return checkTrayShowsFieldWithValue(fieldState, stateStopped)
+	return waitTrayShowsFieldWithValue(fieldState, stateStopped)
 }
 
 func (a applescriptHandler) CopyOCLoginCommandAsKubeadmin() error {
@@ -156,6 +159,26 @@ func clickOnElement(elementName string, scriptName string) error {
 		scriptName, bundleIdentifier, element.AXIdentifier)
 }
 
+func waitTrayShowsFieldWithValue(field string, expectedValue string) error {
+	retryCount := 15
+	iterationDuration, extraDuration, err :=
+		util.GetRetryParametersFromTimeoutInSeconds(retryCount, trayClusterStateTimeout)
+	if err != nil {
+		return err
+	}
+	for i := 0; i < retryCount; i++ {
+		err := checkTrayShowsFieldWithValue(field, expectedValue)
+		if err == nil {
+			return nil
+		}
+		time.Sleep(iterationDuration)
+	}
+	if extraDuration != 0 {
+		time.Sleep(extraDuration)
+	}
+	return fmt.Errorf("Tray did not showed %s ", expectedValue)
+}
+
 func checkTrayShowsFieldWithValue(field string, expectedValue string) error {
 	element, err := getElement(field, elements)
 	if err != nil {
diff --git a/test/extended/util/util.go b/test/extended/util/util.go
index 02929fc37..ecc285b8b 100644
--- a/test/extended/util/util.go
+++ b/test/extended/util/util.go
@@ -22,7 +22,8 @@ func CopyFilesToTestDir() error {
 	}
 
 	l := strings.Split(cwd, string(filepath.Separator))
-	dataDirPieces := append(l[:len(l)-3], "testdata")
+	dataDirPieces := l[:len(l)-3]
+	dataDirPieces = append(dataDirPieces, "testdata")
 	var volume string
 	if runtime.GOOS == "windows" {
 		volume = filepath.VolumeName(cwd)
diff --git a/test/integration/resize_test.go b/test/integration/resize_test.go
index 2fff44955..b89c61bc1 100644
--- a/test/integration/resize_test.go
+++ b/test/integration/resize_test.go
@@ -44,7 +44,7 @@ var _ = Describe("vary VM parameters: memory cpus, disk", func() {
 		})
 
 		It("stop CRC", func() {
-			Expect(RunCRCExpectSuccess("stop", "-f")).To(ContainSubstring("Stopped the OpenShift cluster"))
+			Expect(RunCRCExpectSuccess("stop", "-f")).To(MatchRegexp("[Ss]topped the OpenShift cluster"))
 		})
 
 	})
@@ -84,7 +84,7 @@ var _ = Describe("vary VM parameters: memory cpus, disk", func() {
 		})
 
 		It("stop CRC", func() {
-			Expect(RunCRCExpectSuccess("stop", "-f")).To(ContainSubstring("Stopped the OpenShift cluster"))
+			Expect(RunCRCExpectSuccess("stop", "-f")).To(MatchRegexp("[Ss]topped the OpenShift cluster"))
 		})
 	})