mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: ensure deleting workspace creates audit log (#4537)
* fix: ensure deleting workspace creates audit log * getting rid of comments * remove whitespace * pushing failing test * fixed test
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/coderd/audit"
|
||||
"github.com/coder/coder/coderd/coderdtest"
|
||||
"github.com/coder/coder/coderd/database"
|
||||
"github.com/coder/coder/codersdk"
|
||||
@@ -534,7 +535,8 @@ func TestWorkspaceBuildStatus(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
defer cancel()
|
||||
client, closeDaemon, api := coderdtest.NewWithAPI(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
||||
auditor := audit.NewMock()
|
||||
client, closeDaemon, api := coderdtest.NewWithAPI(t, &coderdtest.Options{IncludeProvisionerDaemon: true, Auditor: auditor})
|
||||
user := coderdtest.CreateFirstUser(t, client)
|
||||
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
|
||||
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
|
||||
@@ -575,4 +577,8 @@ func TestWorkspaceBuildStatus(t *testing.T) {
|
||||
workspace, err = client.DeletedWorkspace(ctx, workspace.ID)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, codersdk.WorkspaceStatusDeleted, workspace.LatestBuild.Status)
|
||||
|
||||
// assert an audit log has been created for deletion
|
||||
require.Len(t, auditor.AuditLogs, 5)
|
||||
assert.Equal(t, database.AuditActionDelete, auditor.AuditLogs[4].Action)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user