mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: audit git ssh key regeneration (#4544)
This commit is contained in:
@ -5,9 +5,12 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"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/coderd/gitsshkey"
|
||||
"github.com/coder/coder/codersdk"
|
||||
"github.com/coder/coder/provisioner/echo"
|
||||
@ -73,8 +76,10 @@ func TestGitSSHKey(t *testing.T) {
|
||||
})
|
||||
t.Run("Regenerate", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
auditor := audit.NewMock()
|
||||
client := coderdtest.New(t, &coderdtest.Options{
|
||||
SSHKeygenAlgorithm: gitsshkey.AlgorithmEd25519,
|
||||
Auditor: auditor,
|
||||
})
|
||||
res := coderdtest.CreateFirstUser(t, client)
|
||||
|
||||
@ -89,6 +94,9 @@ func TestGitSSHKey(t *testing.T) {
|
||||
require.GreaterOrEqual(t, key2.UpdatedAt, key1.UpdatedAt)
|
||||
require.NotEmpty(t, key2.PublicKey)
|
||||
require.NotEqual(t, key2.PublicKey, key1.PublicKey)
|
||||
|
||||
require.Len(t, auditor.AuditLogs, 1)
|
||||
assert.Equal(t, database.AuditActionWrite, auditor.AuditLogs[0].Action)
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user