Skip to content

Commit

Permalink
Merge branch version/0-47-0-RC1 to adopt changes from PR #3551
Browse files Browse the repository at this point in the history
  • Loading branch information
as-builds committed Oct 23, 2024
2 parents 6c83f0c + b46d496 commit e8c9d35
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
4 changes: 2 additions & 2 deletions activestate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ scripts:
value: |
set -e
$constants.SET_ENV
TARGET=$BUILD_REMOTE_INSTALLER_TARGET
TARGET=$constants.BUILD_REMOTE_INSTALLER_TARGET
if [[ "$GOOS" == "windows" || "$OS" == "Windows_NT" ]]; then
TARGET="${BUILD_REMOTE_INSTALLER_TARGET}.exe"
TARGET="${constants.BUILD_REMOTE_INSTALLER_TARGET}.exe"
fi
GOFLAGS="" go install github.com/josephspurrier/goversioninfo/cmd/[email protected]
cd cmd/state-remote-installer
Expand Down
36 changes: 35 additions & 1 deletion test/integration/remote_installer_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ package integration

import (
"fmt"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"

svcAutostart "github.com/ActiveState/cli/cmd/state-svc/autostart"
anaConst "github.com/ActiveState/cli/internal/analytics/constants"
"github.com/ActiveState/cli/internal/constants"
"github.com/ActiveState/cli/internal/environment"
"github.com/ActiveState/cli/internal/fileutils"
"github.com/ActiveState/cli/internal/osutils"
"github.com/ActiveState/cli/internal/osutils/autostart"
"github.com/ActiveState/cli/internal/testhelpers/e2e"
"github.com/ActiveState/cli/internal/testhelpers/suite"
"github.com/ActiveState/cli/internal/testhelpers/tagsuite"
Expand All @@ -25,6 +30,28 @@ func (suite *RemoteInstallIntegrationTestSuite) TestInstall() {
ts := e2e.New(suite.T(), false)
defer ts.Close()

// Setup running the remote installer in restricted powershell mode.
if runtime.GOOS == "windows" {
getPolicy := func() string {
policy, err := exec.Command("powershell.exe", "Get-ExecutionPolicy").CombinedOutput()
suite.Require().NoError(err, "error getting policy: "+string(policy))
return strings.TrimSpace(string(policy))
}
setPolicy := func(policy string) {
output, err := exec.Command("powershell.exe", "Set-ExecutionPolicy", "-ExecutionPolicy", policy).CombinedOutput()
suite.Require().NoError(err, "error setting policy: "+string(output))
}

policy := getPolicy()
defer func() {
setPolicy(policy)
suite.Assert().Equal(policy, getPolicy(), "execution policy was not reset to '"+policy+"'; subsequent test results may be invalid")
}()

setPolicy("Restricted")
suite.Assert().Equal("Restricted", getPolicy(), "should have set powershell policy to 'Restricted'")
}

tests := []struct {
Name string
Version string
Expand Down Expand Up @@ -103,6 +130,13 @@ func (suite *RemoteInstallIntegrationTestSuite) TestInstall() {
}
}
suite.Assert().True(sessionTokenFound, "sessionToken was not found in analytics")

// Verify a startup shortcut was created (we use powershell to create it).
if runtime.GOOS == "windows" {
shortcut, err := autostart.AutostartPath("", svcAutostart.Options)
suite.Require().NoError(err)
suite.Assert().FileExists(shortcut)
}
})
}
}
Expand All @@ -112,7 +146,7 @@ func (s *RemoteInstallIntegrationTestSuite) setupTest(ts *e2e.Session) {
buildDir := fileutils.Join(root, "build")
installerExe := filepath.Join(buildDir, constants.StateRemoteInstallerCmd+osutils.ExeExtension)
if !fileutils.FileExists(installerExe) {
s.T().Fatal("E2E tests require a state-remote-installer binary. Run `state run build-installer`.")
s.T().Fatal("E2E tests require a state-remote-installer binary. Run `state run build-remote-installer`.")
}
s.remoteInstallerExe = ts.CopyExeToDir(installerExe, filepath.Join(ts.Dirs.Base, "installer"))
}
Expand Down

0 comments on commit e8c9d35

Please sign in to comment.