chore: do not clobber ~/.ssh/authorized_keys in certain tests (#10163)

The running of `make test` without any additional options will result in the tampering with of ~/.ssh/authorized_keys. This ensures that the tests use a temporary directory by setting SSH.RootPath consistent with other tests in this codebase.

Resolves forgejo/forgejo#10164

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10163
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Kevin Schoon <me@kevinschoon.com>
Co-committed-by: Kevin Schoon <me@kevinschoon.com>
This commit is contained in:
Kevin Schoon 2025-11-19 16:14:16 +01:00 committed by Gusted
parent 255ed593d3
commit 363a712aa2
2 changed files with 6 additions and 0 deletions

View file

@ -11,6 +11,8 @@ import (
"forgejo.org/models/db"
"forgejo.org/models/unittest"
user_model "forgejo.org/models/user"
"forgejo.org/modules/setting"
"forgejo.org/modules/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -18,6 +20,7 @@ import (
func TestAddLdapSSHPublicKeys(t *testing.T) {
require.NoError(t, unittest.PrepareTestDatabase())
defer test.MockVariableValue(&setting.SSH.RootPath, t.TempDir())()
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
s := &auth.Source{ID: 1}

View file

@ -8,6 +8,8 @@ import (
"testing"
"forgejo.org/models/unittest"
"forgejo.org/modules/setting"
"forgejo.org/modules/test"
driver_options "forgejo.org/services/f3/driver/options"
_ "forgejo.org/models"
@ -22,6 +24,7 @@ import (
func TestF3(t *testing.T) {
require.NoError(t, unittest.PrepareTestDatabase())
defer test.MockVariableValue(&setting.SSH.RootPath, t.TempDir())()
tests_f3.ForgeCompliance(t, driver_options.Name)
}