Skip to content

Commit

Permalink
enhancement(5832): added rpm test
Browse files Browse the repository at this point in the history
  • Loading branch information
kaanyalti committed Dec 2, 2024
1 parent dacca54 commit 1a4d087
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions testing/integration/restrict_upgrade_rpm_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//go:build integration

package integration

import (
"context"
"testing"

"github.com/elastic/elastic-agent/internal/pkg/agent/cmd"
atesting "github.com/elastic/elastic-agent/pkg/testing"
"github.com/elastic/elastic-agent/pkg/testing/define"
"github.com/stretchr/testify/require"
)

func TestRestrictUpgradeRPM(t *testing.T) {
define.Require(t, define.Requirements{
Group: RPM,
Stack: &define.Stack{},
Sudo: true,
OS: []define.OS{
{
Type: define.Linux,
Distro: "rhel",
},
},
})
t.Run("when agent is deployed via rpm, a user should not be able to upgrade the agent using the cli", func(t *testing.T) {
ctx := context.Background()

fixture, err := define.NewFixtureFromLocalBuild(t, define.Version(), atesting.WithPackageFormat("rpm"))
require.NoError(t, err)
installOpts := atesting.InstallOpts{
NonInteractive: true,
Privileged: true,
Force: true,
DelayEnroll: true,
}

_, err = fixture.Install(ctx, &installOpts)
require.NoError(t, err)
out, err := fixture.Exec(ctx, []string{"upgrade", "1.0.0"})
require.Error(t, err)
require.Contains(t, string(out), cmd.UpgradeDisabledError.Error())
})
}

0 comments on commit 1a4d087

Please sign in to comment.